On 05/03/2011 11:02 PM, Laine Stump wrote:
> On 05/03/2011 04:22 PM, Eric Blake wrote:
>> Clang warned about a dead assignment. In the process, I noticed
>> that we are only using the function for a bool value. I audited
>> all other callers in qemu_{migration,cgroup,driver,hotplug), and
>> all were making the call in a bool context.
>>
>> +bool qemuCgroupControllerActive(struct qemud_driver *driver,
>> + int controller)
>> {
>> if (driver->cgroup == NULL)
>> - return 0;
>> + return false;
>> if (!virCgroupMounted(driver->cgroup, controller))
>> - return 0;
>> + return false;
>> if (driver->cgroupControllers& (1<< controller))
Undefined behavior if controller is out of range.
>
> ACK.
I pushed with this squashed in:
diff --git i/src/qemu/qemu_cgroup.c w/src/qemu/qemu_cgroup.c
index ac1c016..6f075fb 100644
--- i/src/qemu/qemu_cgroup.c
+++ w/src/qemu/qemu_cgroup.c
@@ -50,6 +50,8 @@ bool qemuCgroupControllerActive(struct qemud_driver
*driver,
return false;
if (!virCgroupMounted(driver->cgroup, controller))
return false;
+ if (controller < 0 || controller >= VIR_CGROUP_CONTROLLER_LAST)
+ return false;
if (driver->cgroupControllers & (1 << controller))
return true;
return false;
--
Eric Blake [email protected] +1-801-349-2682
Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature
-- libvir-list mailing list [email protected] https://www.redhat.com/mailman/listinfo/libvir-list
