[libvirt] [PATCH] libvirt: hostdev SCSI AdapterId retrieval fix

Fixed the retrieval of the AdapterId from the AdapterName of the hostdev source so it does return an error instead of leaving the adapter_id uninitialized. Signed-off-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com> Reviewed-by: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com> --- src/util/virscsi.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/src/util/virscsi.c b/src/util/virscsi.c index 43658c0..7aca9e6 100644 --- a/src/util/virscsi.c +++ b/src/util/virscsi.c @@ -88,16 +88,13 @@ static int virSCSIDeviceGetAdapterId(const char *adapter, unsigned int *adapter_id) { - if (STRPREFIX(adapter, "scsi_host")) { - if (virStrToLong_ui(adapter + strlen("scsi_host"), - NULL, 0, adapter_id) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Cannot parse adapter '%s'"), adapter); - return -1; - } - } - - return 0; + if (STRPREFIX(adapter, "scsi_host") && + virStrToLong_ui(adapter + strlen("scsi_host"), + NULL, 0, adapter_id) == 0) + return 0; + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Cannot parse adapter '%s'"), adapter); + return -1; } char * -- 1.8.3.1

On 30.09.2013 13:20, Boris Fiuczynski wrote:
Fixed the retrieval of the AdapterId from the AdapterName of the hostdev source so it does return an error instead of leaving the adapter_id uninitialized.
Signed-off-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com> Reviewed-by: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com> --- src/util/virscsi.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-)
diff --git a/src/util/virscsi.c b/src/util/virscsi.c index 43658c0..7aca9e6 100644 --- a/src/util/virscsi.c +++ b/src/util/virscsi.c @@ -88,16 +88,13 @@ static int virSCSIDeviceGetAdapterId(const char *adapter, unsigned int *adapter_id) { - if (STRPREFIX(adapter, "scsi_host")) { - if (virStrToLong_ui(adapter + strlen("scsi_host"), - NULL, 0, adapter_id) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Cannot parse adapter '%s'"), adapter); - return -1; - } - } - - return 0; + if (STRPREFIX(adapter, "scsi_host") && + virStrToLong_ui(adapter + strlen("scsi_host"), + NULL, 0, adapter_id) == 0) + return 0; + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Cannot parse adapter '%s'"), adapter); + return -1; }
char *
ACK, but I had some difficulties applying this patch. Have you edited it before sending or did you e-mail client mangle it? The context must have exactly one space in prefix, not two. Michal

Michal, I am sorry about that. Had some trouble sending the patch. Do you want me to resend it with a none-mangling email client? On 09/30/2013 03:14 PM, Michal Privoznik wrote:
On 30.09.2013 13:20, Boris Fiuczynski wrote:
Fixed the retrieval of the AdapterId from the AdapterName of the hostdev source so it does return an error instead of leaving the adapter_id uninitialized.
Signed-off-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com> Reviewed-by: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com> --- src/util/virscsi.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-)
diff --git a/src/util/virscsi.c b/src/util/virscsi.c index 43658c0..7aca9e6 100644 --- a/src/util/virscsi.c +++ b/src/util/virscsi.c @@ -88,16 +88,13 @@ static int virSCSIDeviceGetAdapterId(const char *adapter, unsigned int *adapter_id) { - if (STRPREFIX(adapter, "scsi_host")) { - if (virStrToLong_ui(adapter + strlen("scsi_host"), - NULL, 0, adapter_id) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Cannot parse adapter '%s'"), adapter); - return -1; - } - } - - return 0; + if (STRPREFIX(adapter, "scsi_host") && + virStrToLong_ui(adapter + strlen("scsi_host"), + NULL, 0, adapter_id) == 0) + return 0; + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Cannot parse adapter '%s'"), adapter); + return -1; }
char *
ACK, but I had some difficulties applying this patch. Have you edited it before sending or did you e-mail client mangle it? The context must have exactly one space in prefix, not two.
Michal
-- Mit freundlichen Grüßen/Kind regards Boris Fiuczynski IBM Deutschland Research & Development GmbH Vorsitzender des Aufsichtsrats: Martina Köderitz Geschäftsführung: Dirk Wittkopp Sitz der Gesellschaft: Böblingen Registergericht: Amtsgericht Stuttgart, HRB 243294

On 01.10.2013 09:57, Boris Fiuczynski wrote:
Michal, I am sorry about that. Had some trouble sending the patch. Do you want me to resend it with a none-mangling email client?
No, the patch is already pushed. But just for the future: you can use 'git send-email' to send not mangled patches. Michal
participants (2)
-
Boris Fiuczynski
-
Michal Privoznik