]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
blockdev-util: let's initialize return parameter on success
authorLennart Poettering <lennart@poettering.net>
Mon, 11 Jun 2018 10:03:35 +0000 (12:03 +0200)
committerLennart Poettering <lennart@poettering.net>
Mon, 11 Jun 2018 15:55:17 +0000 (17:55 +0200)
We document the rule that return values >= 0 of functions are supposed
to indicate success, and that in case of success all return parameters
should be initialized. Let's actually do so.

Just a tiny coding style fix-up.

src/basic/blockdev-util.c
src/basic/btrfs-util.c

index b15b8cf7703c05b24cd8fe489e2d5b1f05bf60a0..6495a7165847121daaf10f4c06ff17543ca241f6 100644 (file)
@@ -81,6 +81,7 @@ int get_block_device(const char *path, dev_t *dev) {
         if (F_TYPE_EQUAL(sfs.f_type, BTRFS_SUPER_MAGIC))
                 return btrfs_get_block_device(path, dev);
 
+        *dev = 0;
         return 0;
 }
 
index 7720d98009f1fdae28b8834b383a53cb4336a7d0..32a022f7ce18f21beaa0f3e9fdefb72d1717c2aa 100644 (file)
@@ -277,8 +277,10 @@ int btrfs_get_block_device_fd(int fd, dev_t *dev) {
                 return -errno;
 
         /* We won't do this for btrfs RAID */
-        if (fsi.num_devices != 1)
+        if (fsi.num_devices != 1) {
+                *dev = 0;
                 return 0;
+        }
 
         for (id = 1; id <= fsi.max_id; id++) {
                 struct btrfs_ioctl_dev_info_args di = {