From 16640487b0a52b2923ba402feb5ff5d7b0b26a81 Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Fri, 5 Apr 2024 12:59:33 +0000 Subject: [PATCH] installer: Fix lots of constify issues Signed-off-by: Michael Tremer Signed-off-by: Arne Fitzenreiter --- 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 -- 2.39.2