]> granicus.if.org Git - strace/commitdiff
filter: remove redundant braces around single line expressions
authorDmitry V. Levin <ldv@altlinux.org>
Sun, 14 Jan 2018 14:00:53 +0000 (14:00 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Mon, 15 Jan 2018 16:23:54 +0000 (16:23 +0000)
* basic_filters.c (qualify_syscall_class, qualify_syscall_name):
Rearrange the inner loop body.
(qualify_syscall_number, lookup_class, qualify_syscall_tokens,
qualify_tokens): Remove redundant braces around single line expressions.
* filter_qualify.c (qualify_inject_common): Likewise.

basic_filters.c
filter_qualify.c

index 7b7f0a545753229cccc6ca78cec784177d00e6c1..ca17f7fc00621a65c6a546ce17a0e7522e8f64f0 100644 (file)
@@ -42,9 +42,8 @@ qualify_syscall_number(const char *s, struct number_set *set)
        bool done = false;
 
        for (p = 0; p < SUPPORTED_PERSONALITIES; ++p) {
-               if ((unsigned) n >= nsyscall_vec[p]) {
+               if ((unsigned) n >= nsyscall_vec[p])
                        continue;
-               }
                add_number_to_set_array(n, set, p);
                done = true;
        }
@@ -126,9 +125,8 @@ lookup_class(const char *s)
 
        unsigned int i;
        for (i = 0; i < ARRAY_SIZE(syscall_class); ++i) {
-               if (strcmp(s, syscall_class[i].name) == 0) {
+               if (strcmp(s, syscall_class[i].name) == 0)
                        return syscall_class[i].value;
-               }
        }
 
        return 0;
@@ -146,11 +144,9 @@ qualify_syscall_class(const char *s, struct number_set *set)
                unsigned int i;
 
                for (i = 0; i < nsyscall_vec[p]; ++i) {
-                       if (!sysent_vec[p][i].sys_name
-                           || (sysent_vec[p][i].sys_flags & n) != n) {
-                               continue;
-                       }
-                       add_number_to_set_array(i, set, p);
+                       if (sysent_vec[p][i].sys_name &&
+                           (sysent_vec[p][i].sys_flags & n) == n)
+                               add_number_to_set_array(i, set, p);
                }
        }
 
@@ -167,12 +163,11 @@ qualify_syscall_name(const char *s, struct number_set *set)
                unsigned int i;
 
                for (i = 0; i < nsyscall_vec[p]; ++i) {
-                       if (!sysent_vec[p][i].sys_name
-                           || strcmp(s, sysent_vec[p][i].sys_name)) {
-                               continue;
+                       if (sysent_vec[p][i].sys_name &&
+                           strcmp(s, sysent_vec[p][i].sys_name) == 0) {
+                               add_number_to_set_array(i, set, p);
+                               found = true;
                        }
-                       add_number_to_set_array(i, set, p);
-                       found = true;
                }
        }
 
@@ -246,16 +241,14 @@ handle_inversion:
        for (token = strtok_r(copy, ",", &saveptr); token;
             token = strtok_r(NULL, ",", &saveptr)) {
                done = qualify_syscall(token, set);
-               if (!done) {
+               if (!done)
                        error_msg_and_die("invalid %s '%s'", name, token);
-               }
        }
 
        free(copy);
 
-       if (!done) {
+       if (!done)
                error_msg_and_die("invalid %s '%s'", name, str);
-       }
 }
 
 /*
@@ -306,16 +299,14 @@ handle_inversion:
        for (token = strtok_r(copy, ",", &saveptr); token;
             token = strtok_r(NULL, ",", &saveptr)) {
                number = func(token);
-               if (number < 0) {
+               if (number < 0)
                        error_msg_and_die("invalid %s '%s'", name, token);
-               }
 
                add_number_to_set(number, set);
        }
 
        free(copy);
 
-       if (number < 0) {
+       if (number < 0)
                error_msg_and_die("invalid %s '%s'", name, str);
-       }
 }
index 1bfcd86b8c98857ba2395bfba814f390a6535c00..362857fb6758cfaeff5d2b66c6e2817bb0fc8063 100644 (file)
@@ -241,9 +241,8 @@ qualify_inject_common(const char *const str,
        };
        char *copy = xstrdup(str);
        char *name = parse_inject_expression(copy, &opts, fault_tokens_only);
-       if (!name) {
+       if (!name)
                error_msg_and_die("invalid %s '%s'", description, str);
-       }
 
        /* If neither of retval, error, or signal is specified, then ... */
        if (!opts.data.flags) {
@@ -264,7 +263,7 @@ qualify_inject_common(const char *const str,
        free(copy);
 
        /*
-        * Initialize inject_vec accourding to tmp_set.
+        * Initialize inject_vec according to tmp_set.
         * Merge tmp_set into inject_set.
         */
        unsigned int p;
@@ -278,7 +277,7 @@ qualify_inject_common(const char *const str,
                }
                if (!inject_vec[p]) {
                        inject_vec[p] = xcalloc(nsyscall_vec[p],
-                                              sizeof(*inject_vec[p]));
+                                               sizeof(*inject_vec[p]));
                }
 
                unsigned int i;