diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2007-06-25 10:55:35 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2007-06-25 10:55:35 +0000 |
commit | 80b8b39899a09c7516920cda5fd343b3086d4824 (patch) | |
tree | aa9903fd6b64d19c5f640fa302272d85c92b204e /networking | |
parent | 1399282b47bb218132a554cbe5b2b0ce4dcc055f (diff) | |
download | busybox-w32-80b8b39899a09c7516920cda5fd343b3086d4824.tar.gz busybox-w32-80b8b39899a09c7516920cda5fd343b3086d4824.tar.bz2 busybox-w32-80b8b39899a09c7516920cda5fd343b3086d4824.zip |
Consolidate ARRAY_SIZE macro; remove one unneeded global var (walter harms <wharms@bfs.de>)
Diffstat (limited to 'networking')
-rw-r--r-- | networking/httpd.c | 5 | ||||
-rw-r--r-- | networking/ifconfig.c | 2 | ||||
-rw-r--r-- | networking/ifupdown.c | 12 | ||||
-rw-r--r-- | networking/libiproute/ll_proto.c | 4 | ||||
-rw-r--r-- | networking/libiproute/ll_types.c | 2 | ||||
-rw-r--r-- | networking/tftp.c | 4 |
6 files changed, 13 insertions, 16 deletions
diff --git a/networking/httpd.c b/networking/httpd.c index 8c0a83e52..383a00635 100644 --- a/networking/httpd.c +++ b/networking/httpd.c | |||
@@ -878,11 +878,8 @@ static int sendHeaders(HttpResponseNum responseNum) | |||
878 | time_t timer = time(0); | 878 | time_t timer = time(0); |
879 | char timeStr[80]; | 879 | char timeStr[80]; |
880 | int len; | 880 | int len; |
881 | enum { | ||
882 | numNames = sizeof(httpResponseNames) / sizeof(httpResponseNames[0]) | ||
883 | }; | ||
884 | 881 | ||
885 | for (i = 0; i < numNames; i++) { | 882 | for (i = 0; i < ARRAY_SIZE(httpResponseNames); i++) { |
886 | if (httpResponseNames[i].type == responseNum) { | 883 | if (httpResponseNames[i].type == responseNum) { |
887 | responseString = httpResponseNames[i].name; | 884 | responseString = httpResponseNames[i].name; |
888 | infoString = httpResponseNames[i].info; | 885 | infoString = httpResponseNames[i].info; |
diff --git a/networking/ifconfig.c b/networking/ifconfig.c index 5742399c5..5e11b2b7c 100644 --- a/networking/ifconfig.c +++ b/networking/ifconfig.c | |||
@@ -337,7 +337,7 @@ int ifconfig_main(int argc, char **argv) | |||
337 | } | 337 | } |
338 | 338 | ||
339 | /* We fell through, so treat as possible hostname. */ | 339 | /* We fell through, so treat as possible hostname. */ |
340 | a1op = Arg1Opt + (sizeof(Arg1Opt) / sizeof(Arg1Opt[0])) - 1; | 340 | a1op = Arg1Opt + ARRAY_SIZE(Arg1Opt) - 1; |
341 | mask = op->arg_flags; | 341 | mask = op->arg_flags; |
342 | goto HOSTNAME; | 342 | goto HOSTNAME; |
343 | 343 | ||
diff --git a/networking/ifupdown.c b/networking/ifupdown.c index 2b748f11d..8843184bf 100644 --- a/networking/ifupdown.c +++ b/networking/ifupdown.c | |||
@@ -375,7 +375,7 @@ static const struct method_t methods6[] = { | |||
375 | 375 | ||
376 | static const struct address_family_t addr_inet6 = { | 376 | static const struct address_family_t addr_inet6 = { |
377 | "inet6", | 377 | "inet6", |
378 | sizeof(methods6) / sizeof(struct method_t), | 378 | ARRAY_SIZE(methods6), |
379 | methods6 | 379 | methods6 |
380 | }; | 380 | }; |
381 | #endif /* FEATURE_IFUPDOWN_IPV6 */ | 381 | #endif /* FEATURE_IFUPDOWN_IPV6 */ |
@@ -471,8 +471,8 @@ static const struct dhcp_client_t ext_dhcp_clients[] = { | |||
471 | static int dhcp_up(struct interface_defn_t *ifd, execfn *exec) | 471 | static int dhcp_up(struct interface_defn_t *ifd, execfn *exec) |
472 | { | 472 | { |
473 | #if ENABLE_FEATURE_IFUPDOWN_EXTERNAL_DHCP | 473 | #if ENABLE_FEATURE_IFUPDOWN_EXTERNAL_DHCP |
474 | int i, nclients = sizeof(ext_dhcp_clients) / sizeof(ext_dhcp_clients[0]); | 474 | int i ; |
475 | for (i = 0; i < nclients; i++) { | 475 | for (i = 0; i < ARRAY_SIZE(ext_dhcp_clients); i++) { |
476 | if (exists_execable(ext_dhcp_clients[i].name)) | 476 | if (exists_execable(ext_dhcp_clients[i].name)) |
477 | return execute(ext_dhcp_clients[i].startcmd, ifd, exec); | 477 | return execute(ext_dhcp_clients[i].startcmd, ifd, exec); |
478 | } | 478 | } |
@@ -490,8 +490,8 @@ static int dhcp_up(struct interface_defn_t *ifd, execfn *exec) | |||
490 | static int dhcp_down(struct interface_defn_t *ifd, execfn *exec) | 490 | static int dhcp_down(struct interface_defn_t *ifd, execfn *exec) |
491 | { | 491 | { |
492 | #if ENABLE_FEATURE_IFUPDOWN_EXTERNAL_DHCP | 492 | #if ENABLE_FEATURE_IFUPDOWN_EXTERNAL_DHCP |
493 | int i, nclients = sizeof(ext_dhcp_clients) / sizeof(ext_dhcp_clients[0]); | 493 | int i ; |
494 | for (i = 0; i < nclients; i++) { | 494 | for (i = 0; i < ARRAY_SIZE(ext_dhcp_clients); i++) { |
495 | if (exists_execable(ext_dhcp_clients[i].name)) | 495 | if (exists_execable(ext_dhcp_clients[i].name)) |
496 | return execute(ext_dhcp_clients[i].stopcmd, ifd, exec); | 496 | return execute(ext_dhcp_clients[i].stopcmd, ifd, exec); |
497 | } | 497 | } |
@@ -551,7 +551,7 @@ static const struct method_t methods[] = { | |||
551 | 551 | ||
552 | static const struct address_family_t addr_inet = { | 552 | static const struct address_family_t addr_inet = { |
553 | "inet", | 553 | "inet", |
554 | sizeof(methods) / sizeof(methods[0]), | 554 | ARRAY_SIZE(methods), |
555 | methods | 555 | methods |
556 | }; | 556 | }; |
557 | 557 | ||
diff --git a/networking/libiproute/ll_proto.c b/networking/libiproute/ll_proto.c index 10d749881..4e62e876e 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) | |||
96 | 96 | ||
97 | id = ntohs(id); | 97 | id = ntohs(id); |
98 | 98 | ||
99 | for (i=0; i<sizeof(llproto_names)/sizeof(llproto_names[0]); i++) { | 99 | for (i=0; i < ARRAY_SIZE(llproto_names); i++) { |
100 | if (llproto_names[i].id == id) | 100 | if (llproto_names[i].id == id) |
101 | return llproto_names[i].name; | 101 | return llproto_names[i].name; |
102 | } | 102 | } |
@@ -107,7 +107,7 @@ const char * ll_proto_n2a(unsigned short id, char *buf, int len) | |||
107 | int ll_proto_a2n(unsigned short *id, char *buf) | 107 | int ll_proto_a2n(unsigned short *id, char *buf) |
108 | { | 108 | { |
109 | int i; | 109 | int i; |
110 | for (i=0; i<sizeof(llproto_names)/sizeof(llproto_names[0]); i++) { | 110 | for (i=0; i < ARRAY_SIZE(llproto_names); i++) { |
111 | if (strcasecmp(llproto_names[i].name, buf) == 0) { | 111 | if (strcasecmp(llproto_names[i].name, buf) == 0) { |
112 | *id = htons(llproto_names[i].id); | 112 | *id = htons(llproto_names[i].id); |
113 | return 0; | 113 | return 0; |
diff --git a/networking/libiproute/ll_types.c b/networking/libiproute/ll_types.c index 5d2843b14..84fd628cb 100644 --- a/networking/libiproute/ll_types.c +++ b/networking/libiproute/ll_types.c | |||
@@ -108,7 +108,7 @@ __PF(VOID,void) | |||
108 | #undef __PF | 108 | #undef __PF |
109 | 109 | ||
110 | int i; | 110 | int i; |
111 | for (i = 0; i < sizeof(arphrd_names)/sizeof(arphrd_names[0]); i++) { | 111 | for (i = 0; i < ARRAY_SIZE(arphrd_names); i++) { |
112 | if (arphrd_names[i].type == type) | 112 | if (arphrd_names[i].type == type) |
113 | return arphrd_names[i].name; | 113 | return arphrd_names[i].name; |
114 | } | 114 | } |
diff --git a/networking/tftp.c b/networking/tftp.c index 8517830b7..b20486cc1 100644 --- a/networking/tftp.c +++ b/networking/tftp.c | |||
@@ -280,13 +280,13 @@ static int tftp( USE_GETPUT(const int cmd,) | |||
280 | "no such user", | 280 | "no such user", |
281 | "bad option", | 281 | "bad option", |
282 | }; | 282 | }; |
283 | enum { NUM_ERRCODE = sizeof(errcode_str) / sizeof(errcode_str[0]) }; | 283 | |
284 | const char *msg = ""; | 284 | const char *msg = ""; |
285 | 285 | ||
286 | if (rbuf[4] != '\0') { | 286 | if (rbuf[4] != '\0') { |
287 | msg = &rbuf[4]; | 287 | msg = &rbuf[4]; |
288 | rbuf[tftp_bufsize - 1] = '\0'; | 288 | rbuf[tftp_bufsize - 1] = '\0'; |
289 | } else if (recv_blk < NUM_ERRCODE) { | 289 | } else if (recv_blk < ARRAY_SIZE(errcode_str)) { |
290 | msg = errcode_str[recv_blk]; | 290 | msg = errcode_str[recv_blk]; |
291 | } | 291 | } |
292 | bb_error_msg("server error: (%u) %s", recv_blk, msg); | 292 | bb_error_msg("server error: (%u) %s", recv_blk, msg); |