From d34cb01da6a26cc35b4cd0cce1c8c3a62094e894 Mon Sep 17 00:00:00 2001 From: Arnaud Giersch Date: Tue, 22 May 2012 13:58:37 +0200 Subject: [PATCH] Ensure that lfields[] is fully initialized. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Fixes compilation error: In file included from .../src/xbt/mmalloc/mm.c:24:0: .../src/xbt/mmalloc/mm_diff.c: In function ‘get_addr_memory_map’: .../src/xbt/mmalloc/mm_diff.c:373:9: error: ‘lfields[5]’ may be used uninitialized in this function [-Werror=uninitialized] cc1: all warnings being treated as errors In fact, once strtok returns NULL, subsequent searches with the same parameters return NULL too. --- src/xbt/mmalloc/mm_diff.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/xbt/mmalloc/mm_diff.c b/src/xbt/mmalloc/mm_diff.c index c8bc05adfa..a2e29b6f6d 100644 --- a/src/xbt/mmalloc/mm_diff.c +++ b/src/xbt/mmalloc/mm_diff.c @@ -353,7 +353,7 @@ const char* get_addr_memory_map(void *addr, void* s_heap, void* r_heap){ lfields[0] = strtok(line, " "); - for (i = 1; i < 6 && lfields[i - 1] != NULL; i++) { + for (i = 1; i < 6; i++) { lfields[i] = strtok(NULL, " "); } -- 2.20.1