From: Greg Thelen <gthelen@google.com>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: linux-trace-devel@vger.kernel.org, Greg Thelen <gthelen@google.com>
Subject: [PATCH] trace-cmd: always initialize write_record() len
Date: Thu, 27 Jun 2019 08:25:02 -0700 [thread overview]
Message-ID: <20190627152502.174918-1-gthelen@google.com> (raw)
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.
Signed-off-by: Greg Thelen <gthelen@google.com>
---
tracecmd/trace-split.c | 10 +++-------
1 file changed, 3 insertions(+), 7 deletions(-)
diff --git a/tracecmd/trace-split.c b/tracecmd/trace-split.c
index d27b3c65badc..6c8a774e13d0 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);
--
2.22.0.410.gd8fdbe21b5-goog
next reply other threads:[~2019-06-27 15:25 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-27 15:25 Greg Thelen [this message]
2019-06-27 15:40 ` [PATCH] trace-cmd: always initialize write_record() len Steven Rostedt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190627152502.174918-1-gthelen@google.com \
--to=gthelen@google.com \
--cc=linux-trace-devel@vger.kernel.org \
--cc=rostedt@goodmis.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).