Remove code for protocols we don't properly support. (Most of this could
[oweals/busybox.git] / networking / nameif.c
index 5fee465ccb3ea98153bc18ea504f671747a940c8..f28e5ebe33c02c27a164807a3588b32ac07b6600 100644 (file)
@@ -5,7 +5,7 @@
  * Busybox port 2002 by Nick Fedchik <nick@fedchik.org.ua>
  *                     Glenn McGrath <bug1@iinet.net.au>
  *
- * Licensed under the GPL v2 or later, see the file LICENSE in this tarball. 
+ * Licensed under the GPL v2 or later, see the file LICENSE in this tarball.
  */
 
 #include <sys/syslog.h>
@@ -48,7 +48,7 @@ typedef struct mactable_s {
 
 static unsigned long flags;
 
-static void serror(const char *s, ...) __attribute__ ((noreturn));
+static void serror(const char *s, ...) ATTRIBUTE_NORETURN;
 
 static void serror(const char *s, ...)
 {
@@ -60,16 +60,17 @@ static void serror(const char *s, ...)
                openlog(bb_applet_name, 0, LOG_LOCAL0);
                vsyslog(LOG_ERR, s, ap);
                closelog();
-       } else
-               bb_error_msg(s, ap);
-
+       } else {
+               bb_verror_msg(s, ap);
+               putc('\n', stderr);
+       }
        va_end(ap);
 
        exit(EXIT_FAILURE);
 }
 
 /* Check ascii str_macaddr, convert and copy to *mac */
-static struct ether_addr *cc_macaddr(char *str_macaddr)
+static struct ether_addr *cc_macaddr(const char *str_macaddr)
 {
        struct ether_addr *lmac, *mac;
 
@@ -94,7 +95,7 @@ int nameif_main(int argc, char **argv)
 
        flags = bb_getopt_ulflags(argc, argv, "sc:", &fname);
 
-       if (argc - optind == 1)
+       if ((argc - optind) & 1)
                bb_show_usage();
 
        if (optind < argc) {
@@ -120,8 +121,10 @@ int nameif_main(int argc, char **argv)
                        size_t name_length;
 
                        line_ptr = line + strspn(line, " \t");
-                       if ((line_ptr[0] == '#') || (line_ptr[0] == '\n'))
+                       if ((line_ptr[0] == '#') || (line_ptr[0] == '\n')) {
+                               free(line);
                                continue;
+                       }
                        name_length = strcspn(line_ptr, " \t");
                        ch = xcalloc(1, sizeof(mactable_t));
                        ch->ifname = bb_xstrndup(line_ptr, name_length);