chsmack: exchanging order of nested blocks if/for
authorJosé Bollo <jose.bollo@open.eurogiciel.org>
Tue, 10 Dec 2013 13:46:18 +0000 (14:46 +0100)
committerJosé Bollo <jose.bollo@open.eurogiciel.org>
Tue, 17 Dec 2013 11:01:26 +0000 (12:01 +0100)
Prepare to add the removing of labels and also reduce
the count of tests.

Signed-off-by: José Bollo <jose.bollo@open.eurogiciel.org>
utils/chsmack.c

index a41bd96..c255c36 100644 (file)
@@ -158,8 +158,9 @@ int main(int argc, char *argv[])
                option_flag = 1;
        }
 
-       for (i = optind; i < argc; i++) {
-               if (option_flag) {
+       /* setting labels */
+       if (option_flag) {
+               for (i = optind; i < argc; i++) {
                        if (strlen(access_buf) > 0) {
                                rc = smack_set_label_for_path(argv[i],
                                                        XATTR_NAME_SMACK, 0, access_buf);
@@ -187,7 +188,13 @@ int main(int argc, char *argv[])
                                if (rc < 0)
                                        perror(argv[i]);
                        }
-               } else {
+               }
+       } 
+
+       /* listing labels */
+       else {
+               for (i = optind; i < argc; i++) {
+
                        /* Print file path. */
                        printf("%s", argv[i]);