Re: compat_ioctl cmd does not match even if it shows same value

"Patrick J. LoPresti" <[email protected]>
Newsgroups gmane.comp.debugging.valgrind
Message-ID <CAKGkouvuk3A6vNKX_8TrqAJZnLHTi_3VYOcCdQTjJp3Xsz58Og@mail.gmail.com>
On Sat, Aug 15, 2020 at 10:59 AM John Reiser <[email protected]> wrote:
>
> The fact that you write '0xc018786f' here, but '3222829167' in the code,
> shows that you are not sufficiently paranoid.  First, if the bit pattern
is important
> then you should write hex.  If you insist on decimal, then you should
write '3222829167u'
> to remind yourself and the compiler that the value is unsigned; otherwise
because
> 3222829167 exceeds INT_MAX then a compiler is allowed to interpret it as
-1072138129
> (or ANY VALUE WHATSOEVER!!!)

This is incorrect for C99 and indeed any compiler that supports "long
long". On such systems, the integer constant 3222829167 has type "long
long", and it is absolutely guaranteed to preserve that value when cast to
unsigned. Assuming 32-bit int, of course.

I agree it is poor style, but there is essentially zero chance it is
causing a problem here. Although 32-bit vs. 64-bit confusion elsewhere
certainly might.

 - Pat

_______________________________________________
Valgrind-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/valgrind-users
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.