diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2018-03-05 17:46:17 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2018-03-05 17:46:17 +0100 |
commit | 82ec89480d524a219ad027d1f7c5aa42cc6373d5 (patch) | |
tree | ad36e295337e149aa170b0d241a0b441d828dd3e | |
parent | 8a5299fcfd54ae3b895b66249d6d105e956192cb (diff) | |
download | busybox-w32-82ec89480d524a219ad027d1f7c5aa42cc6373d5.tar.gz busybox-w32-82ec89480d524a219ad027d1f7c5aa42cc6373d5.tar.bz2 busybox-w32-82ec89480d524a219ad027d1f7c5aa42cc6373d5.zip |
networking/interface.c: get rid of global "smallint interface_opt_a"
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | include/libbb.h | 2 | ||||
-rw-r--r-- | networking/ifconfig.c | 8 | ||||
-rw-r--r-- | networking/interface.c | 37 |
3 files changed, 20 insertions, 27 deletions
diff --git a/include/libbb.h b/include/libbb.h index f1ab1ca6f..fa878433e 100644 --- a/include/libbb.h +++ b/include/libbb.h | |||
@@ -1367,7 +1367,7 @@ struct hwtype { | |||
1367 | int FAST_FUNC (*activate)(int fd); | 1367 | int FAST_FUNC (*activate)(int fd); |
1368 | int suppress_null_addr; | 1368 | int suppress_null_addr; |
1369 | }; | 1369 | }; |
1370 | extern smallint interface_opt_a; | 1370 | #define IFNAME_SHOW_DOWNED_TOO ((char*)(intptr_t)1) |
1371 | int display_interfaces(char *ifname) FAST_FUNC; | 1371 | int display_interfaces(char *ifname) FAST_FUNC; |
1372 | int in_ether(const char *bufp, struct sockaddr *sap) FAST_FUNC; | 1372 | int in_ether(const char *bufp, struct sockaddr *sap) FAST_FUNC; |
1373 | #if ENABLE_FEATURE_HWIB | 1373 | #if ENABLE_FEATURE_HWIB |
diff --git a/networking/ifconfig.c b/networking/ifconfig.c index 61d91788a..5c47abc16 100644 --- a/networking/ifconfig.c +++ b/networking/ifconfig.c | |||
@@ -338,6 +338,7 @@ int ifconfig_main(int argc UNUSED_PARAM, char **argv) | |||
338 | char *p; | 338 | char *p; |
339 | /*char host[128];*/ | 339 | /*char host[128];*/ |
340 | const char *host = NULL; /* make gcc happy */ | 340 | const char *host = NULL; /* make gcc happy */ |
341 | IF_FEATURE_IFCONFIG_STATUS(char *show_all_param;) | ||
341 | 342 | ||
342 | did_flags = 0; | 343 | did_flags = 0; |
343 | #if ENABLE_FEATURE_IFCONFIG_BROADCAST_PLUS | 344 | #if ENABLE_FEATURE_IFCONFIG_BROADCAST_PLUS |
@@ -349,15 +350,16 @@ int ifconfig_main(int argc UNUSED_PARAM, char **argv) | |||
349 | ++argv; | 350 | ++argv; |
350 | 351 | ||
351 | #if ENABLE_FEATURE_IFCONFIG_STATUS | 352 | #if ENABLE_FEATURE_IFCONFIG_STATUS |
352 | if (argv[0] && (argv[0][0] == '-' && argv[0][1] == 'a' && !argv[0][2])) { | 353 | show_all_param = NULL; |
353 | interface_opt_a = 1; | 354 | if (argv[0] && argv[0][0] == '-' && argv[0][1] == 'a' && !argv[0][2]) { |
354 | ++argv; | 355 | ++argv; |
356 | show_all_param = IFNAME_SHOW_DOWNED_TOO; | ||
355 | } | 357 | } |
356 | #endif | 358 | #endif |
357 | 359 | ||
358 | if (!argv[0] || !argv[1]) { /* one or no args */ | 360 | if (!argv[0] || !argv[1]) { /* one or no args */ |
359 | #if ENABLE_FEATURE_IFCONFIG_STATUS | 361 | #if ENABLE_FEATURE_IFCONFIG_STATUS |
360 | return display_interfaces(argv[0] /* can be NULL */); | 362 | return display_interfaces(argv[0] ? argv[0] : show_all_param); |
361 | #else | 363 | #else |
362 | bb_error_msg_and_die("no support for status display"); | 364 | bb_error_msg_and_die("no support for status display"); |
363 | #endif | 365 | #endif |
diff --git a/networking/interface.c b/networking/interface.c index 0bbef9879..ff99c2981 100644 --- a/networking/interface.c +++ b/networking/interface.c | |||
@@ -342,8 +342,6 @@ struct interface { | |||
342 | }; | 342 | }; |
343 | 343 | ||
344 | 344 | ||
345 | smallint interface_opt_a; /* show all interfaces */ | ||
346 | |||
347 | static struct interface *int_list, *int_last; | 345 | static struct interface *int_list, *int_last; |
348 | 346 | ||
349 | 347 | ||
@@ -1086,13 +1084,13 @@ static void ife_print(struct interface *ptr) | |||
1086 | bb_putchar('\n'); | 1084 | bb_putchar('\n'); |
1087 | } | 1085 | } |
1088 | 1086 | ||
1089 | static int do_if_print(struct interface *ife) /*, int *opt_a)*/ | 1087 | static int do_if_print(struct interface *ife, int show_downed_too) |
1090 | { | 1088 | { |
1091 | int res; | 1089 | int res; |
1092 | 1090 | ||
1093 | res = do_if_fetch(ife); | 1091 | res = do_if_fetch(ife); |
1094 | if (res >= 0) { | 1092 | if (res >= 0) { |
1095 | if ((ife->flags & IFF_UP) || interface_opt_a) | 1093 | if ((ife->flags & IFF_UP) || show_downed_too) |
1096 | ife_print(ife); | 1094 | ife_print(ife); |
1097 | } | 1095 | } |
1098 | return res; | 1096 | return res; |
@@ -1128,40 +1126,33 @@ static int for_all_interfaces(int (*doit) (struct interface *, void *), | |||
1128 | } | 1126 | } |
1129 | #endif | 1127 | #endif |
1130 | 1128 | ||
1131 | /* for ipv4 add/del modes */ | 1129 | int FAST_FUNC display_interfaces(char *ifname) |
1132 | static int if_print(char *ifname) | ||
1133 | { | 1130 | { |
1134 | struct interface *ife; | 1131 | struct interface *ife; |
1135 | int res; | 1132 | int res; |
1136 | 1133 | ||
1137 | if (!ifname) { | 1134 | if (!ifname || ifname == IFNAME_SHOW_DOWNED_TOO) { |
1138 | /*res = for_all_interfaces(do_if_print, &interface_opt_a);*/ | 1135 | /*res = for_all_interfaces(do_if_print, &interface_opt_a);*/ |
1139 | if (!int_list) { | 1136 | if (!int_list) { |
1140 | int err = if_readlist(); | 1137 | res = if_readlist(); |
1141 | if (err < 0) | 1138 | if (res < 0) |
1142 | return err; | 1139 | goto ret; |
1143 | } | 1140 | } |
1144 | for (ife = int_list; ife; ife = ife->next) { | 1141 | for (ife = int_list; ife; ife = ife->next) { |
1145 | int err = do_if_print(ife); /*, &interface_opt_a);*/ | 1142 | BUILD_BUG_ON((int)(intptr_t)IFNAME_SHOW_DOWNED_TOO != 1); |
1146 | if (err) | 1143 | res = do_if_print(ife, (int)(intptr_t)ifname); |
1147 | return err; | 1144 | if (res < 0) |
1145 | goto ret; | ||
1148 | } | 1146 | } |
1149 | return 0; | 1147 | return 0; |
1150 | } | 1148 | } |
1149 | |||
1151 | ife = lookup_interface(ifname); | 1150 | ife = lookup_interface(ifname); |
1152 | res = do_if_fetch(ife); | 1151 | res = do_if_fetch(ife); |
1153 | if (res >= 0) | 1152 | if (res >= 0) |
1154 | ife_print(ife); | 1153 | ife_print(ife); |
1155 | return res; | 1154 | ret: |
1156 | } | 1155 | return (res < 0); /* status < 0 == 1 -- error */ |
1157 | |||
1158 | int FAST_FUNC display_interfaces(char *ifname) | ||
1159 | { | ||
1160 | int status; | ||
1161 | |||
1162 | status = if_print(ifname); | ||
1163 | |||
1164 | return (status < 0); /* status < 0 == 1 -- error */ | ||
1165 | } | 1156 | } |
1166 | 1157 | ||
1167 | #if ENABLE_FEATURE_HWIB | 1158 | #if ENABLE_FEATURE_HWIB |