eal: fix argument in 32-bit safe BSF function

The first argument to rte_bsf32_safe was incorrectly declared as
a 64 bit value. The code only works on 32 bit values and the underlying
function rte_bsf32 only accepts 32 bit values. This was a mistake
introduced when the safe version was added and probably cause
by copy/paste from the 64 bit version.

The bug passed silently under the radar until some other code was
built with -Wall and -Wextra in C++ and C++ complains about the
missing cast.

Yes, this is a API signature change, but the original code was wrong.
It is an inline so not an ABI change.

Fixes: 4e261f551986 ("eal: add 64-bit bsf and 32-bit safe bsf functions")
Cc: stable@dpdk.org

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Acked-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
This commit is contained in:
Stephen Hemminger 2021-07-23 08:45:46 -07:00 committed by Thomas Monjalon
parent 73b91412ca
commit 128c22b998
2 changed files with 5 additions and 1 deletions

View File

@ -202,6 +202,10 @@ API Changes
* eal: ``rte_strscpy`` sets ``rte_errno`` to ``E2BIG`` in case of string
truncation.
* eal: ``rte_bsf32_safe`` now takes a 32-bit value for its first argument.
This fixes warnings about loss of precision
when used with some compilers settings.
* eal: ``rte_power_monitor`` and the ``rte_power_monitor_cond`` struct changed
to use a callback mechanism.

View File

@ -623,7 +623,7 @@ rte_bsf32(uint32_t v)
* Returns 0 if ``v`` was 0, otherwise returns 1.
*/
static inline int
rte_bsf32_safe(uint64_t v, uint32_t *pos)
rte_bsf32_safe(uint32_t v, uint32_t *pos)
{
if (v == 0)
return 0;