From e199f6d98b40e37e79aad51f2fad7f1490968ede Mon Sep 17 00:00:00 2001 From: Brian Behlendorf Date: Tue, 2 Jun 2026 16:36:38 -0700 Subject: [PATCH] Fix uninitialized variable warning in vdev_prop_get() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Tony Hutter Signed-off-by: Brian Behlendorf Closes #18616 --- module/zfs/vdev.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/module/zfs/vdev.c b/module/zfs/vdev.c index 91cd9c6dc84..211adae0968 100644 --- a/module/zfs/vdev.c +++ b/module/zfs/vdev.c @@ -460,6 +460,7 @@ vdev_prop_get_objid(vdev_t *vd, uint64_t *objid) } else if (vd->vdev_leaf_zap != 0) { *objid = vd->vdev_leaf_zap; } else { + *objid = 0; return (EINVAL); } @@ -6444,7 +6445,7 @@ vdev_prop_get(vdev_t *vd, nvlist_t *innvl, nvlist_t *outnvl) spa_t *spa = vd->vdev_spa; objset_t *mos = spa->spa_meta_objset; int err = 0; - uint64_t objid; + uint64_t objid = 0; uint64_t vdev_guid; nvpair_t *elem = NULL; nvlist_t *nvprops = NULL;