From patchwork Fri Apr 5 12:59:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Tremer X-Patchwork-Id: 7702 Return-Path: Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384 client-signature ECDSA (secp384r1) client-digest SHA384) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by web04.haj.ipfire.org (Postfix) with ESMTPS id 4V9z9B3lMGz3wZV for ; Fri, 5 Apr 2024 12:59:58 +0000 (UTC) Received: from mail02.haj.ipfire.org (mail02.haj.ipfire.org [172.28.1.201]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384 client-signature ECDSA (secp384r1) client-digest SHA384) (Client CN "mail02.haj.ipfire.org", Issuer "R3" (verified OK)) by mail01.ipfire.org (Postfix) with ESMTPS id 4V9z943Phbz5Vt; Fri, 5 Apr 2024 12:59:52 +0000 (UTC) Received: from mail02.haj.ipfire.org (localhost [127.0.0.1]) by mail02.haj.ipfire.org (Postfix) with ESMTP id 4V9z935Mllz32ls; Fri, 5 Apr 2024 12:59:51 +0000 (UTC) Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384 client-signature ECDSA (secp384r1) client-digest SHA384) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by mail02.haj.ipfire.org (Postfix) with ESMTPS id 4V9z911btkz2ytr for ; Fri, 5 Apr 2024 12:59:49 +0000 (UTC) Received: from michael.haj.ipfire.org (michael.haj.ipfire.org [172.28.1.242]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) client-signature ECDSA (secp384r1)) (Client CN "michael.haj.ipfire.org", Issuer "R3" (verified OK)) by mail01.ipfire.org (Postfix) with ESMTPS id 4V9z8y0T21z3nD; Fri, 5 Apr 2024 12:59:46 +0000 (UTC) Received: by michael.haj.ipfire.org (Postfix, from userid 0) id 4V9z8x3F7bzThpB; Fri, 5 Apr 2024 12:59:45 +0000 (UTC) From: Michael Tremer To: development@lists.ipfire.org Subject: [PATCH 04/13] installer: Fix lots of constify issues Date: Fri, 5 Apr 2024 12:59:33 +0000 Message-Id: <20240405125942.1803058-4-michael.tremer@ipfire.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240405125942.1803058-1-michael.tremer@ipfire.org> References: <20240405125942.1803058-1-michael.tremer@ipfire.org> MIME-Version: 1.0 Message-ID-Hash: ZUPEQKZCYLO2NRODCBDI4RIDO4QWZFPB X-Message-ID-Hash: ZUPEQKZCYLO2NRODCBDI4RIDO4QWZFPB X-MailFrom: root@michael.haj.ipfire.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Michael Tremer X-Mailman-Version: 3.3.8 Precedence: list List-Id: IPFire development talk Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Signed-off-by: Michael Tremer --- src/installer/hw.c | 8 ++++---- src/installer/hw.h | 4 ++-- src/installer/main.c | 8 ++++---- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/installer/hw.c b/src/installer/hw.c index 46330ce43..72d736bb1 100644 --- a/src/installer/hw.c +++ b/src/installer/hw.c @@ -285,7 +285,7 @@ struct hw_disk** hw_find_disks(struct hw* hw, const char* sourcedrive) { struct hw_disk** disks = ret; // Determine the disk device of source if it is a partition - char* sourcedisk = NULL; + const char* sourcedisk = NULL; char syssource[PATH_MAX]; (void)snprintf(syssource, sizeof(syssource) - 1, "/sys/class/block/%s", sourcedrive + 5); struct udev_device* s_dev = udev_device_new_from_syspath(hw->udev, syssource); @@ -424,7 +424,7 @@ void hw_free_disks(struct hw_disk** disks) { free(disks); } -unsigned int hw_count_disks(const struct hw_disk** disks) { +unsigned int hw_count_disks(struct hw_disk** disks) { unsigned int ret = 0; while (*disks++) @@ -437,7 +437,7 @@ struct hw_disk** hw_select_disks(struct hw_disk** disks, int* selection) { struct hw_disk** ret = hw_create_disks(); struct hw_disk** selected_disks = ret; - unsigned int num_disks = hw_count_disks((const struct hw_disk**)disks); + unsigned int num_disks = hw_count_disks(disks); for (unsigned int i = 0; i < num_disks; i++) { if (!selection || selection[i]) { @@ -454,7 +454,7 @@ struct hw_disk** hw_select_disks(struct hw_disk** disks, int* selection) { return ret; } -struct hw_disk** hw_select_first_disk(const struct hw_disk** disks) { +struct hw_disk** hw_select_first_disk(struct hw_disk** disks) { struct hw_disk** ret = hw_create_disks(); struct hw_disk** selected_disks = ret; diff --git a/src/installer/hw.h b/src/installer/hw.h index bba06da95..92f32b67f 100644 --- a/src/installer/hw.h +++ b/src/installer/hw.h @@ -136,9 +136,9 @@ char* hw_find_source_medium(struct hw* hw); struct hw_disk** hw_find_disks(struct hw* hw, const char* sourcedrive); void hw_free_disks(struct hw_disk** disks); -unsigned int hw_count_disks(const struct hw_disk** disks); +unsigned int hw_count_disks(struct hw_disk** disks); struct hw_disk** hw_select_disks(struct hw_disk** disks, int* selection); -struct hw_disk** hw_select_first_disk(const struct hw_disk** disks); +struct hw_disk** hw_select_first_disk(struct hw_disk** disks); struct hw_destination* hw_make_destination(struct hw* hw, int part_type, struct hw_disk** disks, int disable_swap, int filesystem); diff --git a/src/installer/main.c b/src/installer/main.c index c31c032c2..20a8cc962 100644 --- a/src/installer/main.c +++ b/src/installer/main.c @@ -192,11 +192,11 @@ static int newtLicenseBox(const char* title, const char* text, int width, int he return ret; } -int write_lang_configs(char* lang) { +int write_lang_configs(const char* lang) { struct keyvalue *kv = initkeyvalues(); /* default stuff for main/settings. */ - replacekeyvalue(kv, "LANGUAGE", lang); + replacekeyvalue(kv, "LANGUAGE", (char*)lang); replacekeyvalue(kv, "HOSTNAME", DISTRO_SNAME); replacekeyvalue(kv, "THEME", "ipfire"); writekeyvalues(kv, "/harddisk" CONFIG_ROOT "/main/settings"); @@ -279,7 +279,7 @@ static struct config { int disable_swap; char download_url[STRING_SIZE]; char postinstall[STRING_SIZE]; - char* language; + const char* language; } config = { .unattended = 0, .serial_console = 0, @@ -606,7 +606,7 @@ int main(int argc, char *argv[]) { // or if we are running in unattended mode, we will select // the first disk and go with that one } else if ((num_disks == 1) || (config.unattended && num_disks >= 1)) { - selected_disks = hw_select_first_disk((const struct hw_disk**)disks); + selected_disks = hw_select_first_disk(disks); // more than one usable disk has been found and // the user needs to choose what to do with them