]> git.ipfire.org Git - ipfire-2.x.git/commitdiff
installer: Fix loads of compiler warnings
authorMichael Tremer <michael.tremer@ipfire.org>
Sat, 25 Oct 2014 13:54:45 +0000 (15:54 +0200)
committerMichael Tremer <michael.tremer@ipfire.org>
Sat, 25 Oct 2014 13:54:45 +0000 (15:54 +0200)
src/installer/Makefile.am
src/installer/configure.ac
src/installer/hw.c
src/installer/hw.h
src/installer/main.c

index f52a5940ac474e2f413016bbae9e3b0ca02c7dc8..62625fd0fe1666906b294aa913ad07e833f60388 100644 (file)
@@ -44,6 +44,7 @@ installer_SOURCES = \
        main.c
 
 installer_CFLAGS = \
        main.c
 
 installer_CFLAGS = \
+       $(AM_CFLAGS) \
        $(BLKID_CFLAGS) \
        $(LIBSMOOTH_CFLAGS) \
        $(PCI_CFLAGS) \
        $(BLKID_CFLAGS) \
        $(LIBSMOOTH_CFLAGS) \
        $(PCI_CFLAGS) \
index e93e0afe415b99e6a6158b81f234aac1d93a37ef..85c5c5cb8c95a2c6f56680e5c541e9b889bb9234 100644 (file)
@@ -39,6 +39,16 @@ AC_PROG_CC
 AC_PROG_CC_C99
 AC_PROG_CC_C_O
 
 AC_PROG_CC_C99
 AC_PROG_CC_C_O
 
+CC_CHECK_FLAGS_APPEND([with_cflags], [CFLAGS], [\
+       "-Wformat=2 -Wformat-security -Wformat-nonliteral" \
+       -Werror=overflow \
+       -fno-strict-aliasing \
+       -fstack-protector \
+       -fstack-protector-strong \
+       -fPIE \
+       --param=ssp-buffer-size=4])
+AC_SUBST([OUR_CFLAGS], "$with_cflags")
+
 AC_PATH_PROG([M4], [m4])
 
 # Gettext
 AC_PATH_PROG([M4], [m4])
 
 # Gettext
index 651ffdf27c696a1560813388fcc74077baa007ad..e14a47016e951e9993e867dcb8e082b87bda2cb5 100644 (file)
@@ -340,7 +340,7 @@ void hw_free_disks(struct hw_disk** disks) {
        free(disks);
 }
 
        free(disks);
 }
 
