Re: [PATCH] flow_dissector: avoid uninitialized variable access

From
Linus Torvalds <torvalds@linux-foundation.org>
Date
2016-10-22 01:48:51
Also in
lkml
Reply to
Jiri Pirko, 2016-10-21
On Fri, Oct 21, 2016 at 9:31 AM, Jiri Pirko [off-list ref] wrote:
I don't see how vlan could be used uninitialized. But I understand that
this is impossible for gcc to track it. Please just use uninitialized_var()
Actually, I think we should never use "uninitialized_var()" except
possibly for arrays or structures that gcc can complain about.

It's a horrible thing to use, in that it adds extra cruft to the
source code, and then shuts up a compiler warning (even the _reliable_
warnings from gcc).

It's much better to just initialize the variable, and if gcc some day
gets smarter and sees that it  is unnecessary and always overwritten,
so much the better. The cost of initializing a single word is
basically zero.

            Linus
Thread (11 messages) 11 messages, 5 authors, last reply 2016-10-24
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help