[libvirt] [PATCH 1/2] build: remove some dead assignments

No syntactic effect; this merely silences some clang warnings. * src/libxl/libxl_driver.c (libxlDomainSetVcpusFlags): Drop redundant ret=0 statement. * src/qemu/qemu_monitor_text.c (qemuMonitorTextDriveDel): Likewise. --- More clang fallout, found by switching over to rawhide. src/libxl/libxl_driver.c | 1 - src/qemu/qemu_monitor_text.c | 1 - 2 files changed, 0 insertions(+), 2 deletions(-) diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c index dec4f43..5355b57 100644 --- a/src/libxl/libxl_driver.c +++ b/src/libxl/libxl_driver.c @@ -1659,7 +1659,6 @@ libxlDomainSetVcpusFlags(virDomainPtr dom, unsigned int nvcpus, def->maxvcpus = nvcpus; if (nvcpus < def->vcpus) def->vcpus = nvcpus; - ret = 0; break; case VIR_DOMAIN_VCPU_CONFIG: diff --git a/src/qemu/qemu_monitor_text.c b/src/qemu/qemu_monitor_text.c index 53781c8..7ace95f 100644 --- a/src/qemu/qemu_monitor_text.c +++ b/src/qemu/qemu_monitor_text.c @@ -2396,7 +2396,6 @@ int qemuMonitorTextDriveDel(qemuMonitorPtr mon, } else if (STRPREFIX(reply, "Device '") && (strstr(reply, "not found"))) { /* NB: device not found errors mean the drive was auto-deleted and we * ignore the error */ - ret = 0; } else if (STRNEQ(reply, "")) { qemuReportError(VIR_ERR_OPERATION_FAILED, _("deleting %s drive failed: %s"), drivestr, reply); -- 1.7.4.4

If we plow on after udev_device_get_syspath fails, we will hit a NULL dereference. Clang found one due to strdup later in udevSetParent, but in fact we hit a NULL dereference sooner because of the use of STREQ within virNodeDeviceFindBySysfsPath. * src/conf/node_device_conf.h (virNodeDeviceFindBySysfsPath): Mark path argument non-null. * src/node_device/node_device_udev.c (udevSetParent): Avoid null dereference. --- src/conf/node_device_conf.h | 5 +++-- src/node_device/node_device_udev.c | 6 ++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/conf/node_device_conf.h b/src/conf/node_device_conf.h index 975abb3..e90bdc5 100644 --- a/src/conf/node_device_conf.h +++ b/src/conf/node_device_conf.h @@ -1,7 +1,7 @@ /* * node_device_conf.h: config handling for node devices * - * Copyright (C) 2010 Red Hat, Inc. + * Copyright (C) 2010-2011 Red Hat, Inc. * Copyright (C) 2008 Virtual Iron Software, Inc. * Copyright (C) 2008 David F. Lively * @@ -228,7 +228,8 @@ virNodeDeviceObjPtr virNodeDeviceFindByName(const virNodeDeviceObjListPtr devs, const char *name); virNodeDeviceObjPtr virNodeDeviceFindBySysfsPath(const virNodeDeviceObjListPtr devs, - const char *sysfs_path); + const char *sysfs_path) + ATTRIBUTE_NONNULL(2); virNodeDeviceObjPtr virNodeDeviceAssignDef(virNodeDeviceObjListPtr devs, const virNodeDeviceDefPtr def); diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_device_udev.c index 8cf0e82..9cca375 100644 --- a/src/node_device/node_device_udev.c +++ b/src/node_device/node_device_udev.c @@ -1236,8 +1236,10 @@ static int udevSetParent(struct udev_device *device, parent_sysfs_path = udev_device_get_syspath(parent_device); if (parent_sysfs_path == NULL) { - VIR_DEBUG("Could not get syspath for parent of '%s'", - udev_device_get_syspath(parent_device)); + virNodeDeviceReportError(VIR_ERR_INTERNAL_ERROR, + _("Could not get syspath for parent of '%s'"), + udev_device_get_syspath(parent_device)); + goto out; } dev = virNodeDeviceFindBySysfsPath(&driverState->devs, -- 1.7.4.4

On 05/04/2011 07:37 PM, Eric Blake wrote:
If we plow on after udev_device_get_syspath fails, we will hit a NULL dereference. Clang found one due to strdup later in udevSetParent, but in fact we hit a NULL dereference sooner because of the use of STREQ within virNodeDeviceFindBySysfsPath.
* src/conf/node_device_conf.h (virNodeDeviceFindBySysfsPath): Mark path argument non-null. * src/node_device/node_device_udev.c (udevSetParent): Avoid null dereference. --- src/conf/node_device_conf.h | 5 +++-- src/node_device/node_device_udev.c | 6 ++++-- 2 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/src/conf/node_device_conf.h b/src/conf/node_device_conf.h index 975abb3..e90bdc5 100644 --- a/src/conf/node_device_conf.h +++ b/src/conf/node_device_conf.h @@ -1,7 +1,7 @@ /* * node_device_conf.h: config handling for node devices * - * Copyright (C) 2010 Red Hat, Inc. + * Copyright (C) 2010-2011 Red Hat, Inc. * Copyright (C) 2008 Virtual Iron Software, Inc. * Copyright (C) 2008 David F. Lively * @@ -228,7 +228,8 @@ virNodeDeviceObjPtr virNodeDeviceFindByName(const virNodeDeviceObjListPtr devs, const char *name); virNodeDeviceObjPtr virNodeDeviceFindBySysfsPath(const virNodeDeviceObjListPtr devs, - const char *sysfs_path); + const char *sysfs_path) + ATTRIBUTE_NONNULL(2);
virNodeDeviceObjPtr virNodeDeviceAssignDef(virNodeDeviceObjListPtr devs, const virNodeDeviceDefPtr def); diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_device_udev.c index 8cf0e82..9cca375 100644 --- a/src/node_device/node_device_udev.c +++ b/src/node_device/node_device_udev.c @@ -1236,8 +1236,10 @@ static int udevSetParent(struct udev_device *device,
parent_sysfs_path = udev_device_get_syspath(parent_device); if (parent_sysfs_path == NULL) { - VIR_DEBUG("Could not get syspath for parent of '%s'", - udev_device_get_syspath(parent_device)); + virNodeDeviceReportError(VIR_ERR_INTERNAL_ERROR, + _("Could not get syspath for parent of '%s'"), + udev_device_get_syspath(parent_device)); + goto out; }
dev = virNodeDeviceFindBySysfsPath(&driverState->devs,
ACK.

On 05/11/2011 10:26 AM, Laine Stump wrote:
On 05/04/2011 07:37 PM, Eric Blake wrote:
If we plow on after udev_device_get_syspath fails, we will hit a NULL dereference. Clang found one due to strdup later in udevSetParent, but in fact we hit a NULL dereference sooner because of the use of STREQ within virNodeDeviceFindBySysfsPath.
* src/conf/node_device_conf.h (virNodeDeviceFindBySysfsPath): Mark path argument non-null. * src/node_device/node_device_udev.c (udevSetParent): Avoid null dereference.
ACK.
Thanks; pushed. -- Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org

On 05/04/2011 07:37 PM, Eric Blake wrote:
No syntactic effect; this merely silences some clang warnings.
* src/libxl/libxl_driver.c (libxlDomainSetVcpusFlags): Drop redundant ret=0 statement. * src/qemu/qemu_monitor_text.c (qemuMonitorTextDriveDel): Likewise. ---
More clang fallout, found by switching over to rawhide.
src/libxl/libxl_driver.c | 1 - src/qemu/qemu_monitor_text.c | 1 - 2 files changed, 0 insertions(+), 2 deletions(-)
ACK.
diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c index dec4f43..5355b57 100644 --- a/src/libxl/libxl_driver.c +++ b/src/libxl/libxl_driver.c @@ -1659,7 +1659,6 @@ libxlDomainSetVcpusFlags(virDomainPtr dom, unsigned int nvcpus, def->maxvcpus = nvcpus; if (nvcpus< def->vcpus) def->vcpus = nvcpus; - ret = 0; break;
case VIR_DOMAIN_VCPU_CONFIG: diff --git a/src/qemu/qemu_monitor_text.c b/src/qemu/qemu_monitor_text.c index 53781c8..7ace95f 100644 --- a/src/qemu/qemu_monitor_text.c +++ b/src/qemu/qemu_monitor_text.c @@ -2396,7 +2396,6 @@ int qemuMonitorTextDriveDel(qemuMonitorPtr mon, } else if (STRPREFIX(reply, "Device '")&& (strstr(reply, "not found"))) { /* NB: device not found errors mean the drive was auto-deleted and we * ignore the error */ - ret = 0; } else if (STRNEQ(reply, "")) { qemuReportError(VIR_ERR_OPERATION_FAILED, _("deleting %s drive failed: %s"), drivestr, reply);

On 05/11/2011 10:25 AM, Laine Stump wrote:
On 05/04/2011 07:37 PM, Eric Blake wrote:
No syntactic effect; this merely silences some clang warnings.
* src/libxl/libxl_driver.c (libxlDomainSetVcpusFlags): Drop redundant ret=0 statement. * src/qemu/qemu_monitor_text.c (qemuMonitorTextDriveDel): Likewise. ---
More clang fallout, found by switching over to rawhide.
src/libxl/libxl_driver.c | 1 - src/qemu/qemu_monitor_text.c | 1 - 2 files changed, 0 insertions(+), 2 deletions(-)
ACK.
Thanks; pushed. -- Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org
participants (2)
-
Eric Blake
-
Laine Stump