Cleanup patch from Rob Sullivan.

This commit is contained in:
Rob Landley 2006-01-15 02:20:06 +00:00
parent 734a779a42
commit 855f1e1320

View File

@ -5,31 +5,16 @@
* Busybox port 2002 by Nick Fedchik <nick@fedchik.org.ua> * Busybox port 2002 by Nick Fedchik <nick@fedchik.org.ua>
* Glenn McGrath <bug1@iinet.net.au> * Glenn McGrath <bug1@iinet.net.au>
* *
* This program is free software; you can redistribute it and/or modify * Licensed under the GPL v2 or later, see the file LICENSE in this tarball.
* 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
*
*/ */
#include <sys/syslog.h> #include <sys/syslog.h>
#include <sys/socket.h> #include <sys/socket.h>
#include <sys/ioctl.h> #include <sys/ioctl.h>
#include <errno.h> #include <errno.h>
#include <getopt.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <unistd.h>
#include <net/if.h> #include <net/if.h>
#include <netinet/ether.h> #include <netinet/ether.h>
@ -61,7 +46,7 @@ typedef struct mactable_s {
struct ether_addr *mac; struct ether_addr *mac;
} mactable_t; } mactable_t;
static unsigned char use_syslog; static unsigned long flags;
static void serror(const char *s, ...) __attribute__ ((noreturn)); static void serror(const char *s, ...) __attribute__ ((noreturn));
@ -71,14 +56,12 @@ static void serror(const char *s, ...)
va_start(ap, s); va_start(ap, s);
if (use_syslog) { if (flags & 1) {
openlog(bb_applet_name, 0, LOG_LOCAL0); openlog(bb_applet_name, 0, LOG_LOCAL0);
vsyslog(LOG_ERR, s, ap); vsyslog(LOG_ERR, s, ap);
closelog(); closelog();
} else { } else
bb_verror_msg(s, ap); bb_error_msg(s, ap);
putc('\n', stderr);
}
va_end(ap); va_end(ap);
@ -106,25 +89,12 @@ int nameif_main(int argc, char **argv)
const char *fname = "/etc/mactab"; const char *fname = "/etc/mactab";
char *line; char *line;
int ctl_sk; int ctl_sk;
int opt;
int if_index = 1; int if_index = 1;
mactable_t *ch; mactable_t *ch;
flags = bb_getopt_ulflags(argc, argv, "sc:", &fname);
while ((opt = getopt(argc, argv, "c:s")) != -1) { if (argc - optind == 1)
switch (opt) {
case 'c':
fname = optarg;
break;
case 's':
use_syslog = 1;
break;
default:
bb_show_usage();
}
}
if ((argc - optind) & 1)
bb_show_usage(); bb_show_usage();
if (optind < argc) { if (optind < argc) {
@ -177,7 +147,7 @@ int nameif_main(int argc, char **argv)
while (clist) { while (clist) {
struct ifreq ifr; struct ifreq ifr;
bzero(&ifr, sizeof(struct ifreq)); memset(&ifr, 0, sizeof(struct ifreq));
if_index++; if_index++;
ifr.ifr_ifindex = if_index; ifr.ifr_ifindex = if_index;