From a19967762fa8b8e6da7fcbcf7447131f33b0135b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timo=20Ter=C3=A4s?= Date: Wed, 28 Oct 2015 10:20:57 +0200 Subject: [PATCH 2003/2003] modinfo: fix argument parsing, and printing of firmware MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit getopt was missing a short option for 'firmware', thus the -F option for specific keyword was flagged as last OPT_TAGS entry. This caused "-F firmware" to print twice the firmware fields (once due to incorrectly set OPT_TAGS and once for OPT_F) and incorrectly with the fieldname prefix. This adds -f as shortcut for "-F firmware" so that OPT_TAGS and OPT_F are now set properly by getopt32(). This allows removing the incorrect and unneeded OPT_F setting based on the keyword field. function old new delta modinfo_main 438 430 -8 modinfo 457 438 -19 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-27) Total: -27 bytes text data bss dec hex filename 787574 15136 3656 806366 c4dde busybox_old 787547 15136 3656 806339 c4dc3 busybox_unstripped Fixes: 772f17a843 "modinfo: match more standard module fields and fix version field" Signed-off-by: Timo Teräs Cc: Tanguy Pruvot --- modutils/modinfo.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/modutils/modinfo.c b/modutils/modinfo.c index 8e74b64..e2c9df3 100644 --- a/modutils/modinfo.c +++ b/modutils/modinfo.c @@ -31,7 +31,7 @@ enum { struct modinfo_env { char *field; - int tags; + unsigned tags; }; static void display(const char *data, const char *pattern, int flag) @@ -62,11 +62,13 @@ static void modinfo(const char *path, const char *version, "firmware", }; size_t len; - int j; + unsigned j; char *ptr, *the_module; const char *field = env->field; - int tags = env->tags; + unsigned tags = env->tags; + if (!tags) + tags = OPT_TAGS; if (tags & 1) { /* filename */ display(path, shortcuts[0], 1 != tags); } @@ -84,8 +86,6 @@ static void modinfo(const char *path, const char *version, return; } - if (field) - tags |= OPT_F; for (j = 1; (1<