summaryrefslogtreecommitdiff
path: root/networking
diff options
context:
space:
mode:
authorDenis Vlasenko2007-06-25 10:55:35 +0000
committerDenis Vlasenko2007-06-25 10:55:35 +0000
commit80b8b39899a09c7516920cda5fd343b3086d4824 (patch)
treeaa9903fd6b64d19c5f640fa302272d85c92b204e /networking
parent1399282b47bb218132a554cbe5b2b0ce4dcc055f (diff)
downloadbusybox-80b8b39899a09c7516920cda5fd343b3086d4824.zip
busybox-80b8b39899a09c7516920cda5fd343b3086d4824.tar.gz
Consolidate ARRAY_SIZE macro; remove one unneeded global var (walter harms <wharms@bfs.de>)
Diffstat (limited to 'networking')
-rw-r--r--networking/httpd.c5
-rw-r--r--networking/ifconfig.c2
-rw-r--r--networking/ifupdown.c12
-rw-r--r--networking/libiproute/ll_proto.c4
-rw-r--r--networking/libiproute/ll_types.c2
-rw-r--r--networking/tftp.c4
6 files changed, 13 insertions, 16 deletions
diff --git a/networking/httpd.c b/networking/httpd.c
index 8c0a83e..383a006 100644
--- a/networking/httpd.c
+++ b/networking/httpd.c
@@ -878,11 +878,8 @@ static int sendHeaders(HttpResponseNum responseNum)
time_t timer = time(0);
char timeStr[80];
int len;
- enum {
- numNames = sizeof(httpResponseNames) / sizeof(httpResponseNames[0])
- };
- for (i = 0; i < numNames; i++) {
+ for (i = 0; i < ARRAY_SIZE(httpResponseNames); i++) {
if (httpResponseNames[i].type == responseNum) {
responseString = httpResponseNames[i].name;
infoString = httpResponseNames[i].info;
diff --git a/networking/ifconfig.c b/networking/ifconfig.c
index 5742399..5e11b2b 100644
--- a/networking/ifconfig.c
+++ b/networking/ifconfig.c
@@ -337,7 +337,7 @@ int ifconfig_main(int argc, char **argv)
}
/* We fell through, so treat as possible hostname. */
- a1op = Arg1Opt + (sizeof(Arg1Opt) / sizeof(Arg1Opt[0])) - 1;
+ a1op = Arg1Opt + ARRAY_SIZE(Arg1Opt) - 1;
mask = op->arg_flags;
goto HOSTNAME;
diff --git a/networking/ifupdown.c b/networking/ifupdown.c
index 2b748f1..8843184 100644
--- a/networking/ifupdown.c
+++ b/networking/ifupdown.c
@@ -375,7 +375,7 @@ static const struct method_t methods6[] = {
static const struct address_family_t addr_inet6 = {
"inet6",
- sizeof(methods6) / sizeof(struct method_t),
+ ARRAY_SIZE(methods6),
methods6
};
#endif /* FEATURE_IFUPDOWN_IPV6 */
@@ -471,8 +471,8 @@ static const struct dhcp_client_t ext_dhcp_clients[] = {
static int dhcp_up(struct interface_defn_t *ifd, execfn *exec)
{
#if ENABLE_FEATURE_IFUPDOWN_EXTERNAL_DHCP
- int i, nclients = sizeof(ext_dhcp_clients) / sizeof(ext_dhcp_clients[0]);
- for (i = 0; i < nclients; i++) {
+ int i ;
+ for (i = 0; i < ARRAY_SIZE(ext_dhcp_clients); i++) {
if (exists_execable(ext_dhcp_clients[i].name))
return execute(ext_dhcp_clients[i].startcmd, ifd, exec);
}
@@ -490,8 +490,8 @@ static int dhcp_up(struct interface_defn_t *ifd, execfn *exec)
static int dhcp_down(struct interface_defn_t *ifd, execfn *exec)
{
#if ENABLE_FEATURE_IFUPDOWN_EXTERNAL_DHCP
- int i, nclients = sizeof(ext_dhcp_clients) / sizeof(ext_dhcp_clients[0]);
- for (i = 0; i < nclients; i++) {
+ int i ;
+ for (i = 0; i < ARRAY_SIZE(ext_dhcp_clients); i++) {
if (exists_execable(ext_dhcp_clients[i].name))
return execute(ext_dhcp_clients[i].stopcmd, ifd, exec);
}
@@ -551,7 +551,7 @@ static const struct method_t methods[] = {
static const struct address_family_t addr_inet = {
"inet",
- sizeof(methods) / sizeof(methods[0]),
+ ARRAY_SIZE(methods),
methods
};
diff --git a/networking/libiproute/ll_proto.c b/networking/libiproute/ll_proto.c
index 10d7498..4e62e87 100644
--- a/networking/libiproute/ll_proto.c
+++ b/networking/libiproute/ll_proto.c
@@ -96,7 +96,7 @@ const char * ll_proto_n2a(unsigned short id, char *buf, int len)
id = ntohs(id);
- for (i=0; i<sizeof(llproto_names)/sizeof(llproto_names[0]); i++) {
+ for (i=0; i < ARRAY_SIZE(llproto_names); i++) {
if (llproto_names[i].id == id)
return llproto_names[i].name;
}
@@ -107,7 +107,7 @@ const char * ll_proto_n2a(unsigned short id, char *buf, int len)
int ll_proto_a2n(unsigned short *id, char *buf)
{
int i;
- for (i=0; i<sizeof(llproto_names)/sizeof(llproto_names[0]); i++) {
+ for (i=0; i < ARRAY_SIZE(llproto_names); i++) {
if (strcasecmp(llproto_names[i].name, buf) == 0) {
*id = htons(llproto_names[i].id);
return 0;
diff --git a/networking/libiproute/ll_types.c b/networking/libiproute/ll_types.c
index 5d2843b..84fd628 100644
--- a/networking/libiproute/ll_types.c
+++ b/networking/libiproute/ll_types.c
@@ -108,7 +108,7 @@ __PF(VOID,void)
#undef __PF
int i;
- for (i = 0; i < sizeof(arphrd_names)/sizeof(arphrd_names[0]); i++) {
+ for (i = 0; i < ARRAY_SIZE(arphrd_names); i++) {
if (arphrd_names[i].type == type)
return arphrd_names[i].name;
}
diff --git a/networking/tftp.c b/networking/tftp.c
index 8517830..b20486c 100644
--- a/networking/tftp.c
+++ b/networking/tftp.c
@@ -280,13 +280,13 @@ static int tftp( USE_GETPUT(const int cmd,)
"no such user",
"bad option",
};
- enum { NUM_ERRCODE = sizeof(errcode_str) / sizeof(errcode_str[0]) };
+
const char *msg = "";
if (rbuf[4] != '\0') {
msg = &rbuf[4];
rbuf[tftp_bufsize - 1] = '\0';
- } else if (recv_blk < NUM_ERRCODE) {
+ } else if (recv_blk < ARRAY_SIZE(errcode_str)) {
msg = errcode_str[recv_blk];
}
bb_error_msg("server error: (%u) %s", recv_blk, msg);