Skip to contentSkip to conversation

Compiler warning - ipv4 fib_trie

DISCUSSION Koen Vandeputte 2 participants 2 messages Feb 4, 2019 – Feb 5, 2019

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

Hi All,

During compilation of kernel 4.14.96 and 5.0-rc5 I'm seeing following warning:

net/ipv4/fib_trie.c: In function 'fib_trie_unmerge':
net/ipv4/fib_trie.c:1749:8: warning: 'local_tp' may be used uninitialized in this function [-Wmaybe-uninitialized] if (fib_insert_alias(lt, local_tp, local_l, new_fa, ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           NULL, l->key)) {
           ~~~~~~~~~~~~~

Code:

https://elixir.bootlin.com/linux/v5.0-rc5/source/net/ipv4/fib_trie.c#L1731

Looks like 'local_tp' should be NULL-ified

Thanks,

Koen

#1 lore raw
Quoted 15 lines · Koen Vandeputte

Hi All,

During compilation of kernel 4.14.96 and 5.0-rc5 I'm seeing following warning:

net/ipv4/fib_trie.c: In function 'fib_trie_unmerge':
net/ipv4/fib_trie.c:1749:8: warning: 'local_tp' may be used uninitialized in this function [-Wmaybe-uninitialized] if (fib_insert_alias(lt, local_tp, local_l, new_fa, ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ NULL, l->key)) {
           ~~~~~~~~~~~~~

Code:

Quoted 9 lines

https://elixir.bootlin.com/linux/v5.0-rc5/source/net/ipv4/fib_trie.c#L1731

Looks like 'local_tp' should be NULL-ified

Thanks,

Koen

I believe that is a false positive. If you analyze the loop, local_tp is set when local_l is NULL and it is set before the first use. I am surprised the compiler can not track that. fib_find_node has 1 return point and local_tp is set right before.