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-w32-a980109c6aa36995434eae4993e77d346d2f227a.tar.gz
busybox-w32-a980109c6aa36995434eae4993e77d346d2f227a.tar.bz2
busybox-w32-a980109c6aa36995434eae4993e77d346d2f227a.zip
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 {
271}; 271};
272 272
273static const struct { 273static const struct {
274 int type; 274 unsigned char type;
275 const char *name; 275 char name[7];
276} qtypes[] = { 276} qtypes[] = {
277 { ns_t_soa, "SOA" }, 277 { ns_t_soa, "SOA" },
278 { ns_t_ns, "NS" }, 278 { ns_t_ns, "NS" },
@@ -285,7 +285,6 @@ static const struct {
285 { ns_t_txt, "TXT" }, 285 { ns_t_txt, "TXT" },
286 { ns_t_ptr, "PTR" }, 286 { ns_t_ptr, "PTR" },
287 { ns_t_any, "ANY" }, 287 { ns_t_any, "ANY" },
288 { }
289}; 288};
290 289
291static const char *const rcodes[] = { 290static const char *const rcodes[] = {
@@ -803,7 +802,7 @@ int nslookup_main(int argc UNUSED_PARAM, char **argv)
803 ptr = chr + 1; 802 ptr = chr + 1;
804 803
805 for (c = 0;; c++) { 804 for (c = 0;; c++) {
806 if (!qtypes[c].name) 805 if (c == ARRAY_SIZE(qtypes))
807 bb_error_msg_and_die("invalid query type \"%s\"", ptr); 806 bb_error_msg_and_die("invalid query type \"%s\"", ptr);
808 if (strcmp(qtypes[c].name, ptr) == 0) 807 if (strcmp(qtypes[c].name, ptr) == 0)
809 break; 808 break;
@@ -836,13 +835,11 @@ int nslookup_main(int argc UNUSED_PARAM, char **argv)
836 add_query(&queries, &n_queries, T_AAAA, *argv); 835 add_query(&queries, &n_queries, T_AAAA, *argv);
837#endif 836#endif
838 } 837 }
839 } 838 } else {
840 else {
841 int c; 839 int c;
842 for (c = 0; qtypes[c].name; c++) { 840 for (c = 0; c < ARRAY_SIZE(qtypes); c++) {
843 if (types & (1 << c)) 841 if (types & (1 << c))
844 add_query(&queries, &n_queries, qtypes[c].type, 842 add_query(&queries, &n_queries, qtypes[c].type, *argv);
845 *argv);
846 } 843 }
847 } 844 }
848 argv++; 845 argv++;