[libvirt] [PATCH 06/11] storage_scsi: Don't ignore the return value of VIR_STRDUP
John Ferlan
jferlan at redhat.com
Wed Jun 19 15:40:54 UTC 2013
On 06/07/2013 01:03 PM, Osier Yang wrote:
> ---
> src/storage/storage_backend_scsi.c | 10 ++++++++--
> 1 file changed, 8 insertions(+), 2 deletions(-)
>
ACK, but probably is something that doesn't need to be in this series or
done at all since the changes don't affect code paths...
John
> diff --git a/src/storage/storage_backend_scsi.c b/src/storage/storage_backend_scsi.c
> index 0a79e6c..13c498d 100644
> --- a/src/storage/storage_backend_scsi.c
> +++ b/src/storage/storage_backend_scsi.c
> @@ -188,7 +188,12 @@ virStorageBackendSCSISerial(const char *dev)
> *nl = '\0';
> } else {
> VIR_FREE(serial);
> - ignore_value(VIR_STRDUP(serial, dev));
> + if (VIR_STRDUP(serial, dev) < 0)
> +#ifdef WITH_UDEV
> + goto cleanup;
> +#else
> + return NULL;
> +#endif
> }
if you expand the scope of this - the next line is the cleanup: label
inside the WITH_UDEV ifdef, so in reality this does nothing since serial
is returned immediately thereafter and would be NULL when the return is < 0.
>
> #ifdef WITH_UDEV
> @@ -624,7 +629,8 @@ getAdapterName(virStoragePoolSourceAdapter adapter)
> char *name = NULL;
>
> if (adapter.type != VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_FC_HOST) {
> - ignore_value(VIR_STRDUP(name, adapter.data.scsi_host.name));
> + if (VIR_STRDUP(name, adapter.data.scsi_host.name) < 0)
> + return NULL;
This one is another unnecessary check since NULL would be the value of
name if the return value < 0
> return name;
> }
>
>
More information about the libvir-list
mailing list