eal: explicit cast in rwlock functions
authorAndy Green <andy@warmcat.com>
Tue, 22 May 2018 01:24:17 +0000 (09:24 +0800)
committerThomas Monjalon <thomas@monjalon.net>
Tue, 22 May 2018 14:27:01 +0000 (16:27 +0200)
commit1587d36e22d0cf0e037a104e1e851acefd6597f0
tree9d9bd8a82034bd7f85aab07fb21fef363c061730
parent14035e5fadff19efb17069c6dc463670a8e8b6c1
eal: explicit cast in rwlock functions

GCC 8.1 warned:

In function 'rte_rwlock_read_lock':
rte_rwlock.h:74:12: warning: conversion to 'uint32_t'
{aka 'unsigned int'} from 'int32_t' {aka 'int'} may
change the sign of the result [-Wsign-conversion]
            x, x + 1);
            ^
rte_rwlock.h:74:17: warning: conversion to 'uint32_t'
{aka 'unsigned int'} from 'int' may change the sign
of the result [-Wsign-conversion]
            x, x + 1);
               ~~^~~

In function 'rte_rwlock_write_lock':
rte_rwlock.h:110:15: warning: unsigned conversion
from 'int' to 'uint32_t' {aka 'unsigned int'}
changes value from '-1' to '4294967295' [-Wsign-conversion]
            0, -1);
               ^~

Again in this case we are making explicit the exact cast
that was always happening implicitly.  The patch does not
change the generated code.

The int32_t temp "x" is required to be signed to detect
a < 0 error condition from the lock status.  Afterwards,
it has always been implicitly cast to uint32_t when it
is used in the arguments to rte_atomic32_cmpset()...
gcc8.1 objects to the implicit cast now and requires us
to cast it explicitly.

Fixes: af75078fec ("first public release")
Cc: stable@dpdk.org
Signed-off-by: Andy Green <andy@warmcat.com>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
lib/librte_eal/common/include/generic/rte_rwlock.h