[libvirt] [PATCH] storage: kill dead stores
Matthias Bolte
matthias.bolte at googlemail.com
Fri Jul 30 18:20:01 UTC 2010
2010/7/30 Eric Blake <eblake at redhat.com>:
> Found by clang. Clang complained that virStorageBackendProbeTarget
> could dereference NULL if backingStoreFormat was NULL, but since all
> callers passed a valid pointer, I added attributes instead of null
> checks.
>
> * src/storage/storage_backend.c
> (virStorageBackendQEMUImgBackingFormat): Kill dead store.
> * src/storage/storage_backend_fs.c (virStorageBackendProbeTarget):
> Likewise. Skip null checks, by adding attributes.
> ---
>
> Thankfully, the null dereference scenario noted by clang was never
> triggered in the code, which is good since it was introduced as
> part of fixing a CVE.
>
> src/storage/storage_backend.c | 3 +--
> src/storage/storage_backend_fs.c | 34 +++++++++++++++-------------------
> 2 files changed, 16 insertions(+), 21 deletions(-)
>
> @@ -75,7 +73,7 @@ virStorageBackendProbeTarget(virStorageVolTargetPtr target,
> allocation,
> capacity)) < 0) {
> close(fd);
> - return -1;
> + return ret;
Why do you return ret here? Doing so doesn't harm but it's not
necessary, virStorageBackendUpdateVolTargetInfoFD returns 0 or -1
only, in contrast to virStorageBackendVolOpenCheckMode that can return
0, -1 or -2.
ACK.
Matthias
More information about the libvir-list
mailing list