Skip to contentSkip to conversation

lib/mpi/mpicoder.c: looping issue, need stop when equal to zero, found by 'EXTRA_FLAGS=-W'.

PATCH In review Chen Gang 2 participants 3 messages May 20, 2013

lore
Share & tools
lore

Chen Gang

author
#0 lore raw

PATCH 1/1 lib/mpi/mpicoder.c: looping issue, need stop when equal to zero, found by 'EXTRA_FLAGS=-W'.

For 'while' looping, need stop when 'nbytes == 0', or will cause issue. ('nbytes' is size_t which is always bigger or equal than zero).

The related warning: (with EXTRA_CFLAGS=-W)
lib/mpi/mpicoder.c:40:2: warning: comparison of unsigned expression >= 0 is always true [-Wtype-limits]

---
 lib/mpi/mpicoder.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
lib/mpi/mpicoder.c +1 -1
index 5f9c44c..4cc6442 100644
@@ -37,7 +37,7 @@ MPI mpi_read_raw_data(const void *xbuffer, size_t nbytes)
 	mpi_limb_t a;
 	MPI val = NULL;
 
-	while (nbytes >= 0 && buffer[0] == 0) {
+	while (nbytes > 0 && buffer[0] == 0) {
 		buffer++;
 		nbytes--;
 	}
Signature · 1 line
1.7.7.6
Acked-by on v1 1/1
#1 lore raw
Quoted 5 lines · Chen Gang

For 'while' looping, need stop when 'nbytes == 0', or will cause issue. ('nbytes' is size_t which is always bigger or equal than zero).

The related warning: (with EXTRA_CFLAGS=-W)
lib/mpi/mpicoder.c:40:2: warning: comparison of unsigned expression >= 0 is always true [-Wtype-limits]

author
#2 lore raw
Quoted 10 lines · David Howells
Quoted 5 lines · Chen Gang
Quoted 5 lines

For 'while' looping, need stop when 'nbytes == 0', or will cause issue. ('nbytes' is size_t which is always bigger or equal than zero).

The related warning: (with EXTRA_CFLAGS=-W)
lib/mpi/mpicoder.c:40:2: warning: comparison of unsigned expression >= 0 is always true [-Wtype-limits]

Thank you very much.

Thanks.

Signature · 3 lines
Chen Gang

Asianux Corporation