svn commit: trunk/busybox/networking

landley at busybox.net landley at busybox.net
Sun Jan 15 02:20:08 UTC 2006


Author: landley
Date: 2006-01-14 18:20:06 -0800 (Sat, 14 Jan 2006)
New Revision: 13333

Log:
Cleanup patch from Rob Sullivan.


Modified:
   trunk/busybox/networking/nameif.c


Changeset:
Modified: trunk/busybox/networking/nameif.c
===================================================================
--- trunk/busybox/networking/nameif.c	2006-01-14 23:22:31 UTC (rev 13332)
+++ trunk/busybox/networking/nameif.c	2006-01-15 02:20:06 UTC (rev 13333)
@@ -5,31 +5,16 @@
  * Busybox port 2002 by Nick Fedchik <nick at fedchik.org.ua>
  *			Glenn McGrath <bug1 at iinet.net.au>
  *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
- * 02111-1307 USA
- *
+ * Licensed under the GPL v2 or later, see the file LICENSE in this tarball. 
  */
 
-
 #include <sys/syslog.h>
 #include <sys/socket.h>
 #include <sys/ioctl.h>
 #include <errno.h>
-#include <getopt.h>
 #include <stdlib.h>
 #include <string.h>
+#include <unistd.h>
 #include <net/if.h>
 #include <netinet/ether.h>
 
@@ -61,7 +46,7 @@
 	struct ether_addr *mac;
 } mactable_t;
 
-static unsigned char use_syslog;
+static unsigned long flags;
 
 static void serror(const char *s, ...) __attribute__ ((noreturn));
 
@@ -71,14 +56,12 @@
 
 	va_start(ap, s);
 
-	if (use_syslog) {
+	if (flags & 1) {
 		openlog(bb_applet_name, 0, LOG_LOCAL0);
 		vsyslog(LOG_ERR, s, ap);
 		closelog();
-	} else {
-		bb_verror_msg(s, ap);
-		putc('\n', stderr);
-	}
+	} else
+		bb_error_msg(s, ap);
 
 	va_end(ap);
 
@@ -106,25 +89,12 @@
 	const char *fname = "/etc/mactab";
 	char *line;
 	int ctl_sk;
-	int opt;
 	int if_index = 1;
 	mactable_t *ch;
 
+	flags = bb_getopt_ulflags(argc, argv, "sc:", &fname);
 
-	while ((opt = getopt(argc, argv, "c:s")) != -1) {
-		switch (opt) {
-		case 'c':
-			fname = optarg;
-			break;
-		case 's':
-			use_syslog = 1;
-			break;
-		default:
-			bb_show_usage();
-		}
-	}
-
-	if ((argc - optind) & 1)
+	if (argc - optind == 1)
 		bb_show_usage();
 
 	if (optind < argc) {
@@ -177,7 +147,7 @@
 	while (clist) {
 		struct ifreq ifr;
 
-		bzero(&ifr, sizeof(struct ifreq));
+		memset(&ifr, 0, sizeof(struct ifreq));
 		if_index++;
 		ifr.ifr_ifindex = if_index;
 




More information about the busybox-cvs mailing list