]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
tree-wide: coccinelle fixes 17230/head
authorFrantisek Sumsal <frantisek@sumsal.cz>
Sun, 4 Oct 2020 09:29:23 +0000 (11:29 +0200)
committerFrantisek Sumsal <frantisek@sumsal.cz>
Sun, 4 Oct 2020 10:32:21 +0000 (12:32 +0200)
src/basic/rm-rf.c
src/core/unit.c
src/libsystemd-network/sd-dhcp-lease.c
src/libsystemd-network/sd-dhcp6-client.c
src/shared/calendarspec.c
src/shared/chown-recursive.c
src/test/test-namespace.c
src/udev/scsi_id/scsi_id.c

index 01ff6bb331fd277d6c7de18eb35f5ea88257c52b..ab331cd677ac2207580198a42978f23838a59149 100644 (file)
@@ -45,7 +45,7 @@ static int unlinkat_harder(
                 return -errno;
         if (!S_ISDIR(st.st_mode))
                 return -ENOTDIR;
-        if ((st.st_mode & 0700) == 0700) /* Already set? */
+        if (FLAGS_SET(st.st_mode, 0700)) /* Already set? */
                 return -EACCES; /* original error */
         if (st.st_uid != geteuid())  /* this only works if the UID matches ours */
                 return -EACCES;
index c3d7d24eccdf369ff9301836d6b8977596f0d841..43373f35d4e1dbfdab936d2807406853f339bdc5 100644 (file)
@@ -5502,7 +5502,7 @@ void unit_remove_dependencies(Unit *u, UnitDependencyMask mask) {
                         done = true;
 
                         HASHMAP_FOREACH_KEY(di.data, other, u->dependencies[d]) {
-                                if ((di.origin_mask & ~mask) == di.origin_mask)
+                                if (FLAGS_SET(~mask, di.origin_mask))
                                         continue;
                                 di.origin_mask &= ~mask;
                                 unit_update_dependency_mask(u, d, other, di);
@@ -5516,7 +5516,7 @@ void unit_remove_dependencies(Unit *u, UnitDependencyMask mask) {
                                         UnitDependencyInfo dj;
 
                                         dj.data = hashmap_get(other->dependencies[q], u);
-                                        if ((dj.destination_mask & ~mask) == dj.destination_mask)
+                                        if (FLAGS_SET(~mask, dj.destination_mask))
                                                 continue;
                                         dj.destination_mask &= ~mask;
 
index 0bc5fa321018da09e37dbdee413d9b6471506c77..83e1b902916ad1e4ac87280ddf420bf8c47316f1 100644 (file)
@@ -779,7 +779,7 @@ int dhcp_lease_parse_search_domains(const uint8_t *option, size_t len, char ***d
                                         return r;
 
                                 n += r;
-                        } else if ((c & 0xc0) == 0xc0) {
+                        } else if (FLAGS_SET(c, 0xc0)) {
                                 /* Pointer */
 
                                 uint8_t d;
index 6bbc23f131f0093c7a1b86b748f5b44d6b6d1408..38025b63d92ce7439d8f1551c37444760d3a5422 100644 (file)
@@ -270,7 +270,7 @@ static int dhcp6_client_set_duid_internal(
         assert_return(duid_len == 0 || duid != NULL, -EINVAL);
         assert_return(IN_SET(client->state, DHCP6_STATE_STOPPED), -EBUSY);
 
-        if (duid != NULL) {
+        if (duid) {
                 r = dhcp_validate_duid_len(duid_type, duid_len, true);
                 if (r < 0) {
                         r = dhcp_validate_duid_len(duid_type, duid_len, false);
index db6a103c42a74ed382359a1e32fba5795efcb63c..bcc51f973c9054d5a3019fab07b11e527486d296 100644 (file)
@@ -363,7 +363,7 @@ int calendar_spec_to_string(const CalendarSpec *c, char **p) {
 
         if (c->utc)
                 fputs(" UTC", f);
-        else if (c->timezone != NULL) {
+        else if (c->timezone) {
                 fputc(' ', f);
                 fputs(c->timezone, f);
         } else if (IN_SET(c->dst, 0, 1)) {
index 636c0e2a7fdbf9a1ecb0d86639dba669e533cd84..cb75d9a11bdf453bd06d5360837626040043fd03 100644 (file)
@@ -124,7 +124,7 @@ int path_chown_recursive(
         if (fd < 0)
                 return -errno;
 
-        if (!uid_is_valid(uid) && !gid_is_valid(gid) && (mask & 07777) == 07777)
+        if (!uid_is_valid(uid) && !gid_is_valid(gid) && FLAGS_SET(mask, 07777))
                 return 0; /* nothing to do */
 
         if (fstat(fd, &st) < 0)
@@ -160,7 +160,7 @@ int fd_chown_recursive(
         if (!S_ISDIR(st.st_mode))
                 return -ENOTDIR;
 
-        if (!uid_is_valid(uid) && !gid_is_valid(gid) && (mask & 07777) == 07777)
+        if (!uid_is_valid(uid) && !gid_is_valid(gid) && FLAGS_SET(mask, 07777))
                 return 0; /* nothing to do */
 
         /* Shortcut, as above */
index 397220732985fa89736181124509407cbe5e5609..7571e609a26fe8236a4c691881b00a9a6c91a9ca 100644 (file)
@@ -46,7 +46,7 @@ static void test_tmpdir(const char *id, const char *A, const char *B) {
                 c = strjoina(a, "/tmp");
                 assert_se(stat(c, &x) >= 0);
                 assert_se(S_ISDIR(x.st_mode));
-                assert_se((x.st_mode & 01777) == 01777);
+                assert_se(FLAGS_SET(x.st_mode, 01777));
                 assert_se(rmdir(c) >= 0);
                 assert_se(rmdir(a) >= 0);
         }
@@ -57,7 +57,7 @@ static void test_tmpdir(const char *id, const char *A, const char *B) {
                 d = strjoina(b, "/tmp");
                 assert_se(stat(d, &y) >= 0);
                 assert_se(S_ISDIR(y.st_mode));
-                assert_se((y.st_mode & 01777) == 01777);
+                assert_se(FLAGS_SET(y.st_mode, 01777));
                 assert_se(rmdir(d) >= 0);
                 assert_se(rmdir(b) >= 0);
         }
index bb08da28b52273fbe1ddcc80a51c3f5e8a4bd3cd..9c33a560a8ccbfc0dc3f1399f36be8fd5e1d5501 100644 (file)
@@ -236,7 +236,7 @@ static int get_file_options(const char *vendor, const char *model,
                         retval = -1;
                         break;
                 }
-                if (vendor == NULL) {
+                if (!vendor) {
                         if (!vendor_in)
                                 break;
                 } else if (vendor_in &&