[libvirt] [PATCH] qemu: update qemuCgroupControllerActive signature
Eric Blake
eblake at redhat.com
Wed May 4 15:36:10 UTC 2011
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 eblake at redhat.com +1-801-349-2682
Libvirt virtualization library http://libvirt.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 619 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20110504/29f0b836/attachment-0001.sig>
More information about the libvir-list
mailing list