blockdev: -2 bytes
authorDenys Vlasenko <dvlasenk@redhat.com>
Mon, 6 Sep 2010 13:34:15 +0000 (15:34 +0200)
committerDenys Vlasenko <dvlasenk@redhat.com>
Mon, 6 Sep 2010 13:34:15 +0000 (15:34 +0200)
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
util-linux/blockdev.c

index fea30b0098f7804fb14e3c031c87b8eed5231e59..2b48c28c9034c80243b907879cdda3ad29be6032 100644 (file)
@@ -109,12 +109,15 @@ static const struct bdc bdcommands[] = {
 
 static const struct bdc *find_cmd(const char *s)
 {
-       int j;
-       if (*s++ == '-')
-               if (*s++ == '-')
-                       for (j = 0; j < ARRAY_SIZE(bdcommands); j++)
-                               if (strcmp(s, bdcommands[j].name) == 0)
-                                       return &bdcommands[j];
+       const struct bdc *bdcmd = bdcommands;
+       if (s[0] == '-' && s[1] == '-') {
+               s += 2;
+               do {
+                       if (strcmp(s, bdcmd->name) == 0)
+                               return bdcmd;
+                       bdcmd++;
+               } while (bdcmd != bdcommands + ARRAY_SIZE(bdcommands));
+       }
        bb_show_usage();
 }