On Mon, Sep 17, 2018 at 11:02 PM Richard W.M. Jones <rjones(a)redhat.com>
wrote:
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(a)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.
What if we use uint64_t, and the same careless user sends two 32 bit
size instead of 64 bit size? We will check the second argument with
non-existing
argument, using some random value from the stack.
I think we need to put the line somewhere. Users should include headers
and watch compiler warnings. If not, they deserve the results :-)
Nir