]> git.ipfire.org Git - thirdparty/libvirt.git/commit
esx: Refactor esxVI_LookupHostScsiTopologyLunListByTargetName
authorJiri Denemark <jdenemar@redhat.com>
Tue, 11 Mar 2025 09:35:58 +0000 (10:35 +0100)
committerJiri Denemark <jdenemar@redhat.com>
Tue, 11 Mar 2025 11:20:21 +0000 (12:20 +0100)
commit477a81fedb0fc5853e0879d3ed60f68becd9ccfa
treecfe822ecbc076d1712aced5ceb673b8e5341f7c6
parentcc33c02ad5f2569860fad73b1d28d54f7c65803d
esx: Refactor esxVI_LookupHostScsiTopologyLunListByTargetName

With a specific combination of compiler options gcc reported the
following bogus warning (I added a context to it to make the issue
visible):

../src/esx/esx_vi.c: In function â€˜esxVI_LookupHostScsiTopologyLunListByTargetName’:
../src/esx/esx_vi.c:4674:32: error: potential null pointer dereference [-Werror=null-dereference]
 4671 |     if (!found || !hostScsiTopologyTarget)
 4672 |         goto cleanup;
 4673 |
 4674 |     if (!hostScsiTopologyTarget->lun) {
      |          ~~~~~~~~~~~~~~~~~~~~~~^~~~~

Most likely this is caused by found and hostScsiTopologyTarget doing
essentially the same thing as found is true if and only if
hostScsiTopologyTarget is non-NULL. The found variable is completely
redundant. Removing it would be enough, but I decided to make the code a
little bit easier to read by not using the iterator variable directly.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
src/esx/esx_vi.c