From bc8e92948bc15854d393e16bcf995b2ad99ccfb4 Mon Sep 17 00:00:00 2001 From: Dan Scott Date: Sat, 5 May 2012 01:58:22 -0400 Subject: [PATCH] Remove comparisons that can never evaluate to true Using clang as the compiler results in 4 warnings like the following: osrf_list.c:106:23: warning: comparison of unsigned expression < 0 is always false [-Wtautological-compare] if(!list || position < 0) return NULL; ~~~~~~~~ ^ ~ (Explanation: "position" is an unsigned int; thus the comparison to < 0 can never evaluate to true). Signed-off-by: Dan Scott Signed-off-by: Galen Charlton --- src/libopensrf/osrf_list.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/libopensrf/osrf_list.c b/src/libopensrf/osrf_list.c index 7ea3e97..4d4bb11 100644 --- a/src/libopensrf/osrf_list.c +++ b/src/libopensrf/osrf_list.c @@ -103,7 +103,7 @@ int osrfListPushFirst( osrfList* list, void* item ) { calling code. */ void* osrfListSet( osrfList* list, void* item, unsigned int position ) { - if(!list || position < 0) return NULL; + if(!list) return NULL; int newsize = list->arrsize; @@ -144,7 +144,7 @@ void* osrfListSet( osrfList* list, void* item, unsigned int position ) { If either parameter is invalid, the return value is NULL. */ void* osrfListGetIndex( const osrfList* list, unsigned int position ) { - if(!list || position >= list->size || position < 0) return NULL; + if(!list || position >= list->size) return NULL; return list->arrlist[position]; } @@ -226,7 +226,7 @@ void osrfListSwap( osrfList* one, osrfList* two ) { shift other pointers down to fill in the hole left by the removal. */ void* osrfListRemove( osrfList* list, unsigned int position ) { - if(!list || position >= list->size || position < 0) return NULL; + if(!list || position >= list->size) return NULL; void* olditem = list->arrlist[position]; list->arrlist[position] = NULL; @@ -249,7 +249,7 @@ void* osrfListRemove( osrfList* list, unsigned int position ) { to which the pointer points, even if an item-freeing function has been designated. */ void* osrfListExtract( osrfList* list, unsigned int position ) { - if(!list || position >= list->size || position < 0) return NULL; + if(!list || position >= list->size) return NULL; void* olditem = list->arrlist[position]; list->arrlist[position] = NULL; -- 2.11.0