summaryrefslogtreecommitdiff
path: root/libopeniscsiusr
diff options
context:
space:
mode:
authorKhem Raj <raj.khem@gmail.com>2020-10-21 09:11:20 -0700
committerKhem Raj <raj.khem@gmail.com>2020-10-21 09:11:20 -0700
commit7bdaa32c80bb7d37668c1ff6d88bb02428459a0f (patch)
treed6538fd006cdf96a5c6b7a359d1717d57511daa3 /libopeniscsiusr
parent348f093311f289635f9e85129aad944ffe1eda91 (diff)
downloadopen-iscsi-7bdaa32c80bb7d37668c1ff6d88bb02428459a0f.tar.gz
libopeniscsiusr: Compare with max int instead of max long
This compares value member of int_list_tbl struct which is of unsigned int type. struct int_list_tbl { const char *name; unsigned int value; }; Clang compiler reports this comparison when -Wtautological-constant-out-of-range-compare is enabled | idbm.c:1042:2: error: result of comparison of constant 18446744073709551615 with expression of type 'unsigned int' is always true [-Werror,-Wtautological-constant-out-of-range-compare] | _rec_int_list(SESSION_CHAP_ALGS, recs, node, session.auth.chap_algs, | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | idbm.c:263:23: note: expanded from macro '_rec_int_list' | if (_org->_name[_i] != ~0UL) { \ | ~~~~~~~~~~~~~~~ ^ ~~~~ Since max value for int can be less than unsinged long e.g. on LP64 its better to use UINT_MAX here Signed-off-by: Khem Raj <raj.khem@gmail.com>
Diffstat (limited to 'libopeniscsiusr')
-rw-r--r--libopeniscsiusr/idbm.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/libopeniscsiusr/idbm.c b/libopeniscsiusr/idbm.c
index 7bc2381..060196f 100644
--- a/libopeniscsiusr/idbm.c
+++ b/libopeniscsiusr/idbm.c
@@ -260,7 +260,7 @@ do {\
_recs[_n].type = TYPE_INT_LIST; \
_strncpy(_recs[_n].name, _key, NAME_MAXVAL); \
for (unsigned int _i = 0; _i < ARRAY_LEN(_org->_name); _i++) { \
- if (_org->_name[_i] != ~0UL) { \
+ if (_org->_name[_i] != UINT_MAX) { \
for (unsigned int _j = 0; _j < ARRAY_LEN(_tbl); _j++) { \
if (_tbl[_j].value == _org->_name[_i]) { \
strcat(_recs[_n].value, _tbl[_j].name); \