]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
basic/filesystems: fs_in_group() returns a boolean
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Sun, 6 Nov 2022 17:41:48 +0000 (18:41 +0100)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 8 Nov 2022 17:21:10 +0000 (18:21 +0100)
is_{temporary,network}_fs() looked like they are incorrectly casting an error
to true, but actually the return type is misdeclared.

src/basic/filesystems.c
src/basic/filesystems.h

index 0f71f8e07cdca294938cae9fa75314bdea492269..b11cbb9d65a1c417be269878d3a4e423e269547a 100644 (file)
@@ -27,7 +27,7 @@ int fs_type_from_string(const char *name, const statfs_f_type_t **ret) {
         return 0;
 }
 
-int fs_in_group(const struct statfs *s, FilesystemGroups fs_group) {
+bool fs_in_group(const struct statfs *s, FilesystemGroups fs_group) {
         const char *fs;
         int r;
 
@@ -35,7 +35,7 @@ int fs_in_group(const struct statfs *s, FilesystemGroups fs_group) {
                 const statfs_f_type_t *magic;
 
                 r = fs_type_from_string(fs, &magic);
-                if (r == 0) {
+                if (r >= 0)
                         for (size_t i = 0; i < FILESYSTEM_MAGIC_MAX; i++) {
                                 if (magic[i] == 0)
                                         break;
@@ -43,7 +43,6 @@ int fs_in_group(const struct statfs *s, FilesystemGroups fs_group) {
                                 if (is_fs_type(s, magic[i]))
                                         return true;
                         }
-                }
         }
 
         return false;
index 6d07a97ba7c79206f5468e53ec2f514491c73090..f9edbc1f292e35684810f47643b4afaa0ebd5732 100644 (file)
@@ -36,7 +36,7 @@ const FilesystemSet *filesystem_set_find(const char *name);
 
 const char *fs_type_to_string(statfs_f_type_t magic);
 int fs_type_from_string(const char *name, const statfs_f_type_t **ret);
-int fs_in_group(const struct statfs *s, enum FilesystemGroups fs_group);
+bool fs_in_group(const struct statfs *s, enum FilesystemGroups fs_group);
 
 /* gperf prototypes */
 const struct FilesystemMagic* filesystems_gperf_lookup(const char *key, GPERF_LEN_TYPE length);