From 703e20235aa0624d3ff4335c1e86edaa6e21efe2 Mon Sep 17 00:00:00 2001 From: Denis Vlasenko Date: Mon, 22 Jan 2007 14:12:08 +0000 Subject: [PATCH] cleanups: unnecessary casts, unified const_1, eliminate cross-.c file prototypes (heresy!), add spaces in places like "flags&NETSTAT_CONNECTED", removed unused #defines, #ifdef -> #if, use uint32_t for ipv4 addrs. --- include/libbb.h | 6 + libbb/inet_common.c | 51 ++++---- libbb/lineedit.c | 4 +- libbb/messages.c | 3 + libbb/xconnect.c | 5 +- modutils/insmod.c | 2 - networking/arping.c | 3 +- networking/httpd.c | 4 +- networking/nc.c | 15 +-- networking/netstat.c | 258 ++++++++++++++++++-------------------- networking/ping.c | 3 +- networking/ping6.c | 17 ++- networking/route.c | 72 +++++------ networking/telnet.c | 4 +- networking/traceroute.c | 40 +++--- networking/udhcp/socket.c | 2 +- shell/lash.c | 2 +- 17 files changed, 231 insertions(+), 260 deletions(-) diff --git a/include/libbb.h b/include/libbb.h index c1c9486c4..cd192b9eb 100644 --- a/include/libbb.h +++ b/include/libbb.h @@ -486,6 +486,9 @@ extern void bb_vinfo_msg(const char *s, va_list p); extern int bb_cat(char** argv); extern int bb_echo(char** argv); extern int bb_test(int argc, char** argv); +#if ENABLE_ROUTE +extern void bb_displayroutes(int noresolve, int netstatfmt); +#endif /* Networking */ @@ -740,6 +743,9 @@ extern const char bb_path_motd_file[]; extern const char bb_path_wtmp_file[]; extern const char bb_dev_null[]; +extern const int const_int_0; +extern const int const_int_1; + #ifndef BUFSIZ #define BUFSIZ 4096 #endif diff --git a/libbb/inet_common.c b/libbb/inet_common.c index 9cdcb11de..6b31c79f2 100644 --- a/libbb/inet_common.c +++ b/libbb/inet_common.c @@ -33,19 +33,23 @@ int INET_resolve(const char *name, struct sockaddr_in *s_in, int hostfirst) /* If we expect this to be a hostname, try hostname database first */ #ifdef DEBUG if (hostfirst) { - bb_error_msg("gethostbyname (%s)", name); + bb_error_msg("gethostbyname(%s)", name); } #endif - if (hostfirst && (hp = gethostbyname(name)) != (struct hostent *) NULL) { - memcpy((char *) &s_in->sin_addr, (char *) hp->h_addr_list[0], - sizeof(struct in_addr)); - return 0; + if (hostfirst) { + hp = gethostbyname(name); + if (hp != NULL) { + memcpy(&s_in->sin_addr, hp->h_addr_list[0], + sizeof(struct in_addr)); + return 0; + } } /* Try the NETWORKS database to see if this is a known network. */ #ifdef DEBUG - bb_error_msg("getnetbyname (%s)", name); + bb_error_msg("getnetbyname(%s)", name); #endif - if ((np = getnetbyname(name)) != (struct netent *) NULL) { + np = getnetbyname(name); + if (np != NULL) { s_in->sin_addr.s_addr = htonl(np->n_net); return 1; } @@ -59,14 +63,13 @@ int INET_resolve(const char *name, struct sockaddr_in *s_in, int hostfirst) #endif #ifdef DEBUG - bb_error_msg("gethostbyname (%s)", name); + bb_error_msg("gethostbyname(%s)", name); #endif - if ((hp = gethostbyname(name)) == (struct hostent *) NULL) { + hp = gethostbyname(name); + if (hp == NULL) { return -1; } - memcpy((char *) &s_in->sin_addr, (char *) hp->h_addr_list[0], - sizeof(struct in_addr)); - + memcpy(&s_in->sin_addr, hp->h_addr_list[0], sizeof(struct in_addr)); return 0; } @@ -78,7 +81,7 @@ struct addr { struct addr *next; }; -static struct addr *INET_nn = NULL; /* addr-to-name cache */ +static struct addr *INET_nn = NULL; /* addr-to-name cache */ /* numeric: & 0x8000: default instead of *, * & 0x4000: host instead of net, @@ -90,7 +93,7 @@ int INET_rresolve(char *name, size_t len, struct sockaddr_in *s_in, struct hostent *ent; struct netent *np; struct addr *pn; - unsigned long ad, host_ad; + uint32_t ad, host_ad; int host = 0; /* Grmpf. -FvK */ @@ -102,9 +105,9 @@ int INET_rresolve(char *name, size_t len, struct sockaddr_in *s_in, errno = EAFNOSUPPORT; return -1; } - ad = (unsigned long) s_in->sin_addr.s_addr; + ad = s_in->sin_addr.s_addr; #ifdef DEBUG - bb_error_msg("rresolve: %08lx, mask %08x, num %08x", ad, netmask, numeric); + bb_error_msg("rresolve: %08x, mask %08x, num %08x", (unsigned)ad, netmask, numeric); #endif if (ad == INADDR_ANY) { if ((numeric & 0x0FFF) == 0) { @@ -127,8 +130,8 @@ int INET_rresolve(char *name, size_t len, struct sockaddr_in *s_in, if (pn->addr.sin_addr.s_addr == ad && pn->host == host) { safe_strncpy(name, pn->name, len); #ifdef DEBUG - bb_error_msg("rresolve: found %s %08lx in cache", - (host ? "host" : "net"), ad); + bb_error_msg("rresolve: found %s %08x in cache", + (host ? "host" : "net"), (unsigned)ad); #endif return 0; } @@ -140,7 +143,7 @@ int INET_rresolve(char *name, size_t len, struct sockaddr_in *s_in, ent = NULL; if (host) { #ifdef DEBUG - bb_error_msg("gethostbyaddr (%08lx)", ad); + bb_error_msg("gethostbyaddr (%08x)", (unsigned)ad); #endif ent = gethostbyaddr((char *) &ad, 4, AF_INET); if (ent != NULL) { @@ -148,14 +151,14 @@ int INET_rresolve(char *name, size_t len, struct sockaddr_in *s_in, } } else { #ifdef DEBUG - bb_error_msg("getnetbyaddr (%08lx)", host_ad); + bb_error_msg("getnetbyaddr (%08x)", (unsigned)host_ad); #endif np = getnetbyaddr(host_ad, AF_INET); if (np != NULL) { safe_strncpy(name, np->n_name, len); } } - if ((ent == NULL) && (np == NULL)) { + if (!ent && !np) { safe_strncpy(name, inet_ntoa(s_in->sin_addr), len); } pn = xmalloc(sizeof(struct addr)); @@ -164,7 +167,6 @@ int INET_rresolve(char *name, size_t len, struct sockaddr_in *s_in, pn->host = host; pn->name = xstrdup(name); INET_nn = pn; - return 0; } @@ -183,9 +185,7 @@ int INET6_resolve(const char *name, struct sockaddr_in6 *sin6) return -1; } memcpy(sin6, ai->ai_addr, sizeof(struct sockaddr_in6)); - freeaddrinfo(ai); - return 0; } @@ -224,7 +224,8 @@ int INET6_rresolve(char *name, size_t len, struct sockaddr_in6 *sin6, return 0; } - s = getnameinfo((struct sockaddr *) sin6, sizeof(struct sockaddr_in6), name, len, NULL, 0, 0); + s = getnameinfo((struct sockaddr *) sin6, sizeof(struct sockaddr_in6), + name, len, NULL, 0, 0); if (s) { bb_error_msg("getnameinfo failed"); return -1; diff --git a/libbb/lineedit.c b/libbb/lineedit.c index 2c849eb74..08dab26f0 100644 --- a/libbb/lineedit.c +++ b/libbb/lineedit.c @@ -1254,8 +1254,6 @@ static void win_changed(int nsig) int read_line_input(const char* prompt, char* command, int maxsize, line_input_t *st) { - static const int null_flags; - int lastWasTab = FALSE; unsigned int ic; unsigned char c; @@ -1270,7 +1268,7 @@ int read_line_input(const char* prompt, char* command, int maxsize, line_input_t maxsize = BUFSIZ; /* With null flags, no other fields are ever used */ - state = st ? st : (line_input_t*) &null_flags; + state = st ? st : (line_input_t*) &const_int_0; if (state->flags & SAVE_HISTORY) load_history(state->hist_file); diff --git a/libbb/messages.c b/libbb/messages.c index 6c3d2f608..105e4ce66 100644 --- a/libbb/messages.c +++ b/libbb/messages.c @@ -40,6 +40,9 @@ const char bb_path_motd_file[] = "/etc/motd"; const char bb_default_login_shell[] = LIBBB_DEFAULT_LOGIN_SHELL; const char bb_dev_null[] = "/dev/null"; +const int const_int_0; +const int const_int_1 = 1; + #include /* This is usually something like "/var/adm/wtmp" or "/var/log/wtmp" */ const char bb_path_wtmp_file[] = diff --git a/libbb/xconnect.c b/libbb/xconnect.c index 62cab95a1..0addda157 100644 --- a/libbb/xconnect.c +++ b/libbb/xconnect.c @@ -9,14 +9,13 @@ #include #include "libbb.h" -static const int one = 1; int setsockopt_reuseaddr(int fd) { - return setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &one, sizeof(one)); + return setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &const_int_1, sizeof(const_int_1)); } int setsockopt_broadcast(int fd) { - return setsockopt(fd, SOL_SOCKET, SO_BROADCAST, &one, sizeof(one)); + return setsockopt(fd, SOL_SOCKET, SO_BROADCAST, &const_int_1, sizeof(const_int_1)); } void xconnect(int s, const struct sockaddr *s_addr, socklen_t addrlen) diff --git a/modutils/insmod.c b/modutils/insmod.c index a9bf1854c..1ad3c23a4 100644 --- a/modutils/insmod.c +++ b/modutils/insmod.c @@ -337,7 +337,6 @@ extern int insmod_ng_main( int argc, char **argv); #ifndef MODUTILS_MODULE_H -/* Why? static const int MODUTILS_MODULE_H = 1;*/ /*======================================================================*/ /* For sizeof() which are related to the module platform and not to the @@ -494,7 +493,6 @@ int delete_module(const char *); #ifndef MODUTILS_OBJ_H -/* Why? static const int MODUTILS_OBJ_H = 1; */ /* The relocatable object is manipulated using elfin types. */ diff --git a/networking/arping.c b/networking/arping.c index 58d5b3bd6..55b27872b 100644 --- a/networking/arping.c +++ b/networking/arping.c @@ -335,13 +335,12 @@ int arping_main(int argc, char **argv) saddr.sin_addr = src; xbind(probe_fd, (struct sockaddr *) &saddr, sizeof(saddr)); } else if (!(cfg & dad)) { - static const int on = 1; socklen_t alen = sizeof(saddr); saddr.sin_port = htons(1025); saddr.sin_addr = dst; - if (setsockopt(probe_fd, SOL_SOCKET, SO_DONTROUTE, (char *) &on, sizeof(on)) == -1) + if (setsockopt(probe_fd, SOL_SOCKET, SO_DONTROUTE, &const_int_1, sizeof(const_int_1)) == -1) bb_perror_msg("warning: setsockopt(SO_DONTROUTE)"); xconnect(probe_fd, (struct sockaddr *) &saddr, sizeof(saddr)); if (getsockname(probe_fd, (struct sockaddr *) &saddr, &alen) == -1) { diff --git a/networking/httpd.c b/networking/httpd.c index d14b113a3..ea9fe0974 100644 --- a/networking/httpd.c +++ b/networking/httpd.c @@ -1764,8 +1764,6 @@ static void handleIncoming(void) ****************************************************************************/ static int miniHttpd(int server) { - static const int on = 1; - fd_set readfd, portfd; FD_ZERO(&portfd); @@ -1812,7 +1810,7 @@ static int miniHttpd(int server) #endif /* set the KEEPALIVE option to cull dead connections */ - setsockopt(s, SOL_SOCKET, SO_KEEPALIVE, (void *)&on, sizeof(on)); + setsockopt(s, SOL_SOCKET, SO_KEEPALIVE, &const_int_1, sizeof(const_int_1)); if (DEBUG || fork() == 0) { /* child */ diff --git a/networking/nc.c b/networking/nc.c index 09d89b0a8..dc9102b2a 100644 --- a/networking/nc.c +++ b/networking/nc.c @@ -43,10 +43,10 @@ int nc_main(int argc, char **argv) else if (ENABLE_NC_SERVER && opt=='p') { USE_NC_SERVER(lport = bb_lookup_port(optarg, "tcp", 0)); } - else if (ENABLE_NC_EXTRA && opt=='w') USE_NC_EXTRA( wsecs = xatou(optarg)); - else if (ENABLE_NC_EXTRA && opt=='i') USE_NC_EXTRA( delay = xatou(optarg)); - else if (ENABLE_NC_EXTRA && opt=='f') USE_NC_EXTRA( cfd = xopen(optarg, O_RDWR)); - else if (ENABLE_NC_EXTRA && opt=='e' && optind<=argc) { + else if (ENABLE_NC_EXTRA && opt=='w') USE_NC_EXTRA( wsecs = xatou(optarg)); + else if (ENABLE_NC_EXTRA && opt=='i') USE_NC_EXTRA( delay = xatou(optarg)); + else if (ENABLE_NC_EXTRA && opt=='f') USE_NC_EXTRA( cfd = xopen(optarg, O_RDWR)); + else if (ENABLE_NC_EXTRA && opt=='e' && optind<=argc) { /* We cannot just 'break'. We should let getopt finish. ** Or else we won't be able to find where ** 'host' and 'port' params are @@ -91,8 +91,6 @@ int nc_main(int argc, char **argv) if (!cfd) { if (do_listen) { - socklen_t addrlen; - /* create_and_bind_stream_or_die(NULL, lport) * would've work wonderfully, but we need * to know lsa */ @@ -105,15 +103,14 @@ int nc_main(int argc, char **argv) /* If we didn't specify a port number, * query and print it after listen() */ if (!lport) { - addrlen = lsa->len; + socklen_t addrlen = lsa->len; getsockname(sfd, &lsa->sa, &addrlen); lport = get_nport(lsa); fdprintf(2, "%d\n", ntohs(lport)); } fcntl(sfd, F_SETFD, FD_CLOEXEC); accept_again: - addrlen = lsa->len; - cfd = accept(sfd, NULL, 0); /* &lsa->sa, &addrlen); */ + cfd = accept(sfd, NULL, 0); if (cfd < 0) bb_perror_msg_and_die("accept"); if (!execparam) diff --git a/networking/netstat.c b/networking/netstat.c index 3dad57a40..16ee52d9a 100644 --- a/networking/netstat.c +++ b/networking/netstat.c @@ -14,81 +14,70 @@ #include "busybox.h" #include "inet_common.h" -#ifdef CONFIG_ROUTE -extern void displayroutes(int noresolve, int netstatfmt); -#endif - -#define NETSTAT_CONNECTED 0x01 -#define NETSTAT_LISTENING 0x02 -#define NETSTAT_NUMERIC 0x04 +#define NETSTAT_CONNECTED 0x01 +#define NETSTAT_LISTENING 0x02 +#define NETSTAT_NUMERIC 0x04 /* Must match getopt32 option string */ -#define NETSTAT_TCP 0x10 -#define NETSTAT_UDP 0x20 -#define NETSTAT_RAW 0x40 -#define NETSTAT_UNIX 0x80 -#define NETSTAT_ALLPROTO (NETSTAT_TCP|NETSTAT_UDP|NETSTAT_RAW|NETSTAT_UNIX) +#define NETSTAT_TCP 0x10 +#define NETSTAT_UDP 0x20 +#define NETSTAT_RAW 0x40 +#define NETSTAT_UNIX 0x80 +#define NETSTAT_ALLPROTO (NETSTAT_TCP|NETSTAT_UDP|NETSTAT_RAW|NETSTAT_UNIX) static int flags = NETSTAT_CONNECTED | NETSTAT_ALLPROTO; -#define PROGNAME_WIDTHs PROGNAME_WIDTH1(PROGNAME_WIDTH) -#define PROGNAME_WIDTH1(s) PROGNAME_WIDTH2(s) -#define PROGNAME_WIDTH2(s) #s - -#define PRG_HASH_SIZE 211 - enum { - TCP_ESTABLISHED = 1, - TCP_SYN_SENT, - TCP_SYN_RECV, - TCP_FIN_WAIT1, - TCP_FIN_WAIT2, - TCP_TIME_WAIT, - TCP_CLOSE, - TCP_CLOSE_WAIT, - TCP_LAST_ACK, - TCP_LISTEN, - TCP_CLOSING /* now a valid state */ + TCP_ESTABLISHED = 1, + TCP_SYN_SENT, + TCP_SYN_RECV, + TCP_FIN_WAIT1, + TCP_FIN_WAIT2, + TCP_TIME_WAIT, + TCP_CLOSE, + TCP_CLOSE_WAIT, + TCP_LAST_ACK, + TCP_LISTEN, + TCP_CLOSING /* now a valid state */ }; static const char * const tcp_state[] = { - "", - "ESTABLISHED", - "SYN_SENT", - "SYN_RECV", - "FIN_WAIT1", - "FIN_WAIT2", - "TIME_WAIT", - "CLOSE", - "CLOSE_WAIT", - "LAST_ACK", - "LISTEN", - "CLOSING" + "", + "ESTABLISHED", + "SYN_SENT", + "SYN_RECV", + "FIN_WAIT1", + "FIN_WAIT2", + "TIME_WAIT", + "CLOSE", + "CLOSE_WAIT", + "LAST_ACK", + "LISTEN", + "CLOSING" }; typedef enum { - SS_FREE = 0, /* not allocated */ - SS_UNCONNECTED, /* unconnected to any socket */ - SS_CONNECTING, /* in process of connecting */ - SS_CONNECTED, /* connected to socket */ - SS_DISCONNECTING /* in process of disconnecting */ + SS_FREE = 0, /* not allocated */ + SS_UNCONNECTED, /* unconnected to any socket */ + SS_CONNECTING, /* in process of connecting */ + SS_CONNECTED, /* connected to socket */ + SS_DISCONNECTING /* in process of disconnecting */ } socket_state; -#define SO_ACCEPTCON (1<<16) /* performed a listen */ -#define SO_WAITDATA (1<<17) /* wait data to read */ -#define SO_NOSPACE (1<<18) /* no space to write */ +#define SO_ACCEPTCON (1<<16) /* performed a listen */ +#define SO_WAITDATA (1<<17) /* wait data to read */ +#define SO_NOSPACE (1<<18) /* no space to write */ static char *get_sname(int port, const char *proto, int num) { - char *str=itoa(ntohs(port)); - if (num) { - } else { - struct servent *se=getservbyport(port,proto); + char *str = itoa(ntohs(port)); + if (!num) { + struct servent *se = getservbyport(port, proto); if (se) - str=se->s_name; + str = se->s_name; } if (!port) { - str="*"; + str = "*"; } return str; } @@ -97,21 +86,21 @@ static void snprint_ip_port(char *ip_port, int size, struct sockaddr *addr, int { char *port_name; -#ifdef CONFIG_FEATURE_IPV6 +#if ENABLE_FEATURE_IPV6 if (addr->sa_family == AF_INET6) { INET6_rresolve(ip_port, size, (struct sockaddr_in6 *)addr, - (numeric&NETSTAT_NUMERIC) ? 0x0fff : 0); + (numeric & NETSTAT_NUMERIC) ? 0x0fff : 0); } else #endif { - INET_rresolve(ip_port, size, (struct sockaddr_in *)addr, - 0x4000 | ((numeric&NETSTAT_NUMERIC) ? 0x0fff : 0), - 0xffffffff); + INET_rresolve(ip_port, size, (struct sockaddr_in *)addr, + 0x4000 | ((numeric & NETSTAT_NUMERIC) ? 0x0fff : 0), + 0xffffffff); } - port_name=get_sname(htons(port), proto, numeric); + port_name = get_sname(htons(port), proto, numeric); if ((strlen(ip_port) + strlen(port_name)) > 22) ip_port[22 - strlen(port_name)] = '\0'; - ip_port+=strlen(ip_port); + ip_port += strlen(ip_port); strcat(ip_port, ":"); strcat(ip_port, port_name); } @@ -122,7 +111,7 @@ static void tcp_do_one(int lnr, const char *line) const char *state_str; char more[512]; int num, local_port, rem_port, d, state, timer_run, uid, timeout; -#ifdef CONFIG_FEATURE_IPV6 +#if ENABLE_FEATURE_IPV6 struct sockaddr_in6 localaddr, remaddr; char addr6[INET6_ADDRSTRLEN]; struct in6_addr in6; @@ -142,7 +131,7 @@ static void tcp_do_one(int lnr, const char *line) &txq, &rxq, &timer_run, &time_len, &retr, &uid, &timeout, &inode, more); if (strlen(local_addr) > 8) { -#ifdef CONFIG_FEATURE_IPV6 +#if ENABLE_FEATURE_IPV6 sscanf(local_addr, "%08X%08X%08X%08X", &in6.s6_addr32[0], &in6.s6_addr32[1], &in6.s6_addr32[2], &in6.s6_addr32[3]); @@ -170,20 +159,19 @@ static void tcp_do_one(int lnr, const char *line) return; } state_str = tcp_state[state]; - if ((rem_port && (flags&NETSTAT_CONNECTED)) || - (!rem_port && (flags&NETSTAT_LISTENING))) - { + if ((rem_port && (flags & NETSTAT_CONNECTED)) + || (!rem_port && (flags & NETSTAT_LISTENING)) + ) { snprint_ip_port(local_addr, sizeof(local_addr), (struct sockaddr *) &localaddr, local_port, - "tcp", flags&NETSTAT_NUMERIC); + "tcp", flags & NETSTAT_NUMERIC); snprint_ip_port(rem_addr, sizeof(rem_addr), (struct sockaddr *) &remaddr, rem_port, - "tcp", flags&NETSTAT_NUMERIC); + "tcp", flags & NETSTAT_NUMERIC); printf("tcp %6ld %6ld %-23s %-23s %-12s\n", rxq, txq, local_addr, rem_addr, state_str); - } } @@ -192,7 +180,7 @@ static void udp_do_one(int lnr, const char *line) char local_addr[64], rem_addr[64]; char *state_str, more[512]; int num, local_port, rem_port, d, state, timer_run, uid, timeout; -#ifdef CONFIG_FEATURE_IPV6 +#if ENABLE_FEATURE_IPV6 struct sockaddr_in6 localaddr, remaddr; char addr6[INET6_ADDRSTRLEN]; struct in6_addr in6; @@ -212,7 +200,7 @@ static void udp_do_one(int lnr, const char *line) &txq, &rxq, &timer_run, &time_len, &retr, &uid, &timeout, &inode, more); if (strlen(local_addr) > 8) { -#ifdef CONFIG_FEATURE_IPV6 +#if ENABLE_FEATURE_IPV6 /* Demangle what the kernel gives us */ sscanf(local_addr, "%08X%08X%08X%08X", &in6.s6_addr32[0], &in6.s6_addr32[1], @@ -254,7 +242,7 @@ static void udp_do_one(int lnr, const char *line) break; } -#ifdef CONFIG_FEATURE_IPV6 +#if ENABLE_FEATURE_IPV6 # define notnull(A) (((A.sin6_family == AF_INET6) && \ ((A.sin6_addr.s6_addr32[0]) || \ (A.sin6_addr.s6_addr32[1]) || \ @@ -265,20 +253,19 @@ static void udp_do_one(int lnr, const char *line) #else # define notnull(A) (A.sin_addr.s_addr) #endif - if ((notnull(remaddr) && (flags&NETSTAT_CONNECTED)) || - (!notnull(remaddr) && (flags&NETSTAT_LISTENING))) - { + if ((notnull(remaddr) && (flags & NETSTAT_CONNECTED)) + || (!notnull(remaddr) && (flags & NETSTAT_LISTENING)) + ) { snprint_ip_port(local_addr, sizeof(local_addr), (struct sockaddr *) &localaddr, local_port, - "udp", flags&NETSTAT_NUMERIC); + "udp", flags & NETSTAT_NUMERIC); snprint_ip_port(rem_addr, sizeof(rem_addr), (struct sockaddr *) &remaddr, rem_port, - "udp", flags&NETSTAT_NUMERIC); + "udp", flags & NETSTAT_NUMERIC); printf("udp %6ld %6ld %-23s %-23s %-12s\n", rxq, txq, local_addr, rem_addr, state_str); - } } @@ -287,7 +274,7 @@ static void raw_do_one(int lnr, const char *line) char local_addr[64], rem_addr[64]; char *state_str, more[512]; int num, local_port, rem_port, d, state, timer_run, uid, timeout; -#ifdef CONFIG_FEATURE_IPV6 +#if ENABLE_FEATURE_IPV6 struct sockaddr_in6 localaddr, remaddr; char addr6[INET6_ADDRSTRLEN]; struct in6_addr in6; @@ -307,7 +294,7 @@ static void raw_do_one(int lnr, const char *line) &txq, &rxq, &timer_run, &time_len, &retr, &uid, &timeout, &inode, more); if (strlen(local_addr) > 8) { -#ifdef CONFIG_FEATURE_IPV6 +#if ENABLE_FEATURE_IPV6 sscanf(local_addr, "%08X%08X%08X%08X", &in6.s6_addr32[0], &in6.s6_addr32[1], &in6.s6_addr32[2], &in6.s6_addr32[3]); @@ -334,9 +321,9 @@ static void raw_do_one(int lnr, const char *line) bb_error_msg("warning, got bogus raw line"); return; } - state_str=itoa(state); + state_str = itoa(state); -#ifdef CONFIG_FEATURE_IPV6 +#if ENABLE_FEATURE_IPV6 # define notnull(A) (((A.sin6_family == AF_INET6) && \ ((A.sin6_addr.s6_addr32[0]) || \ (A.sin6_addr.s6_addr32[1]) || \ @@ -347,20 +334,19 @@ static void raw_do_one(int lnr, const char *line) #else # define notnull(A) (A.sin_addr.s_addr) #endif - if ((notnull(remaddr) && (flags&NETSTAT_CONNECTED)) || - (!notnull(remaddr) && (flags&NETSTAT_LISTENING))) - { + if ((notnull(remaddr) && (flags & NETSTAT_CONNECTED)) + || (!notnull(remaddr) && (flags & NETSTAT_LISTENING)) + ) { snprint_ip_port(local_addr, sizeof(local_addr), (struct sockaddr *) &localaddr, local_port, - "raw", flags&NETSTAT_NUMERIC); + "raw", flags & NETSTAT_NUMERIC); snprint_ip_port(rem_addr, sizeof(rem_addr), (struct sockaddr *) &remaddr, rem_port, - "raw", flags&NETSTAT_NUMERIC); + "raw", flags & NETSTAT_NUMERIC); printf("raw %6ld %6ld %-23s %-23s %-12s\n", rxq, txq, local_addr, rem_addr, state_str); - } } @@ -390,12 +376,12 @@ static void unix_do_one(int nr, const char *line) if (!(has & HAS_INODE)) snprintf(path,sizeof(path),"%d",inode); - if ((flags&(NETSTAT_LISTENING|NETSTAT_CONNECTED))!=(NETSTAT_LISTENING|NETSTAT_CONNECTED)) { + if ((flags & (NETSTAT_LISTENING|NETSTAT_CONNECTED)) != (NETSTAT_LISTENING|NETSTAT_CONNECTED)) { if ((state == SS_UNCONNECTED) && (unix_flags & SO_ACCEPTCON)) { - if (!(flags&NETSTAT_LISTENING)) + if (!(flags & NETSTAT_LISTENING)) return; } else { - if (!(flags&NETSTAT_CONNECTED)) + if (!(flags & NETSTAT_CONNECTED)) return; } } @@ -502,20 +488,20 @@ static void do_info(const char *file, const char *name, void (*proc)(int, const procinfo = fopen(file, "r"); if (procinfo == NULL) { if (errno != ENOENT) { - perror(file); + bb_perror_msg("%s", file); } else { bb_error_msg("no support for '%s' on this system", name); } - } else { - do { - char *buffer = xmalloc_fgets(procinfo); - if (buffer) { - (proc)(lnr++, buffer); - free(buffer); - } - } while (!feof(procinfo)); - fclose(procinfo); + return; } + do { + char *buffer = xmalloc_fgets(procinfo); + if (buffer) { + (proc)(lnr++, buffer); + free(buffer); + } + } while (!feof(procinfo)); + fclose(procinfo); } /* @@ -529,12 +515,11 @@ int netstat_main(int argc, char **argv) OPT_showroute = 0x100, }; unsigned opt; -#ifdef CONFIG_FEATURE_IPV6 +#if ENABLE_FEATURE_IPV6 int inet = 1; int inet6 = 1; #else -# define inet 1 -# define inet6 0 + enum { inet = 1, inet6 = 0 }; #endif /* Option string must match NETSTAT_xxx constants */ @@ -551,8 +536,8 @@ int netstat_main(int argc, char **argv) //if (opt & 0x40) // -w: NETSTAT_RAW //if (opt & 0x80) // -x: NETSTAT_UNIX if (opt & OPT_showroute) { // -r -#ifdef CONFIG_ROUTE - displayroutes(flags & NETSTAT_NUMERIC, !(opt & OPT_extended)); +#if ENABLE_ROUTE + bb_displayroutes(flags & NETSTAT_NUMERIC, !(opt & OPT_extended)); return 0; #else bb_error_msg_and_die("-r (display routing table) is not compiled in"); @@ -567,47 +552,42 @@ int netstat_main(int argc, char **argv) if (flags & (NETSTAT_TCP|NETSTAT_UDP|NETSTAT_RAW)) { printf("Active Internet connections "); /* xxx */ - if ((flags&(NETSTAT_LISTENING|NETSTAT_CONNECTED))==(NETSTAT_LISTENING|NETSTAT_CONNECTED)) + if ((flags & (NETSTAT_LISTENING|NETSTAT_CONNECTED)) == (NETSTAT_LISTENING|NETSTAT_CONNECTED)) printf("(servers and established)"); - else { - if (flags & NETSTAT_LISTENING) - printf("(only servers)"); - else - printf("(w/o servers)"); - } + else if (flags & NETSTAT_LISTENING) + printf("(only servers)"); + else + printf("(w/o servers)"); printf("\nProto Recv-Q Send-Q Local Address Foreign Address State\n"); } - if (inet && flags&NETSTAT_TCP) - do_info(_PATH_PROCNET_TCP,"AF INET (tcp)",tcp_do_one); -#ifdef CONFIG_FEATURE_IPV6 - if (inet6 && flags&NETSTAT_TCP) - do_info(_PATH_PROCNET_TCP6,"AF INET6 (tcp)",tcp_do_one); + if (inet && flags & NETSTAT_TCP) + do_info(_PATH_PROCNET_TCP, "AF INET (tcp)", tcp_do_one); +#if ENABLE_FEATURE_IPV6 + if (inet6 && flags & NETSTAT_TCP) + do_info(_PATH_PROCNET_TCP6, "AF INET6 (tcp)", tcp_do_one); #endif - if (inet && flags&NETSTAT_UDP) - do_info(_PATH_PROCNET_UDP,"AF INET (udp)",udp_do_one); -#ifdef CONFIG_FEATURE_IPV6 - if (inet6 && flags&NETSTAT_UDP) - do_info(_PATH_PROCNET_UDP6,"AF INET6 (udp)",udp_do_one); + if (inet && flags & NETSTAT_UDP) + do_info(_PATH_PROCNET_UDP, "AF INET (udp)", udp_do_one); +#if ENABLE_FEATURE_IPV6 + if (inet6 && flags & NETSTAT_UDP) + do_info(_PATH_PROCNET_UDP6, "AF INET6 (udp)", udp_do_one); #endif - if (inet && flags&NETSTAT_RAW) - do_info(_PATH_PROCNET_RAW,"AF INET (raw)",raw_do_one); -#ifdef CONFIG_FEATURE_IPV6 - if (inet6 && flags&NETSTAT_RAW) - do_info(_PATH_PROCNET_RAW6,"AF INET6 (raw)",raw_do_one); + if (inet && flags & NETSTAT_RAW) + do_info(_PATH_PROCNET_RAW, "AF INET (raw)", raw_do_one); +#if ENABLE_FEATURE_IPV6 + if (inet6 && flags & NETSTAT_RAW) + do_info(_PATH_PROCNET_RAW6, "AF INET6 (raw)", raw_do_one); #endif - if (flags&NETSTAT_UNIX) { + if (flags & NETSTAT_UNIX) { printf("Active UNIX domain sockets "); - if ((flags&(NETSTAT_LISTENING|NETSTAT_CONNECTED))==(NETSTAT_LISTENING|NETSTAT_CONNECTED)) + if ((flags & (NETSTAT_LISTENING|NETSTAT_CONNECTED)) == (NETSTAT_LISTENING|NETSTAT_CONNECTED)) printf("(servers and established)"); - else { - if (flags&NETSTAT_LISTENING) - printf("(only servers)"); - else - printf("(w/o servers)"); - } - + else if (flags & NETSTAT_LISTENING) + printf("(only servers)"); + else + printf("(w/o servers)"); printf("\nProto RefCnt Flags Type State I-Node Path\n"); - do_info(_PATH_PROCNET_UNIX,"AF UNIX",unix_do_one); + do_info(_PATH_PROCNET_UNIX, "AF UNIX", unix_do_one); } return 0; } diff --git a/networking/ping.c b/networking/ping.c index d8a70334d..91708d282 100644 --- a/networking/ping.c +++ b/networking/ping.c @@ -343,8 +343,7 @@ static void ping(const char *host) /* set recv buf for broadcast pings */ sockopt = 48 * 1024; /* explain why 48k? */ - setsockopt(pingsock, SOL_SOCKET, SO_RCVBUF, (char *) &sockopt, - sizeof(sockopt)); + setsockopt(pingsock, SOL_SOCKET, SO_RCVBUF, &sockopt, sizeof(sockopt)); printf("PING %s (%s)", hostent->h_name, diff --git a/networking/ping6.c b/networking/ping6.c index dec3b426a..a92387e79 100644 --- a/networking/ping6.c +++ b/networking/ping6.c @@ -77,8 +77,7 @@ static void ping(const char *host) pkt->icmp6_type = ICMP6_ECHO_REQUEST; sockopt = offsetof(struct icmp6_hdr, icmp6_cksum); - setsockopt(pingsock, SOL_RAW, IPV6_CHECKSUM, (char *) &sockopt, - sizeof(sockopt)); + setsockopt(pingsock, SOL_RAW, IPV6_CHECKSUM, &sockopt, sizeof(sockopt)); c = sendto(pingsock, packet, DEFDATALEN + sizeof (struct icmp6_hdr), 0, (struct sockaddr *) &pingaddr, sizeof(struct sockaddr_in6)); @@ -312,6 +311,7 @@ static void unpack(char *packet, int sz, struct sockaddr_in6 *from, int hoplimit fflush(stdout); } +extern int BUG_bad_offsetof_icmp6_cksum(void); static void ping(const char *host) { char packet[datalen + MAXIPLEN + MAXICMPLEN]; @@ -353,18 +353,15 @@ static void ping(const char *host) /* set recv buf for broadcast pings */ sockopt = 48 * 1024; /* explain why 48k? */ - setsockopt(pingsock, SOL_SOCKET, SO_RCVBUF, (char *) &sockopt, - sizeof(sockopt)); + setsockopt(pingsock, SOL_SOCKET, SO_RCVBUF, &sockopt, sizeof(sockopt)); - sockopt = 2; /* iputils-ss020927 does this */ sockopt = offsetof(struct icmp6_hdr, icmp6_cksum); - setsockopt(pingsock, SOL_RAW, IPV6_CHECKSUM, (char *) &sockopt, - sizeof(sockopt)); + if (offsetof(struct icmp6_hdr, icmp6_cksum) != 2) + BUG_bad_offsetof_icmp6_cksum(); + setsockopt(pingsock, SOL_RAW, IPV6_CHECKSUM, &sockopt, sizeof(sockopt)); /* request ttl info to be returned in ancillary data */ - sockopt = 1; - setsockopt(pingsock, SOL_IPV6, IPV6_HOPLIMIT, (char *) &sockopt, - sizeof(sockopt)); + setsockopt(pingsock, SOL_IPV6, IPV6_HOPLIMIT, &const_int_1, sizeof(const_int_1)); if (if_index) pingaddr.sin6_scope_id = if_index; diff --git a/networking/route.c b/networking/route.c index d6d9b7dd9..c6fb5a371 100644 --- a/networking/route.c +++ b/networking/route.c @@ -63,14 +63,14 @@ #endif /* The RTACTION entries must agree with tbl_verb[] below! */ -#define RTACTION_ADD 1 -#define RTACTION_DEL 2 +#define RTACTION_ADD 1 +#define RTACTION_DEL 2 /* For the various tbl_*[] arrays, the 1st byte is the offset to * the next entry and the 2nd byte is return value. */ -#define NET_FLAG 1 -#define HOST_FLAG 2 +#define NET_FLAG 1 +#define HOST_FLAG 2 /* We remap '-' to '#' to avoid problems with getopt. */ static const char tbl_hash_net_host[] = @@ -79,22 +79,22 @@ static const char tbl_hash_net_host[] = "\007\002#host" /* Since last, we can save a byte. */ ; -#define KW_TAKES_ARG 020 -#define KW_SETS_FLAG 040 +#define KW_TAKES_ARG 020 +#define KW_SETS_FLAG 040 -#define KW_IPVx_METRIC 020 -#define KW_IPVx_NETMASK 021 -#define KW_IPVx_GATEWAY 022 -#define KW_IPVx_MSS 023 -#define KW_IPVx_WINDOW 024 -#define KW_IPVx_IRTT 025 -#define KW_IPVx_DEVICE 026 +#define KW_IPVx_METRIC 020 +#define KW_IPVx_NETMASK 021 +#define KW_IPVx_GATEWAY 022 +#define KW_IPVx_MSS 023 +#define KW_IPVx_WINDOW 024 +#define KW_IPVx_IRTT 025 +#define KW_IPVx_DEVICE 026 -#define KW_IPVx_FLAG_ONLY 040 -#define KW_IPVx_REJECT 040 -#define KW_IPVx_MOD 041 -#define KW_IPVx_DYN 042 -#define KW_IPVx_REINSTATE 043 +#define KW_IPVx_FLAG_ONLY 040 +#define KW_IPVx_REJECT 040 +#define KW_IPVx_MOD 041 +#define KW_IPVx_DYN 042 +#define KW_IPVx_REINSTATE 043 static const char tbl_ipvx[] = /* 020 is the "takes an arg" bit */ @@ -167,7 +167,7 @@ static void INET_setroute(int action, char **args) } /* Clean out the RTREQ structure. */ - memset((char *) &rt, 0, sizeof(struct rtentry)); + memset(&rt, 0, sizeof(rt)); { const char *target = *args++; @@ -334,7 +334,7 @@ static void INET_setroute(int action, char **args) if (ENABLE_FEATURE_CLEAN_UP) close(skfd); } -#ifdef CONFIG_FEATURE_IPV6 +#if ENABLE_FEATURE_IPV6 static void INET6_setroute(int action, char **args) { @@ -363,7 +363,7 @@ static void INET6_setroute(int action, char **args) } /* Clean out the RTREQ structure. */ - memset((char *) &rt, 0, sizeof(struct in6_rtmsg)); + memset(&rt, 0, sizeof(rt)); memcpy(&rt.rtmsg_dst, sa6.sin6_addr.s6_addr, sizeof(struct in6_addr)); @@ -445,7 +445,7 @@ static const unsigned int flagvals[] = { /* Must agree with flagchars[]. */ RTF_REINSTATE, RTF_DYNAMIC, RTF_MODIFIED, -#ifdef CONFIG_FEATURE_IPV6 +#if ENABLE_FEATURE_IPV6 RTF_DEFAULT, RTF_ADDRCONF, RTF_CACHE @@ -457,7 +457,7 @@ static const unsigned int flagvals[] = { /* Must agree with flagchars[]. */ static const char flagchars[] = /* Must agree with flagvals[]. */ "GHRDM" -#ifdef CONFIG_FEATURE_IPV6 +#if ENABLE_FEATURE_IPV6 "DAC" #endif ; @@ -476,7 +476,7 @@ static void set_flags(char *flagstr, int flags) } /* also used in netstat */ -void displayroutes(int noresolve, int netstatfmt) +void bb_displayroutes(int noresolve, int netstatfmt) { char devname[64], flags[16], sdest[16], sgw[16]; unsigned long int d, g, m; @@ -537,7 +537,7 @@ void displayroutes(int noresolve, int netstatfmt) } } -#ifdef CONFIG_FEATURE_IPV6 +#if ENABLE_FEATURE_IPV6 static void INET6_displayroutes(int noresolve) { @@ -589,7 +589,7 @@ static void INET6_displayroutes(int noresolve) goto ERROR; } addr6x[i++] = *p++; - if (!((i+1)%5)) { + if (!((i+1) % 5)) { addr6x[i++] = ':'; } } while (i < 40+28+7); @@ -626,10 +626,10 @@ static void INET6_displayroutes(int noresolve) #endif -#define ROUTE_OPT_A 0x01 -#define ROUTE_OPT_n 0x02 -#define ROUTE_OPT_e 0x04 -#define ROUTE_OPT_INET6 0x08 /* Not an actual option. See below. */ +#define ROUTE_OPT_A 0x01 +#define ROUTE_OPT_n 0x02 +#define ROUTE_OPT_e 0x04 +#define ROUTE_OPT_INET6 0x08 /* Not an actual option. See below. */ /* 1st byte is offset to next entry offset. 2nd byte is return value. */ static const char tbl_verb[] = /* 2nd byte matches RTACTION_* code */ @@ -649,15 +649,15 @@ int route_main(int argc, char **argv) /* First, remap '-net' and '-host' to avoid getopt problems. */ p = argv; while (*++p) { - if ((strcmp(*p, "-net") == 0) || (strcmp(*p, "-host") == 0)) { + if (strcmp(*p, "-net") == 0 || strcmp(*p, "-host") == 0) { p[0][0] = '#'; } } opt = getopt32(argc, argv, "A:ne", &family); - if ((opt & ROUTE_OPT_A) && strcmp(family, "inet")) { -#ifdef CONFIG_FEATURE_IPV6 + if ((opt & ROUTE_OPT_A) && strcmp(family, "inet") != 0) { +#if ENABLE_FEATURE_IPV6 if (strcmp(family, "inet6") == 0) { opt |= ROUTE_OPT_INET6; /* Set flag for ipv6. */ } else @@ -670,12 +670,12 @@ int route_main(int argc, char **argv) /* No more args means display the routing table. */ if (!*argv) { int noresolve = (opt & ROUTE_OPT_n) ? 0x0fff : 0; -#ifdef CONFIG_FEATURE_IPV6 +#if ENABLE_FEATURE_IPV6 if (opt & ROUTE_OPT_INET6) INET6_displayroutes(noresolve); else #endif - displayroutes(noresolve, opt & ROUTE_OPT_e); + bb_displayroutes(noresolve, opt & ROUTE_OPT_e); fflush_stdout_and_exit(EXIT_SUCCESS); } @@ -686,7 +686,7 @@ int route_main(int argc, char **argv) bb_show_usage(); } -#ifdef CONFIG_FEATURE_IPV6 +#if ENABLE_FEATURE_IPV6 if (opt & ROUTE_OPT_INET6) INET6_setroute(what, argv); else diff --git a/networking/telnet.c b/networking/telnet.c index 86586600b..fc70cc406 100644 --- a/networking/telnet.c +++ b/networking/telnet.c @@ -95,8 +95,6 @@ static void telopt(byte c); static int subneg(byte c); /* Some globals */ -static const int one = 1; - #ifdef CONFIG_FEATURE_TELNET_TTYPE static char *ttype; #endif @@ -630,7 +628,7 @@ int telnet_main(int argc, char** argv) G.netfd = create_and_connect_stream_or_die(host, port); - setsockopt(G.netfd, SOL_SOCKET, SO_KEEPALIVE, &one, sizeof one); + setsockopt(G.netfd, SOL_SOCKET, SO_KEEPALIVE, &const_int_1, sizeof(const_int_1)); signal(SIGINT, fgotsig); diff --git a/networking/traceroute.c b/networking/traceroute.c index 5eac6cd1e..47775aa8a 100644 --- a/networking/traceroute.c +++ b/networking/traceroute.c @@ -207,7 +207,6 @@ //#undef CONFIG_FEATURE_TRACEROUTE_USE_ICMP //#define CONFIG_FEATURE_TRACEROUTE_USE_ICMP -#include "inet_common.h" #include #include @@ -217,6 +216,7 @@ #include #include "busybox.h" +#include "inet_common.h" /* @@ -803,7 +803,8 @@ inetname(struct sockaddr_in *from) char name[257]; if (!nflag && from->sin_addr.s_addr != INADDR_ANY) { - if (INET_rresolve(name, sizeof(name), from, 0x4000, 0xffffffff) >= 0) + if (INET_rresolve(name, sizeof(name), from, 0x4000, + 0xffffffff) >= 0) n = name; } ina = inet_ntoa(from->sin_addr); @@ -842,7 +843,7 @@ gethostinfo(const char *host) hi = xzalloc(sizeof(*hi)); addr = inet_addr(host); - if ((int32_t)addr != -1) { + if (addr != 0xffffffff) { hi->name = xstrdup(host); hi->n = 1; hi->addrs = xzalloc(sizeof(hi->addrs[0])); @@ -888,8 +889,6 @@ getaddr(uint32_t *ap, const char *host) int traceroute_main(int argc, char *argv[]) { - static const int on = 1; - int code, n; unsigned char *outp; uint32_t *ap; @@ -1043,19 +1042,19 @@ traceroute_main(int argc, char *argv[]) /* Insure the socket fds won't be 0, 1 or 2 */ do n = xopen(bb_dev_null, O_RDONLY); while (n < 2); - if (n > 2) - close(n); + while (n > 2) + close(n--); s = xsocket(AF_INET, SOCK_RAW, IPPROTO_ICMP); #if TRACEROUTE_SO_DEBUG if (op & USAGE_OP_DEBUG) - (void)setsockopt(s, SOL_SOCKET, SO_DEBUG, (char *)&on, - sizeof(on)); + setsockopt(s, SOL_SOCKET, SO_DEBUG, + &const_int_1, sizeof(const_int_1)); #endif if (op & USAGE_OP_BYPASS_ROUTE) - (void)setsockopt(s, SOL_SOCKET, SO_DONTROUTE, (char *)&on, - sizeof(on)); + setsockopt(s, SOL_SOCKET, SO_DONTROUTE, + &const_int_1, sizeof(const_int_1)); sndsock = xsocket(AF_INET, SOCK_RAW, IPPROTO_RAW); @@ -1087,32 +1086,31 @@ traceroute_main(int argc, char *argv[]) #endif /* CONFIG_FEATURE_TRACEROUTE_SOURCE_ROUTE */ #ifdef SO_SNDBUF - if (setsockopt(sndsock, SOL_SOCKET, SO_SNDBUF, (char *)&packlen, - sizeof(packlen)) < 0) { + if (setsockopt(sndsock, SOL_SOCKET, SO_SNDBUF, &packlen, sizeof(packlen)) < 0) { bb_perror_msg_and_die("SO_SNDBUF"); } #endif #ifdef IP_HDRINCL - if (setsockopt(sndsock, IPPROTO_IP, IP_HDRINCL, (char *)&on, - sizeof(on)) < 0 && errno != ENOPROTOOPT) { + if (setsockopt(sndsock, IPPROTO_IP, IP_HDRINCL, &const_int_1, sizeof(const_int_1)) < 0 + && errno != ENOPROTOOPT + ) { bb_perror_msg_and_die("IP_HDRINCL"); } #else #ifdef IP_TOS - if (tos_str && setsockopt(sndsock, IPPROTO_IP, IP_TOS, - (char *)&tos, sizeof(tos)) < 0) { + if (tos_str && setsockopt(sndsock, IPPROTO_IP, IP_TOS, &tos, sizeof(tos)) < 0) { bb_perror_msg_and_die("setsockopt tos %d", tos); } #endif #endif #if TRACEROUTE_SO_DEBUG if (op & USAGE_OP_DEBUG) - (void)setsockopt(sndsock, SOL_SOCKET, SO_DEBUG, (char *)&on, - sizeof(on)); + setsockopt(sndsock, SOL_SOCKET, SO_DEBUG, + &const_int_1, sizeof(const_int_1)); #endif if (op & USAGE_OP_BYPASS_ROUTE) - (void)setsockopt(sndsock, SOL_SOCKET, SO_DONTROUTE, (char *)&on, - sizeof(on)); + setsockopt(sndsock, SOL_SOCKET, SO_DONTROUTE, + &const_int_1, sizeof(const_int_1)); /* Revert to non-privileged user after opening sockets */ xsetgid(getgid()); diff --git a/networking/udhcp/socket.c b/networking/udhcp/socket.c index 8138f5a86..76ae7172d 100644 --- a/networking/udhcp/socket.c +++ b/networking/udhcp/socket.c @@ -112,7 +112,7 @@ int listen_socket(uint32_t ip, int port, char *inf) } strncpy(interface.ifr_name, inf, IFNAMSIZ); - if (setsockopt(fd, SOL_SOCKET, SO_BINDTODEVICE, (char *)&interface, sizeof(interface)) < 0) { + if (setsockopt(fd, SOL_SOCKET, SO_BINDTODEVICE, &interface, sizeof(interface)) < 0) { close(fd); return -1; } diff --git a/shell/lash.c b/shell/lash.c index 4ea4e6763..90bd16885 100644 --- a/shell/lash.c +++ b/shell/lash.c @@ -30,7 +30,7 @@ #define CONFIG_LASH_PIPE_N_REDIRECTS #define CONFIG_LASH_JOB_CONTROL -static const int MAX_READ = 128; /* size of input buffer for `read' builtin */ +enum { MAX_READ = 128 }; /* size of input buffer for 'read' builtin */ #define JOB_STATUS_FORMAT "[%d] %-22s %.40s\n" -- 2.25.1