From: Mike Yuan Date: Wed, 13 Sep 2023 04:48:44 +0000 (+0800) Subject: tree-wide: explicitly compare return value of fd_is_fs_type with 0 X-Git-Tag: v255-rc1~480^2~2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=79de6eb1a7a2d46b3a582fae4b66315246598c0c;p=thirdparty%2Fsystemd.git tree-wide: explicitly compare return value of fd_is_fs_type with 0 According to our coding style. --- diff --git a/src/creds/creds.c b/src/creds/creds.c index 0bc55a36d20..101e5abf9be 100644 --- a/src/creds/creds.c +++ b/src/creds/creds.c @@ -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); diff --git a/src/libsystemd/sd-journal/journal-file.c b/src/libsystemd/sd-journal/journal-file.c index 95cf25bff00..3aa6985b375 100644 --- a/src/libsystemd/sd-journal/journal-file.c +++ b/src/libsystemd/sd-journal/journal-file.c @@ -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); diff --git a/src/shared/btrfs-util.c b/src/shared/btrfs-util.c index d91c69b6241..e61e5f31f58 100644 --- a/src/shared/btrfs-util.c +++ b/src/shared/btrfs-util.c @@ -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; } diff --git a/src/shared/discover-image.c b/src/shared/discover-image.c index d93a1cc74c2..f94fac1b410 100644 --- a/src/shared/discover-image.c +++ b/src/shared/discover-image.c @@ -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 */