chiark / gitweb /
udev: set optind = 0, not the usual 1, to reset getopt_long()s internal state
authorKay Sievers <kay@vrfy.org>
Thu, 25 Oct 2012 19:31:38 +0000 (21:31 +0200)
committerKay Sievers <kay@vrfy.org>
Thu, 25 Oct 2012 19:31:38 +0000 (21:31 +0200)
src/udev/udev-builtin.c
src/udev/udevadm.c

index 18fc3df..26ee16c 100644 (file)
@@ -127,7 +127,8 @@ int udev_builtin_run(struct udev_device *dev, enum udev_builtin_cmd cmd, const c
         int argc;
         char *argv[128];
 
-        optind = 1;
+        /* we need '0' here to reset the internal state */
+        optind = 0;
         util_strscpy(arg, sizeof(arg), command);
         udev_build_argv(udev_device_get_udev(dev), arg, &argc, argv);
         return builtins[cmd]->cmd(dev, argc, argv, test);
index d1e9756..5e69e19 100644 (file)
@@ -134,7 +134,8 @@ int main(int argc, char *argv[])
                         if (strcmp(udevadm_cmds[i]->name, command) == 0) {
                                 argc -= optind;
                                 argv += optind;
-                                optind = 1;
+                                /* we need '0' here to reset the internal state */
+                                optind = 0;
                                 rc = run_command(udev, udevadm_cmds[i], argc, argv);
                                 goto out;
                         }