DPDK patches and discussions
 help / color / mirror / Atom feed
From: Tyler Retzlaff <roretzla@linux.microsoft.com>
To: "Morten Brørup" <mb@smartsharesystems.com>
Cc: Stephen Hemminger <stephen@networkplumber.org>,
	dev@dpdk.org, anatoly.burakov@intel.com,
	Ray Kinsella <mdr@ashroe.eu>, Neil Horman <nhorman@tuxdriver.com>
Subject: Re: [dpdk-dev] [PATCH] librte_eal/common: fix return type of rte_bsf64
Date: Fri, 12 Mar 2021 10:24:19 -0800	[thread overview]
Message-ID: <20210312182419.GC8084@linuxonhyperv3.guj3yctzbm1etfxqx2vob5hsef.xx.internal.cloudapp.net> (raw)
In-Reply-To: <98CBD80474FA8B44BF855DF32C47DC35C61674@smartserver.smartshare.dk>

On Fri, Mar 12, 2021 at 08:34:50AM +0100, Morten Brørup wrote:
> CC: ABI Policy maintainers. You might have an opinion. Or not. :-)
> 
> 
> Please also update the similar math functions in rte_common.h, so the return type is consistent across these functions:
> - rte_bsf32()
> - rte_bsf32_safe()
> - rte_fls_u32()
> - rte_bsf64()
> - rte_fls_u64()
> - rte_log2_u32()
> - rte_log2_u64()

agreed, happy to review the whole set and deal with it all at once.

> 
> They should all return either int or uint32_t.
> 
> Standard C conventions would have them all return int (probably due to C's default type promotion to int when used in calculations), which is also the type returned by their underlying implementation.

yes, i suspect gcc builtins return int because of the default type promotion. probably historical be interesting to get an old gcc hand to tell us a story.

> 
> For some unknown reason, DPDK often uses uint32_t where you would normally use int. I guess it was inspired by MISRA C (for embedded systems); but it is not a documented conventions, and often deviated from.

horses for courses, if it doesn't make sense to interpret as signed then
i don't see a lot of value in using signed and it can open up avenues of
exploit.

> 
> I don't have a personal preference for int or uint32_t here. But at least follow the same convention in the same header file.

agree completely, consistency.

> 
> (Please note that the functions returning a Boolean value as an int type should keep doing that.)

i'm not planning on changing int -> _Bool. but i am curious about your
comment. stdbool.h is already used in the code base is there a compiler
in use that does not support _Bool. this is purely my interest, i don't
propose any change.

> 
> 
> Med venlig hilsen / kind regards
> - Morten Brørup
> 

  parent reply	other threads:[~2021-03-12 18:24 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-10  6:41 Tyler Retzlaff
2021-03-10 18:31 ` Ranjit Menon
2021-03-10 18:49 ` Stephen Hemminger
2021-03-10 22:52   ` Tyler Retzlaff
2021-03-12  7:34     ` Morten Brørup
2021-03-12 11:46       ` Kinsella, Ray
2021-03-12 18:10         ` Tyler Retzlaff
2021-03-12 18:24       ` Tyler Retzlaff [this message]
2021-03-12 21:13         ` Morten Brørup
2021-03-13  1:10           ` Tyler Retzlaff
2021-03-13  7:29             ` Morten Brørup
2021-03-13 16:04               ` Tyler Retzlaff

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=20210312182419.GC8084@linuxonhyperv3.guj3yctzbm1etfxqx2vob5hsef.xx.internal.cloudapp.net \
    --to=roretzla@linux.microsoft.com \
    --cc=anatoly.burakov@intel.com \
    --cc=dev@dpdk.org \
    --cc=mb@smartsharesystems.com \
    --cc=mdr@ashroe.eu \
    --cc=nhorman@tuxdriver.com \
    --cc=stephen@networkplumber.org \
    /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).