flock: merge spawn_and_wait() code patchs for -c and sans-c uses
authorDenys Vlasenko <vda.linux@googlemail.com>
Sun, 24 Apr 2016 16:21:32 +0000 (18:21 +0200)
committerDenys Vlasenko <vda.linux@googlemail.com>
Sun, 24 Apr 2016 16:21:32 +0000 (18:21 +0200)
function                                             old     new   delta
flock_main                                           334     319     -15

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

index 539a835b7dcfab2421497b438ef5b32929b71fbf..1f7ade7c4c1542b076a870695b1e5b6ef2e5e8aa 100644 (file)
@@ -93,19 +93,19 @@ int flock_main(int argc UNUSED_PARAM, char **argv)
        }
 
        if (argv[0]) {
-               if (!(opt & OPT_c)) {
-                       int rc = spawn_and_wait(argv);
-                       if (rc < 0)
-                               bb_simple_perror_msg(argv[0]);
-                       return rc;
+               int rc;
+               if (opt & OPT_c) {
+                       /* -c 'PROG ARGS' means "run sh -c 'PROG ARGS'" */
+                       argv -= 2;
+                       argv[0] = (char*)get_shell_name();
+                       argv[1] = (char*)"-c";
+                       /* argv[2] = "PROG ARGS"; */
+                       /* argv[3] = NULL; */
                }
-               /* -c 'PROG ARGS' means "run sh -c 'PROG ARGS'" */
-               argv -= 2;
-               argv[0] = (char*)get_shell_name();
-               argv[1] = (char*)"-c";
-               /* argv[2] = "PROG ARGS"; */
-               /* argv[3] = NULL; */
-               return spawn_and_wait(argv);
+               rc = spawn_and_wait(argv);
+               if (rc < 0)
+                       bb_simple_perror_msg(argv[0]);
+               return rc;
        }
 
        return EXIT_SUCCESS;