linux-trace-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Michael Petlan <mpetlan@redhat.com>
To: linux-trace-devel@vger.kernel.org
Cc: rostedt@goodmis.org
Subject: [PATCH 3/3] libtraceevent: Fix Branch condition garbage value compiler warning
Date: Fri, 30 Sep 2022 13:10:02 +0200	[thread overview]
Message-ID: <20220930111002.6107-4-mpetlan@redhat.com> (raw)
In-Reply-To: <20220930111002.6107-1-mpetlan@redhat.com>

If *offset equals to zero, it is zero. If not equals to zero, set it to
zero. In any case, it will be zero, so we can omit the condition and so
get rid of the compiler warning:

  libtraceevent/src/event-parse.c:4064:7: warning[core.uninitialized.Branch]: Branch condition evaluates to a garbage value

Instead, let's rather check the pointers for being NULL, in order to
prevent another warning:

  libtraceevent/src/event-parse.c:4064:7: warning[core.NullDereference]: Dereference of null pointer (loaded from variable 'offset')

Signed-off-by: Michael Petlan <mpetlan@redhat.com>
---
 src/event-parse.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/event-parse.c b/src/event-parse.c
index b4094ec..60bf989 100644
--- a/src/event-parse.c
+++ b/src/event-parse.c
@@ -4073,9 +4073,9 @@ static inline void dynamic_offset_field(struct tep_handle *tep,
 {
 	/* Test for overflow */
 	if (field->offset + field->size > size) {
-		if (*offset)
+		if (offset)
 			*offset = 0;
-		if (*len)
+		if (len)
 			*len = 0;
 		return;
 	}
-- 
2.18.4


  parent reply	other threads:[~2022-09-30 11:22 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-30 11:09 [PATCH 0/3] Fix several Coverity andf Clang warnings in libtraceevent Michael Petlan
2022-09-30 11:10 ` [PATCH 1/3] libtraceevent: Fix uninitialized has_0x compiler warning Michael Petlan
2022-09-30 11:10 ` [PATCH 2/3] libtraceevent: Fix check-after-deref coverity flaw Michael Petlan
2022-09-30 11:10 ` Michael Petlan [this message]
2022-10-20 19:15 ` [PATCH 0/3] Fix several Coverity andf Clang warnings in libtraceevent 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=20220930111002.6107-4-mpetlan@redhat.com \
    --to=mpetlan@redhat.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).