On 01/30/2013 11:51 AM, John Ferlan wrote: > Turns out the issue regarding ptr_arith and sign_exension weren't false > positives. When shifting an 'unsigned char' as a target, it gets promoted > to an 'int'; however, that 'int' cannot be shifted 32 bits which was how > the algorithm was written. For the ptr_arith rather than index into the > cpumap, change the to address as necessary and assign directly. > --- > src/xen/xen_hypervisor.c | 10 +++++----- > for (j = 0; j < maplen; j++) { > - /* coverity[ptr_arith] */ > - /* coverity[sign_extension] */ > - *(pm + (j / 8)) |= cpumap[j] << (8 * (j & 7)); > + if ((j & 7) == 0) > + pm = (uint64_t *)((uint64_t)&xen_cpumap + (j & ~0x7UL)); I'm not happy with how this turned out. We are turning an address into a pointer but not via intptr_t (probably warnings on mingw); then doing math on that pointer, then turning the result back into a uint64_t pointer. It looks like we are risking alignment errors. > + *pm |= (uint64_t)cpumap[j] << (8 * (j & 7)); This part looks better, although I can see why you had to push a followup to silence a false negative compiler warning about pm potentially being used uninitialized. I still think we can do a better job; the whole goal of this code is to write an endian-specific ordering of a multiple of 8 bytes; I can't help but wonder if my concurrent work on a new virendian.h header would be a nicer-looking solution here. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
Attachment:
signature.asc
Description: OpenPGP digital signature
-- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list