summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBernhard Voelker <mail@bernhard-voelker.de>2013-07-02 11:53:57 +0200
committerBernhard Voelker <mail@bernhard-voelker.de>2013-07-02 11:54:49 +0200
commit64a212cb75f78b60440efeed2de6461ed1f88ae8 (patch)
treeca8debfdaeb3dcb44def17447f957822160affd7 /src
parent5fb93f635b935ea5632e36600e07a2c5fc5bad5e (diff)
downloadcoreutils-64a212cb75f78b60440efeed2de6461ed1f88ae8.tar.xz
mkdir,mkfifo,mknod: give scontext-related variable a better scope
* 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.
Diffstat (limited to 'src')
-rw-r--r--src/mkdir.c11
-rw-r--r--src/mkfifo.c12
-rw-r--r--src/mknod.c12
3 files changed, 18 insertions, 17 deletions
diff --git a/src/mkdir.c b/src/mkdir.c
index 479faca85..efd318497 100644
--- a/src/mkdir.c
+++ b/src/mkdir.c
@@ -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)
{
diff --git a/src/mkfifo.c b/src/mkfifo.c
index f9fcc0a60..4c6dac468 100644
--- a/src/mkfifo.c
+++ b/src/mkfifo.c
@@ -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)
diff --git a/src/mknod.c b/src/mknod.c
index 4fd6ed0f4..c79468c6d 100644
--- a/src/mknod.c
+++ b/src/mknod.c
@@ -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'. */