[dpdk-dev] [PATCH v4 18/23] rte_rwlock.h: gcc8 sign conversion warnings

Andy Green andy at warmcat.com
Mon May 14 07:10:58 CEST 2018


In file included from /projects/lagopus/src/dpdk/
build/include/rte_rwlock.h:12,
                 from ./mgr/lock.h:24,
                 from ./mgr/sock_io.c:54:
/projects/lagopus/src/dpdk/build/include/generic/
rte_rwlock.h: In function 'rte_rwlock_read_lock':
/projects/lagopus/src/dpdk/build/include/generic/
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);
            ^
/projects/lagopus/src/dpdk/build/include/generic/
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);
               ~~^~~
/projects/lagopus/src/dpdk/build/include/generic/
rte_rwlock.h: In function 'rte_rwlock_write_lock':
/projects/lagopus/src/dpdk/build/include/generic/
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);
               ^~
Fixes: af75078fec ("first public release")
Signed-off-by: Andy Green <andy at warmcat.com>
---
 lib/librte_eal/common/include/generic/rte_rwlock.h |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/librte_eal/common/include/generic/rte_rwlock.h b/lib/librte_eal/common/include/generic/rte_rwlock.h
index 899e9bc43..497934977 100644
--- a/lib/librte_eal/common/include/generic/rte_rwlock.h
+++ b/lib/librte_eal/common/include/generic/rte_rwlock.h
@@ -71,7 +71,7 @@ rte_rwlock_read_lock(rte_rwlock_t *rwl)
 			continue;
 		}
 		success = rte_atomic32_cmpset((volatile uint32_t *)&rwl->cnt,
-					      x, x + 1);
+					      x, (uint32_t)(x + 1));
 	}
 }
 
@@ -107,7 +107,7 @@ rte_rwlock_write_lock(rte_rwlock_t *rwl)
 			continue;
 		}
 		success = rte_atomic32_cmpset((volatile uint32_t *)&rwl->cnt,
-					      0, -1);
+					      0, (uint32_t)-1);
 	}
 }
 



More information about the dev mailing list