basename: do not use argc
authorDenys Vlasenko <vda.linux@googlemail.com>
Fri, 21 Jul 2017 16:41:46 +0000 (18:41 +0200)
committerDenys Vlasenko <vda.linux@googlemail.com>
Fri, 21 Jul 2017 16:41:46 +0000 (18:41 +0200)
function                                             old     new   delta
basename_main                                        153     148      -5

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
coreutils/basename.c

index 481cdcee90f10ff8d68d68528c2758c9327646c9..566aeebda24acd166011b5b7bb0b3010a8cc3e5a 100644 (file)
 /* This is a NOFORK applet. Be very careful! */
 
 int basename_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
-int basename_main(int argc, char **argv)
+int basename_main(int argc UNUSED_PARAM, char **argv)
 {
        size_t m, n;
        char *s;
 
        if (argv[1] && strcmp(argv[1], "--") == 0) {
                argv++;
-               argc--;
        }
-
-       if ((unsigned)(argc-2) >= 2) {
+       if (!argv[1])
                bb_show_usage();
-       }
 
        /* It should strip slash: /abc/def/ -> def */
        s = bb_get_last_path_component_strip(*++argv);
 
        m = strlen(s);
        if (*++argv) {
+               if (argv[1])
+                       bb_show_usage();
                n = strlen(*argv);
                if ((m > n) && (strcmp(s+m-n, *argv) == 0)) {
                        m -= n;