modinfo: trivial optimizations
authorDenys Vlasenko <vda.linux@googlemail.com>
Tue, 15 Feb 2011 00:45:14 +0000 (01:45 +0100)
committerDenys Vlasenko <vda.linux@googlemail.com>
Tue, 15 Feb 2011 00:45:14 +0000 (01:45 +0100)
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
modutils/modinfo.c

index cc501825c6dc10d7f111e713a69288cc83fb7e52..db134bd0037a9298e17299c859b588c173109433 100644 (file)
@@ -44,7 +44,7 @@ static int display(const char *data, const char *pattern, int flag)
 }
 
 static void modinfo(const char *path, const char *version,
-                       struct modinfo_env *env)
+                       const struct modinfo_env *env)
 {
        static const char *const shortcuts[] = {
                "filename",
@@ -82,11 +82,13 @@ static void modinfo(const char *path, const char *version,
        if (field)
                tags |= OPT_F;
        for (j = 1; (1<<j) & (OPT_TAGS + OPT_F); j++) {
-               const char *pattern = field;
-               if ((1<<j) & OPT_TAGS)
-                       pattern = shortcuts[j];
+               const char *pattern;
+
                if (!((1<<j) & tags))
                        continue;
+               pattern = field;
+               if ((1<<j) & OPT_TAGS)
+                       pattern = shortcuts[j];
                length = strlen(pattern);
                ptr = the_module;
                while (1) {