Fix uninitialized variable warning in vdev_prop_get()

Update vdev_prop_get_objid() to set objid on error as the comment
in vdev_prop_get() describes.

    "objid is set to 0 when absent and the few cases that call
    zap_lookup directly guard against this below."

This resolves the following possible uninitialized variable warning.

    module/zfs/vdev.c: In function ‘vdev_prop_get’:
    module/zfs/vdev.c:6913:12: error: ‘objid’ may be used uninitialized
    in this function [-Werror=maybe-uninitialized]

Reviewed-by: Alexander Motin <alexander.motin@TrueNAS.com>
Reviewed-by: Tony Hutter <hutter2@llnl.gov>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #18616
This commit is contained in:
Brian Behlendorf
2026-06-02 16:36:38 -07:00
committed by GitHub
parent 0aa4088dce
commit e199f6d98b
+2 -1
View File
@@ -460,6 +460,7 @@ vdev_prop_get_objid(vdev_t *vd, uint64_t *objid)
} else if (vd->vdev_leaf_zap != 0) { } else if (vd->vdev_leaf_zap != 0) {
*objid = vd->vdev_leaf_zap; *objid = vd->vdev_leaf_zap;
} else { } else {
*objid = 0;
return (EINVAL); return (EINVAL);
} }
@@ -6444,7 +6445,7 @@ vdev_prop_get(vdev_t *vd, nvlist_t *innvl, nvlist_t *outnvl)
spa_t *spa = vd->vdev_spa; spa_t *spa = vd->vdev_spa;
objset_t *mos = spa->spa_meta_objset; objset_t *mos = spa->spa_meta_objset;
int err = 0; int err = 0;
uint64_t objid; uint64_t objid = 0;
uint64_t vdev_guid; uint64_t vdev_guid;
nvpair_t *elem = NULL; nvpair_t *elem = NULL;
nvlist_t *nvprops = NULL; nvlist_t *nvprops = NULL;