From: "Morten Brørup" <mb@smartsharesystems.com>
To: "Tyler Retzlaff" <roretzla@linux.microsoft.com>,
"Bruce Richardson" <bruce.richardson@intel.com>
Cc: "Burakov, Anatoly" <anatoly.burakov@intel.com>, <dev@dpdk.org>,
<david.hunt@intel.com>
Subject: Re: [dpdk-dev] [PATCH] eal, power: don't use '-' sign with unsigned literals
Date: Sat, 13 Mar 2021 10:05:59 +0100 [thread overview]
Message-ID: <98CBD80474FA8B44BF855DF32C47DC35C6167C@smartserver.smartshare.dk> (raw)
In-Reply-To: <20210312184001.GB23744@linuxonhyperv3.guj3yctzbm1etfxqx2vob5hsef.xx.internal.cloudapp.net>
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Tyler Retzlaff
> Sent: Friday, March 12, 2021 7:40 PM
>
> On Fri, Mar 12, 2021 at 10:36:15AM -0800, Tyler Retzlaff wrote:
> > On Fri, Mar 12, 2021 at 05:37:41PM +0000, Bruce Richardson wrote:
> > > On Fri, Mar 12, 2021 at 09:05:58AM -0800, Tyler Retzlaff wrote:
> > > > > 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.
> > > >
> > > What about using ULLONG_MAX and similar defines from limits.h?
The type of the variable being manipulated is not unsigned long long, but uint64_t, which theoretically is not the same. Long long can be more than 64 bit, although all current implementations use 64 bit for long long.
So -1ULL was wrong from the start, and ~0ULL is similarly incorrect. The correct value would be UINT64_MAX from stdint.h.
> >
> > i think this would be okay even in circumstances where the code is
> > building masks so long as in practice it results in "all bits being
> > set". i'm not aware of a XXX_MAX where max isn't all bits set.. is
> > there?
>
> just a qualification to my previous.
>
> specifically for the UXXX_MAX (unsigned) preprocessor definitions, we
> aren't talking about signed here (or at least i wasn't).
next prev parent reply other threads:[~2021-03-13 9:07 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-09 23:44 Tyler Retzlaff
2021-03-12 12:51 ` Burakov, Anatoly
2021-03-12 17:05 ` Tyler Retzlaff
2021-03-12 17:37 ` Bruce Richardson
2021-03-12 18:36 ` Tyler Retzlaff
2021-03-12 18:40 ` Tyler Retzlaff
2021-03-13 9:05 ` Morten Brørup [this message]
2021-03-15 15:36 ` [dpdk-dev] [PATCH v2] eal, power: use UINT64_MAX instead of -1ULL Tyler Retzlaff
2021-03-16 0:13 ` [dpdk-dev] [PATCH v3] eal, power: use UINT64_MAX and UINT32_MAX Tyler Retzlaff
2021-03-16 11:06 ` Morten Brørup
2021-04-01 11:22 ` Burakov, Anatoly
2021-04-19 9:43 ` Thomas Monjalon
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=98CBD80474FA8B44BF855DF32C47DC35C6167C@smartserver.smartshare.dk \
--to=mb@smartsharesystems.com \
--cc=anatoly.burakov@intel.com \
--cc=bruce.richardson@intel.com \
--cc=david.hunt@intel.com \
--cc=dev@dpdk.org \
--cc=roretzla@linux.microsoft.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).