Thread (4 messages) read the whole thread 4 messages, 4 authors, 2021-09-07

Re: bridge.c:157:11: error: variable 'err' is used uninitialized whenever 'if' condition is false

From: Linus Torvalds <torvalds@linux-foundation.org>
Date: 2021-09-06 16:40:16
Also in: lkml

On Mon, Sep 6, 2021 at 2:11 AM Naresh Kamboju [off-list ref] wrote:
drivers/net/ethernet/mellanox/mlx5/core/en/rep/bridge.c:157:11: error:
variable 'err' is used uninitialized whenever 'if' condition is false
That compiler warning (now error) seems to be entirely valid.

That's a

    if (..)
    else if (..)

and if neither are valid then the code will return an uninitialized 'err'.

It's possible the two conditionals are guaranteed to cover all cases,
but as the compiler says, in that case the "if" in the else clause is
pointless and should be removed.

But it does look like 'ret' should probably just be initialized to 0.

              Linus
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help