]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
tree-wide: explicitly compare return value of fd_is_fs_type with 0
authorMike Yuan <me@yhndnzj.com>
Wed, 13 Sep 2023 04:48:44 +0000 (12:48 +0800)
committerMike Yuan <me@yhndnzj.com>
Tue, 19 Sep 2023 13:45:27 +0000 (21:45 +0800)
According to our coding style.

src/creds/creds.c
src/libsystemd/sd-journal/journal-file.c
src/shared/btrfs-util.c
src/shared/discover-image.c

index 0bc55a36d208cd99157f331b9665d3ea9de120f7..101e5abf9be39e2732780de0389301502a7eb5ab 100644 (file)
@@ -181,8 +181,8 @@ static int add_credentials_to_table(Table *t, bool encrypted) {
                         if (r < 0)
                                 return log_error_errno(r, "Failed to determine backing file system of '%s': %m", de->d_name);
 
-                        secure = r ? "secure" : "weak"; /* ramfs is not swappable, hence "secure", everything else is "weak" */
-                        secure_color = r ? ansi_highlight_green() : ansi_highlight_yellow4();
+                        secure = r > 0 ? "secure" : "weak"; /* ramfs is not swappable, hence "secure", everything else is "weak" */
+                        secure_color = r > 0 ? ansi_highlight_green() : ansi_highlight_yellow4();
                 }
 
                 j = path_join(prefix, de->d_name);
index 95cf25bff00264672e1d626657bbf57bd0d428ba..3aa6985b375d61da0ebd8c578ecff781e8184bb6 100644 (file)
@@ -3792,7 +3792,7 @@ static int journal_file_warn_btrfs(JournalFile *f) {
         r = fd_is_fs_type(f->fd, BTRFS_SUPER_MAGIC);
         if (r < 0)
                 return log_ratelimit_warning_errno(r, JOURNAL_LOG_RATELIMIT, "Failed to determine if journal is on btrfs: %m");
-        if (!r)
+        if (r == 0)
                 return 0;
 
         r = read_attr_fd(f->fd, &attrs);
index d91c69b624147e33ba46438ea1d2d35364a1b581..e61e5f31f581a43b7a964af556b35e0dc95754de 100644 (file)
@@ -120,7 +120,7 @@ int btrfs_get_block_device_at(int dir_fd, const char *path, dev_t *ret) {
         r = fd_is_fs_type(fd, BTRFS_SUPER_MAGIC);
         if (r < 0)
                 return r;
-        if (!r)
+        if (r == 0)
                 return -ENOTTY;
 
         if (ioctl(fd, BTRFS_IOC_FS_INFO, &fsi) < 0)
@@ -182,7 +182,7 @@ int btrfs_subvol_get_id_fd(int fd, uint64_t *ret) {
         r = fd_is_fs_type(fd, BTRFS_SUPER_MAGIC);
         if (r < 0)
                 return r;
-        if (!r)
+        if (r == 0)
                 return -ENOTTY;
 
         if (ioctl(fd, BTRFS_IOC_INO_LOOKUP, &args) < 0)
@@ -302,7 +302,7 @@ int btrfs_subvol_get_info_fd(int fd, uint64_t subvol_id, BtrfsSubvolInfo *ret) {
                 r = fd_is_fs_type(fd, BTRFS_SUPER_MAGIC);
                 if (r < 0)
                         return r;
-                if (!r)
+                if (r == 0)
                         return -ENOTTY;
         }
 
@@ -393,7 +393,7 @@ int btrfs_qgroup_get_quota_fd(int fd, uint64_t qgroupid, BtrfsQuotaInfo *ret) {
                 r = fd_is_fs_type(fd, BTRFS_SUPER_MAGIC);
                 if (r < 0)
                         return r;
-                if (!r)
+                if (r == 0)
                         return -ENOTTY;
         }
 
@@ -610,7 +610,7 @@ int btrfs_quota_enable_fd(int fd, bool b) {
         r = fd_is_fs_type(fd, BTRFS_SUPER_MAGIC);
         if (r < 0)
                 return r;
-        if (!r)
+        if (r == 0)
                 return -ENOTTY;
 
         return RET_NERRNO(ioctl(fd, BTRFS_IOC_QUOTA_CTL, &args));
@@ -644,7 +644,7 @@ int btrfs_qgroup_set_limit_fd(int fd, uint64_t qgroupid, uint64_t referenced_max
                 r = fd_is_fs_type(fd, BTRFS_SUPER_MAGIC);
                 if (r < 0)
                         return r;
-                if (!r)
+                if (r == 0)
                         return -ENOTTY;
         }
 
@@ -1071,7 +1071,7 @@ int btrfs_qgroup_copy_limits(int fd, uint64_t old_qgroupid, uint64_t new_qgroupi
         r = fd_is_fs_type(fd, BTRFS_SUPER_MAGIC);
         if (r < 0)
                 return r;
-        if (!r)
+        if (r == 0)
                 return -ENOTTY;
 
         while (btrfs_ioctl_search_args_compare(&args) <= 0) {
@@ -1575,7 +1575,7 @@ int btrfs_qgroup_find_parents(int fd, uint64_t qgroupid, uint64_t **ret) {
                 r = fd_is_fs_type(fd, BTRFS_SUPER_MAGIC);
                 if (r < 0)
                         return r;
-                if (!r)
+                if (r == 0)
                         return -ENOTTY;
         }
 
@@ -1822,7 +1822,7 @@ int btrfs_subvol_get_parent(int fd, uint64_t subvol_id, uint64_t *ret) {
                 r = fd_is_fs_type(fd, BTRFS_SUPER_MAGIC);
                 if (r < 0)
                         return r;
-                if (!r)
+                if (r == 0)
                         return -ENOTTY;
         }
 
index d93a1cc74c2cfec74175cb31bc58edeee8738122..f94fac1b4102f5942e3d1184c8f062b83f08fb61 100644 (file)
@@ -298,7 +298,7 @@ static int image_make(
                         r = fd_is_fs_type(fd, BTRFS_SUPER_MAGIC);
                         if (r < 0)
                                 return r;
-                        if (r) {
+                        if (r > 0) {
                                 BtrfsSubvolInfo info;
 
                                 /* It's a btrfs subvolume */