[PATCH] building libtraceevent with clang
From: Arnaldo Carvalho de Melo
Date: Fri Feb 10 2017 - 12:04:23 EST
Hi Steven,
I tried building perf (and thus libtraceevent) with clang and
got this one:
kbuffer-parse.c:312:7: warning: variable 'length' is used uninitialized whenever switch case is taken [-Wsometimes-uninitialized]
case OLD_RINGBUF_TYPE_TIME_EXTEND:
^~~~~~~~~~~~~~~~~~~~~~~~~~~~
kbuffer-parse.c:339:29: note: uninitialized use occurs here
kbuf->next = kbuf->index + length;
^~~~~~
kbuffer-parse.c:297:21: note: initialize the variable 'length' to silence this warning
unsigned int length;
^
= 0
1 warning generated.
Please take a look if the following is what should be done:
diff --git a/tools/lib/traceevent/kbuffer-parse.c b/tools/lib/traceevent/kbuffer-parse.c
index 65984f1c2974..3f717294cb82 100644
--- a/tools/lib/traceevent/kbuffer-parse.c
+++ b/tools/lib/traceevent/kbuffer-parse.c
@@ -309,20 +309,20 @@ static unsigned int old_update_pointers(struct kbuffer *kbuf)
kbuf->next = kbuf->size;
return 0;
- case OLD_RINGBUF_TYPE_TIME_EXTEND:
- extend = read_4(kbuf, ptr);
- extend <<= TS_SHIFT;
- extend += delta;
- delta = extend;
- ptr += 4;
- break;
-
case OLD_RINGBUF_TYPE_TIME_STAMP:
/* should never happen! */
kbuf->curr = kbuf->size;
kbuf->next = kbuf->size;
kbuf->index = kbuf->size;
return -1;
+
+ case OLD_RINGBUF_TYPE_TIME_EXTEND:
+ extend = read_4(kbuf, ptr);
+ extend <<= TS_SHIFT;
+ extend += delta;
+ delta = extend;
+ ptr += 4;
+ /* Fall through */
default:
if (len)
length = len * 4;