aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGreg Thelen <gthelen@google.com>2019-06-27 08:25:02 -0700
committerSteven Rostedt (VMware) <rostedt@goodmis.org>2019-07-05 10:20:38 -0400
commitf8d45ca8cd97cdbefba4a513fbd814efe6a645af (patch)
tree77c60860cdf4808e11f715e7ef0de3fe590931dd
parente946da1d8c819ed18d8979cc2558ef095df8a189 (diff)
downloadtrace-cmd-f8d45ca8cd97cdbefba4a513fbd814efe6a645af.tar.gz
trace-cmd: Always initialize write_record() len
write_record() uses an uninitializedd 'len' when record->size is 0. I'm not sure how likely this case is. To be safe and silence compiler warning, unconditionally initialize len. Link: http://lore.kernel.org/linux-trace-devel/20190627152502.174918-1-gthelen@google.com Fixes: 87d2a344a ("trace-cmd: Add split feature") Signed-off-by: Greg Thelen <gthelen@google.com> Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
-rw-r--r--tracecmd/trace-split.c10
1 files changed, 3 insertions, 7 deletions
diff --git a/tracecmd/trace-split.c b/tracecmd/trace-split.c
index d27b3c65..6c8a774e 100644
--- a/tracecmd/trace-split.c
+++ b/tracecmd/trace-split.c
@@ -80,7 +80,7 @@ static int write_record(struct tracecmd_input *handle,
unsigned long long diff;
struct tep_handle *pevent;
void *page;
- int len;
+ int len = 0;
char *ptr;
int index = 0;
int time;
@@ -106,12 +106,8 @@ static int write_record(struct tracecmd_input *handle,
return 0;
}
- if (record->size) {
- if (record->size < 28 * 4)
- len = record->size / 4;
- else
- len = 0;
- }
+ if (record->size && (record->size < 28 * 4))
+ len = record->size / 4;
time = (unsigned)diff;
time = create_type_len(pevent, time, len);