-unsigned int hw_count_disks(struct hw_disk** disks) {
+unsigned int hw_count_disks(const struct hw_disk** disks) {
        unsigned int ret = 0;
 
        while (*disks++)
        unsigned int ret = 0;
 
        while (*disks++)
@@ -353,7 +353,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;
 
        struct hw_disk** ret = hw_create_disks();
        struct hw_disk** selected_disks = ret;
 
-       unsigned int num_disks = hw_count_disks(disks);
+       unsigned int num_disks = hw_count_disks((const struct hw_disk**)disks);
 
        for (unsigned int i = 0; i < num_disks; i++) {
                if (!selection || selection[i]) {
 
        for (unsigned int i = 0; i < num_disks; i++) {
                if (!selection || selection[i]) {
@@ -1029,12 +1029,13 @@ static char* hw_get_uuid(const char* dev) {
        return uuid;
 }
 
        return uuid;
 }
 
+#define FSTAB_FMT "UUID=%s %-8s %-4s %-10s %d %d\n"
+
 int hw_write_fstab(struct hw_destination* dest) {
        FILE* f = fopen(DESTINATION_MOUNT_PATH "/etc/fstab", "w");
        if (!f)
                return -1;
 
 int hw_write_fstab(struct hw_destination* dest) {
        FILE* f = fopen(DESTINATION_MOUNT_PATH "/etc/fstab", "w");
        if (!f)
                return -1;
 
-       const char* fmt = "UUID=%s %-8s %-4s %-10s %d %d\n";
        char* uuid = NULL;
 
        // boot
        char* uuid = NULL;
 
        // boot
@@ -1042,7 +1043,7 @@ int hw_write_fstab(struct hw_destination* dest) {
                uuid = hw_get_uuid(dest->part_boot);
 
                if (uuid) {
                uuid = hw_get_uuid(dest->part_boot);
 
                if (uuid) {
-                       fprintf(f, fmt, uuid, "/boot", "auto", "defaults", 1, 2);
+                       fprintf(f, FSTAB_FMT, uuid, "/boot", "auto", "defaults", 1, 2);
                        free(uuid);
                }
        }
                        free(uuid);
                }
        }
@@ -1052,7 +1053,7 @@ int hw_write_fstab(struct hw_destination* dest) {
                uuid = hw_get_uuid(dest->part_swap);
 
                if (uuid) {
                uuid = hw_get_uuid(dest->part_swap);
 
                if (uuid) {
-                       fprintf(f, fmt, uuid, "swap", "swap", "defaults,pri=1", 0, 0);
+                       fprintf(f, FSTAB_FMT, uuid, "swap", "swap", "defaults,pri=1", 0, 0);
                        free(uuid);
                }
        }
                        free(uuid);
                }
        }
@@ -1060,7 +1061,7 @@ int hw_write_fstab(struct hw_destination* dest) {
        // root
        uuid = hw_get_uuid(dest->part_root);
        if (uuid) {
        // root
        uuid = hw_get_uuid(dest->part_root);
        if (uuid) {
-               fprintf(f, fmt, uuid, "/", "auto", "defaults", 1, 1);
+               fprintf(f, FSTAB_FMT, uuid, "/", "auto", "defaults", 1, 1);
                free(uuid);
        }
 
                free(uuid);
        }
 
@@ -1069,7 +1070,7 @@ int hw_write_fstab(struct hw_destination* dest) {
                uuid = hw_get_uuid(dest->part_data);
 
                if (uuid) {
                uuid = hw_get_uuid(dest->part_data);
 
                if (uuid) {
-                       fprintf(f, fmt, uuid, "/var", "auto", "defaults", 1, 1);
+                       fprintf(f, FSTAB_FMT, uuid, "/var", "auto", "defaults", 1, 1);
                        free(uuid);
                }
        }
                        free(uuid);
                }
        }
index 41ff093ad23b38661523edcc56d2d01d7c17c2b9..83753fdc0dec1d937e7a0193a6a1c6f38cb96900 100644 (file)
@@ -107,7 +107,7 @@ 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);
 
 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(struct hw_disk** disks);
+unsigned int hw_count_disks(const 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_disks(struct hw_disk** disks, int* selection);
 struct hw_disk** hw_select_first_disk(const struct hw_disk** disks);
 
@@ -131,6 +131,8 @@ int hw_write_fstab(struct hw_destination* dest);
 char* hw_find_backup_file(const char* output, const char* search_path);
 int hw_restore_backup(const char* output, const char* backup_path, const char* destination);
 
 char* hw_find_backup_file(const char* output, const char* search_path);
 int hw_restore_backup(const char* output, const char* backup_path, const char* destination);
 
+int hw_start_networking(const char* output);
+
 void hw_sync();
 
 #endif /* HEADER_HW_H */
 void hw_sync();
 
 #endif /* HEADER_HW_H */
index 5a2e0c40670dad1f083cdffccad92214e525c5e2..1d8abb81ba39279daeddb4f871151614e651b00a 100644 (file)
@@ -7,6 +7,7 @@
  * Contains main entry point, and misc functions.6
  * 
  */
  * Contains main entry point, and misc functions.6
  * 
  */
+#define _GNU_SOURCE
 
 #include <assert.h>
 #include <errno.h>
 
 #include <assert.h>
 #include <errno.h>
@@ -162,7 +163,7 @@ static int newtLicenseBox(const char* title, const char* text, int width, int he
        return ret;
 }
 
        return ret;
 }
 
-int write_lang_configs(const char *lang) {
+int write_lang_configs(char* lang) {
        struct keyvalue *kv = initkeyvalues();
 
        /* default stuff for main/settings. */
        struct keyvalue *kv = initkeyvalues();
 
        /* default stuff for main/settings. */
@@ -206,7 +207,7 @@ static char* center_string(const char* str, int width) {
 }
 
 #define DEFAULT_LANG "English"
 }
 
 #define DEFAULT_LANG "English"
-#define NUM_LANGS 8
+#define NUM_LANGS 10
 
 static struct lang {
        const char* code;
 
 static struct lang {
        const char* code;
@@ -253,7 +254,7 @@ static void parse_command_line(struct config* c) {
 
                while (token) {
                        strncpy(buffer, token, sizeof(buffer));
 
                while (token) {
                        strncpy(buffer, token, sizeof(buffer));
-                       char* val = &buffer;
+                       char* val = buffer;
                        char* key = strsep(&val, "=");
 
                        // serial console
                        char* key = strsep(&val, "=");
 
                        // serial console
@@ -270,7 +271,7 @@ static void parse_command_line(struct config* c) {
 
                        // download url
                        else if (strcmp(key, "installer.download-url") == 0) {
 
                        // download url
                        else if (strcmp(key, "installer.download-url") == 0) {
-                               strncpy(&c->download_url, val, sizeof(c->download_url));
+                               strncpy(c->download_url, val, sizeof(c->download_url));
                                c->perform_download = 1;
 
                                // Require networking for the download
                                c->perform_download = 1;
 
                                // Require networking for the download
@@ -301,11 +302,10 @@ int main(int argc, char *argv[]) {
        char message[STRING_SIZE];
        char title[STRING_SIZE];
        int allok = 0;
        char message[STRING_SIZE];
        char title[STRING_SIZE];
        int allok = 0;
-       FILE *handle, *copying;
-       char line[STRING_SIZE];
-               
-       setlocale (LC_ALL, "");
-       sethostname( SNAME , 10);
+       FILE *copying;
+
+       setlocale(LC_ALL, "");
+       sethostname(SNAME, 10);
 
        /* Log file/terminal stuff. */
        FILE* flog = NULL;
 
        /* Log file/terminal stuff. */
        FILE* flog = NULL;
@@ -364,7 +364,7 @@ int main(int argc, char *argv[]) {
                assert(choice <= NUM_LANGS);
 
                fprintf(flog, "Selected language: %s (%s)\n", languages[choice].name, languages[choice].code);
                assert(choice <= NUM_LANGS);
 
                fprintf(flog, "Selected language: %s (%s)\n", languages[choice].name, languages[choice].code);
-               snprintf(language, sizeof(language), languages[choice].code);
+               snprintf(language, sizeof(language), "%s", languages[choice].code);
 
                setenv("LANGUAGE", language, 1);
                setlocale(LC_ALL, language);
 
                setenv("LANGUAGE", language, 1);
                setlocale(LC_ALL, language);
@@ -487,7 +487,7 @@ int main(int argc, char *argv[]) {
                // Read the license file.
                if (!(copying = fopen(LICENSE_FILE, "r"))) {
                        sprintf(discl_msg, "Could not open license file: %s\n", LICENSE_FILE);
                // Read the license file.
                if (!(copying = fopen(LICENSE_FILE, "r"))) {
                        sprintf(discl_msg, "Could not open license file: %s\n", LICENSE_FILE);
-                       fprintf(flog, discl_msg);
+                       fprintf(flog, "%s", discl_msg);
                } else {
                        fread(discl_msg, 1, 40000, copying);
                        fclose(copying);
                } else {
                        fread(discl_msg, 1, 40000, copying);
                        fclose(copying);
@@ -510,7 +510,7 @@ int main(int argc, char *argv[]) {
 
        // Check how many disks have been found and what
        // we can do with them.
 
        // Check how many disks have been found and what
        // we can do with them.
-       unsigned int num_disks = hw_count_disks(disks);
+       unsigned int num_disks = hw_count_disks((const struct hw_disk**)disks);
 
        while (1) {
                // no harddisks found
 
        while (1) {
                // no harddisks found
@@ -522,7 +522,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)) {
                // 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(disks);
+                       selected_disks = hw_select_first_disk((const struct hw_disk**)disks);
 
                // more than one usable disk has been found and
                // the user needs to choose what to do with them
 
                // more than one usable disk has been found and
                // the user needs to choose what to do with them
@@ -531,7 +531,7 @@ int main(int argc, char *argv[]) {
                        int disk_selection[num_disks];
 
                        for (unsigned int i = 0; i < num_disks; i++) {
                        int disk_selection[num_disks];
 
                        for (unsigned int i = 0; i < num_disks; i++) {
-                               disk_names[i] = &disks[i]->description;
+                               disk_names[i] = disks[i]->description;
                                disk_selection[i] = 0;
                        }
 
                                disk_selection[i] = 0;
                        }
 
@@ -562,7 +562,7 @@ int main(int argc, char *argv[]) {
                if (config.unattended)
                        break;
 
                if (config.unattended)
                        break;
 
-               num_selected_disks = hw_count_disks(selected_disks);
+               num_selected_disks = hw_count_disks((const struct hw_disk**)selected_disks);
 
                if (num_selected_disks == 1) {
                        snprintf(message, sizeof(message),
 
                if (num_selected_disks == 1) {
                        snprintf(message, sizeof(message),
@@ -645,7 +645,7 @@ int main(int argc, char *argv[]) {
                        if (HW_FS_DEFAULT == filesystems[i].fstype)
                                fs_choice = i;
 
                        if (HW_FS_DEFAULT == filesystems[i].fstype)
                                fs_choice = i;
 
-                       fs_names[i] = filesystems[i].description;
+                       fs_names[i] = &filesystems[i].description;
                }
 
                rc = newtWinMenu(_("Filesystem Selection"), _("Please choose your filesystem:"),
                }
 
                rc = newtWinMenu(_("Filesystem Selection"), _("Please choose your filesystem:"),