Thread (3 messages) 3 messages, 2 authors, 2016-06-15

Re: [PATCH] Initialise hash variable to prevent compiler warnings

From: Junio C Hamano <hidden>
Date: 2016-06-15 23:02:42

On Mon, Oct 13, 2014 at 2:53 PM, Felipe Franciosi [off-list ref] wrote:
On Mon, Oct 13, 2014 at 9:12 PM, Junio C Hamano [off-list ref] wrote:
quoted
FNV/I/IDIV10/0 covers all the possibilities of (method & 3), I would
have to say that the compiler needs to be fixed.

Or insert "default:" just before "case HASH_METHOD_0:" line?

I dunno.
Hmm... The "default:" would work, but is it really that bad to initialise a
local variable in this case?

In any case, the compilation warning is annoying. Do you prefer the default
or the initialisation?
If I really had to choose between the two, adding a useless initialization
would be the less harmful choice. Adding a meaningless "default:" robs
another chance from the compilers to diagnose a future breakage we
might add (namely, we may extend methods and forget to write a
corresponding case arm for the new method value, which a smart
compiler can and do diagnose as a switch that does not handle
all the possible values.

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