aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2018-04-15 10:52:11 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2018-04-15 10:52:11 +0200
commita980109c6aa36995434eae4993e77d346d2f227a (patch)
tree6bc1a0c685ae79497cbd9f5c60110e5409bd49db
parent2cf75b3c8113c59db0bf9290bd0fdfc77cd2237b (diff)
downloadbusybox-a980109c6aa36995434eae4993e77d346d2f227a.tar.gz
nslookup: smaller qtypes[] array
function old new delta nslookup_main 2708 2715 +7 qtypes 80 72 -8 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/1 up/down: 7/-8) Total: -1 bytes text data bss dec hex filename 926277 555 5740 932572 e3adc busybox_old 926262 555 5740 932557 e3acd busybox_unstripped Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--networking/nslookup.c15
1 files changed, 6 insertions, 9 deletions
diff --git a/networking/nslookup.c b/networking/nslookup.c
index d31801e96..c6f431347 100644
--- a/networking/nslookup.c
+++ b/networking/nslookup.c
@@ -271,8 +271,8 @@ struct query {
};
static const struct {
- int type;
- const char *name;
+ unsigned char type;
+ char name[7];
} qtypes[] = {
{ ns_t_soa, "SOA" },
{ ns_t_ns, "NS" },
@@ -285,7 +285,6 @@ static const struct {
{ ns_t_txt, "TXT" },
{ ns_t_ptr, "PTR" },
{ ns_t_any, "ANY" },
- { }
};
static const char *const rcodes[] = {
@@ -803,7 +802,7 @@ int nslookup_main(int argc UNUSED_PARAM, char **argv)
ptr = chr + 1;
for (c = 0;; c++) {
- if (!qtypes[c].name)
+ if (c == ARRAY_SIZE(qtypes))
bb_error_msg_and_die("invalid query type \"%s\"", ptr);
if (strcmp(qtypes[c].name, ptr) == 0)
break;
@@ -836,13 +835,11 @@ int nslookup_main(int argc UNUSED_PARAM, char **argv)
add_query(&queries, &n_queries, T_AAAA, *argv);
#endif
}
- }
- else {
+ } else {
int c;
- for (c = 0; qtypes[c].name; c++) {
+ for (c = 0; c < ARRAY_SIZE(qtypes); c++) {
if (types & (1 << c))
- add_query(&queries, &n_queries, qtypes[c].type,
- *argv);
+ add_query(&queries, &n_queries, qtypes[c].type, *argv);
}
}
argv++;