[PATCH 3/3] libtraceevent: Fix Branch condition garbage value compiler warning

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
---
 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




[Index of Archives]     [Linux USB Development]     [Linux USB Development]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux