On 06.10.2016 17:42, Daniel P. Berrange wrote:
On Thu, Oct 06, 2016 at 05:18:11PM +0200, Pavel Hrdina wrote:
> On Thu, Oct 06, 2016 at 04:58:40PM +0200, Michal Privoznik wrote:
>> Pids are signed, report them as such.
>>
>> Before:
>> Detected mount/mapping 2:cpuset at /sys/fs/cgroup/cpuset in
/machine/qemu-4-fedora.libvirt-qemu/vcpu0 for pid 18446744073709551615
>>
>> After:
>> Detected mount/mapping 2:cpuset at /sys/fs/cgroup/cpuset in
/machine/qemu-4-fedora.libvirt-qemu/vcpu0 for pid -1
>>
>> Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
>> ---
>> src/util/vircgroup.c | 5 +++--
>> 1 file changed, 3 insertions(+), 2 deletions(-)
>>
>> diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c
>> index 8b52816..0a06a8a 100644
>> --- a/src/util/vircgroup.c
>> +++ b/src/util/vircgroup.c
>> @@ -732,11 +732,12 @@ virCgroupDetect(virCgroupPtr group,
>> return -1;
>> }
>>
>> - VIR_DEBUG("Detected mount/mapping %zu:%s at %s in %s for pid
%llu", i,
>> + VIR_DEBUG("Detected mount/mapping %zu:%s at %s in %s for pid
%lld",
>> + i,
>> virCgroupControllerTypeToString(i),
>> group->controllers[i].mountPoint,
>> group->controllers[i].placement,
>> - (unsigned long long)pid);
>> + (long long) pid);
>> }
>>
>> return 0;
>
> Printing -1 instead of long number is better, but there are lot of
> other places where we print pids as unsigned:
>
> git grep "unsigned long long.*pid"
>
> it would be worth to change them too.
And add a syntax-check rule to detect such casts.
Well, I don't really like the idea turning every unsigned pid to signed.
There are places where a non-negative PID can be safely assumed (e.g.
virDomainQemuAttach, locking protocol). But okay, I will fix all the
occurrences that I think suffer the same problem and just exclude the
rest from syntax-check.
Michal