From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 82977A0547; Fri, 12 Mar 2021 19:24:21 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4B4521608D2; Fri, 12 Mar 2021 19:24:21 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 5A2A41608CE for ; Fri, 12 Mar 2021 19:24:20 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1086) id 98C1120B39C5; Fri, 12 Mar 2021 10:24:19 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 98C1120B39C5 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1615573459; bh=OPgds1hQ21EXdvkKxHfkuN+/yCwBClWJl47YrrmwGrI=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=O4SGOOyhzNgqbngWdGgO59mjUh4XUobZdoDx5LY26DktPLyZMsFyLy6v/H/mz+/UN VG2qwcORQDvyWBtV7eUA49IoZFzVmsEt+yX+ec1PEsRxwjMc0FMNve/nde+Ea90DFx xYBWDVVjMl/ljWX0OQp5WNlWGTfNnD5TBBStXm5E= Date: Fri, 12 Mar 2021 10:24:19 -0800 From: Tyler Retzlaff To: Morten =?iso-8859-1?Q?Br=F8rup?= Cc: Stephen Hemminger , dev@dpdk.org, anatoly.burakov@intel.com, Ray Kinsella , Neil Horman Message-ID: <20210312182419.GC8084@linuxonhyperv3.guj3yctzbm1etfxqx2vob5hsef.xx.internal.cloudapp.net> References: <1615358466-12761-1-git-send-email-roretzla@linux.microsoft.com> <20210310104942.66ef440e@hermes.local> <20210310225238.GA10267@linuxonhyperv3.guj3yctzbm1etfxqx2vob5hsef.xx.internal.cloudapp.net> <98CBD80474FA8B44BF855DF32C47DC35C61674@smartserver.smartshare.dk> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <98CBD80474FA8B44BF855DF32C47DC35C61674@smartserver.smartshare.dk> User-Agent: Mutt/1.5.21 (2010-09-15) Subject: Re: [dpdk-dev] [PATCH] librte_eal/common: fix return type of rte_bsf64 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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 >