]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
mkdir,mkfifo,mknod: give scontext-related variable a better scope
authorBernhard Voelker <mail@bernhard-voelker.de>
Tue, 2 Jul 2013 09:53:57 +0000 (11:53 +0200)
committerBernhard Voelker <mail@bernhard-voelker.de>
Tue, 2 Jul 2013 09:54:49 +0000 (11:54 +0200)
* src/mkdir.c (main): Move the variable ret and issuing the error
message into the body of the scontext-related if-block.
* src/mkfifo.c (main): Likewise.
* src/mknod.c (main): Likewise.

src/mkdir.c
src/mkfifo.c
src/mknod.c

index 479faca85af06118c657fa10dea6dc5d9398780a..efd318497dba4c22295b71799881f59a7d7b29e2 100644 (file)
@@ -152,7 +152,6 @@ main (int argc, char **argv)
   int optc;
   security_context_t scontext = NULL;
   struct mkdir_options options;
-  int ret = 0;
 
   options.make_ancestor_function = NULL;
   options.mode = S_IRWXUGO;
@@ -198,16 +197,18 @@ main (int argc, char **argv)
 
   if (scontext)
     {
+      int ret = 0;
       if (is_smack_enabled ())
         ret = smack_set_label_for_self (scontext);
       else
         ret = setfscreatecon (scontext);
+
+      if (ret < 0)
+        error (EXIT_FAILURE, errno,
+               _("failed to set default file creation context to %s"),
+               quote (scontext));
     }
 
-  if (ret < 0)
-    error (EXIT_FAILURE, errno,
-           _("failed to set default file creation context to %s"),
-           quote (scontext));
 
   if (options.make_ancestor_function || specified_mode)
     {
index f9fcc0a609545d44416e36601ffa71ada8100dc3..4c6dac468772b3589b959bfefa95816bff233947 100644 (file)
@@ -77,7 +77,6 @@ main (int argc, char **argv)
   int exit_status = EXIT_SUCCESS;
   int optc;
   security_context_t scontext = NULL;
-  int ret = 0;
 
   initialize_main (&argc, &argv);
   set_program_name (argv[0]);
@@ -112,16 +111,17 @@ main (int argc, char **argv)
 
   if (scontext)
     {
+      int ret = 0;
       if (is_smack_enabled ())
         ret = smack_set_label_for_self (scontext);
       else
         ret = setfscreatecon (scontext);
-    }
 
-  if (ret < 0)
-    error (EXIT_FAILURE, errno,
-           _("failed to set default file creation context to %s"),
-           quote (scontext));
+      if (ret < 0)
+        error (EXIT_FAILURE, errno,
+               _("failed to set default file creation context to %s"),
+               quote (scontext));
+    }
 
   newmode = MODE_RW_UGO;
   if (specified_mode)
index 4fd6ed0f4afa41fd326ead352d9661d67a6d9916..c79468c6dd2a4f84587b8d0b89cadc988e6d39ea 100644 (file)
@@ -94,7 +94,6 @@ main (int argc, char **argv)
   int expected_operands;
   mode_t node_type;
   security_context_t scontext = NULL;
-  int ret = 0;
 
   initialize_main (&argc, &argv);
   set_program_name (argv[0]);
@@ -168,16 +167,17 @@ main (int argc, char **argv)
 
   if (scontext)
     {
+      int ret = 0;
       if (is_smack_enabled ())
         ret = smack_set_label_for_self (scontext);
       else
         ret = setfscreatecon (scontext);
-    }
 
-  if (ret < 0)
-    error (EXIT_FAILURE, errno,
-           _("failed to set default file creation context to %s"),
-           quote (scontext));
+      if (ret < 0)
+        error (EXIT_FAILURE, errno,
+               _("failed to set default file creation context to %s"),
+               quote (scontext));
+    }
 
   /* Only check the first character, to allow mnemonic usage like
      'mknod /dev/rst0 character 18 0'. */