Message ID | 20220930111002.6107-4-mpetlan@redhat.com (mailing list archive) |
---|---|
State | Accepted |
Commit | 059563257cdc09bdd92a19819401a48a93cb81e4 |
Headers | show |
Series | Fix several Coverity andf Clang warnings in libtraceevent | expand |
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; }
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(-)