[Libguestfs] [PATCH nbdkit 1/3] common: isaligned: Use uint64_t instead of unsigned int.

Richard W.M. Jones rjones at redhat.com
Mon Sep 17 20:02:05 UTC 2018


On Mon, Sep 17, 2018 at 08:55:06PM +0100, Richard W.M. Jones wrote:
> On Mon, Sep 17, 2018 at 10:00:30PM +0300, Nir Soffer wrote:
> > On Mon, Sep 17, 2018 at 6:03 PM Richard W.M. Jones <rjones at redhat.com>
> > wrote:
> > 
> > > This should have no effect.  However it's probably better to pass the
> > > full type explicitly rather than using an implicit truncation.
> > >
> > 
> > Why is it better?

OK I'll give one (somewhat contrived) example where it might be better
not to rely on implicit truncation of parameters:

(1) User is compiling on a 32 bit architecture.

(2) They have turned off or are ignoring compiler warnings.

(3) The code has forgotten to #include "isaligned.h" (either our code
omits this, which is unlikely, or the user is developing a new plugin
using the same framework).

In this case the uint64_t would be passed as a 64 bit value (eg.  in
two registers, or as a 64 bit stack entry), and thus the receiving
function would get the wrong parameters.

Rich.

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
virt-df lists disk usage of guests without needing to install any
software inside the virtual machine.  Supports Linux and Windows.
http://people.redhat.com/~rjones/virt-df/




More information about the Libguestfs mailing list