*: suppress ~60% of "aliased warnings" on gcc-4.4.1
[oweals/busybox.git] / modutils / modprobe.c
index 0d65d5f19997940dcf8ff7db52421b1b16402879..292f2df22e518432b0786789e63fb02bb9e49389 100644 (file)
@@ -70,7 +70,7 @@ struct globals {
        int num_unresolved_deps;
        /* bool. "Did we have 'symbol:FOO' requested on cmdline?" */
        smallint need_symbols;
-};
+} FIX_ALIASING;
 #define G (*(struct globals*)&bb_common_bufsiz1)
 #define INIT_G() do { } while (0)
 
@@ -80,12 +80,14 @@ static int read_config(const char *path);
 static char *gather_options_str(char *opts, const char *append)
 {
        /* Speed-optimized. We call gather_options_str many times. */
-       if (opts == NULL) {
-               opts = xstrdup(append);
-       } else {
-               int optlen = strlen(opts);
-               opts = xrealloc(opts, optlen + strlen(append) + 2);
-               sprintf(opts + optlen, " %s", append);
+       if (append) {
+               if (opts == NULL) {
+                       opts = xstrdup(append);
+               } else {
+                       int optlen = strlen(opts);
+                       opts = xrealloc(opts, optlen + strlen(append) + 2);
+                       sprintf(opts + optlen, " %s", append);
+               }
        }
        return opts;
 }
@@ -290,6 +292,8 @@ static int do_modprobe(struct module_entry *m)
                        options = gather_options_str(options, G.cmdline_mopts);
                rc = bb_init_module(fn, options);
                DBG("loaded %s '%s', rc:%d", fn, options, rc);
+               if (rc == EEXIST)
+                       rc = 0;
                free(options);
                if (rc) {
                        bb_error_msg("failed to load module %s (%s): %s",
@@ -373,7 +377,7 @@ int modprobe_main(int argc UNUSED_PARAM, char **argv)
                         * "If name is NULL, all unused modules marked
                         * autoclean will be removed".
                         */
-                       if (bb_delete_module(NULL, O_NONBLOCK|O_EXCL) != 0)
+                       if (bb_delete_module(NULL, O_NONBLOCK | O_EXCL) != 0)
                                bb_perror_msg_and_die("rmmod");
                }
                return EXIT_SUCCESS;