[dpdk-dev] [PATCH] eal, power: don't use '-' sign with unsigned literals

Tyler Retzlaff roretzla at linux.microsoft.com
Fri Mar 12 18:05:58 CET 2021


On Fri, Mar 12, 2021 at 12:51:46PM +0000, Burakov, Anatoly wrote:
> On 09-Mar-21 11:44 PM, Tyler Retzlaff wrote:
> >use ~0ULL instead of -1ULL to avoid contridctory application of '-' sign
> >to integer literal where the desired type is unsigned.
> >
> >Signed-off-by: Tyler Retzlaff <roretzla at linux.microsoft.com>
> >---
> 
> Not sure i agree. It's a very common pattern and is widely used and
> understood. I mean, if anything, seeing `~0` would have me stop and
> think as i've literally never seen such code before.

it produces warnings under some compilers. in some enterprises we are
required to fix certain classes of warnings (not suppress them from the
command line) as a function of security policies.

as an alternative would you be more willing to accept something like the
following? ``(unsigned long long)-1LL'' if you don't like ``~0ULL'' it
would make explicit what the compiler is already doing.

the issue is the application of the sign to what is clearly something not
signed; it get's flagged. so the cast is an explicit expression of intent
that will not generate the warnings.

appreciate you're help in finding a solution even if it isn't the
proposed solution.

thanks!

> 
> -- 
> Thanks,
> Anatoly


More information about the dev mailing list