diff options
Diffstat (limited to 'main/busybox/2003-modinfo-fix-argument-parsing-and-printing-of-firmwar.patch')
-rw-r--r-- | main/busybox/2003-modinfo-fix-argument-parsing-and-printing-of-firmwar.patch | 87 |
1 files changed, 87 insertions, 0 deletions
diff --git a/main/busybox/2003-modinfo-fix-argument-parsing-and-printing-of-firmwar.patch b/main/busybox/2003-modinfo-fix-argument-parsing-and-printing-of-firmwar.patch new file mode 100644 index 0000000000..434759d130 --- /dev/null +++ b/main/busybox/2003-modinfo-fix-argument-parsing-and-printing-of-firmwar.patch @@ -0,0 +1,87 @@ +From a19967762fa8b8e6da7fcbcf7447131f33b0135b Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Timo=20Ter=C3=A4s?= <timo.teras@iki.fi> +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 <timo.teras@iki.fi> +Cc: Tanguy Pruvot <tanguy.pruvot@gmail.com> +--- + 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<<j) & (OPT_TAGS + OPT_F); j++) { + const char *pattern; + +@@ -141,8 +141,8 @@ int modinfo_main(int argc UNUSED_PARAM, char **argv) + + env.field = NULL; + opt_complementary = "-1"; /* minimum one param */ +- opts = getopt32(argv, "nladvAsDumpF:0", &env.field); +- env.tags = opts & OPT_TAGS ? opts & OPT_TAGS : OPT_TAGS; ++ opts = getopt32(argv, "nladvAsDumpfF:0", &env.field); ++ env.tags = opts & (OPT_TAGS + OPT_F); + argv += optind; + + uname(&uts); +-- +2.6.1 + |