Re: [PATCH 1/4] wt-status: fix possible use of uninitialized variable

2013-03-22 Thread Jeff King
On Thu, Mar 21, 2013 at 12:49:50PM -0700, Jonathan Nieder wrote: > > We could also convert the flag to an enum, which would > > provide a compile-time check on the function input. > > Unfortunately C permits out-of-bounds values for enums. True, although I would think that most compilers take th

Re: [PATCH 1/4] wt-status: fix possible use of uninitialized variable

2013-03-21 Thread Jonathan Nieder
Junio C Hamano wrote: > Jonathan Nieder writes: >> Jeff King wrote: >>> + default: >>> + die("BUG: unhandled change_type %d in >>> wt_status_print_change_data", >>> + change_type); >> >> Micronit: s/unhandled/invalid/. > > I actually think "unhandled" is more correct fo

Re: [PATCH 1/4] wt-status: fix possible use of uninitialized variable

2013-03-21 Thread Junio C Hamano
Jonathan Nieder writes: > Jeff King wrote: > >> Instead of using the "x = x" hack, let's handle the default >> case in the switch() statement with a die("BUG"). That tells >> the compiler and any readers of the code exactly what the >> function's input assumptions are. > > Sounds reasonable. > >>

Re: [PATCH 1/4] wt-status: fix possible use of uninitialized variable

2013-03-21 Thread Jonathan Nieder
Jeff King wrote: > Instead of using the "x = x" hack, let's handle the default > case in the switch() statement with a die("BUG"). That tells > the compiler and any readers of the code exactly what the > function's input assumptions are. Sounds reasonable. > We could also convert the flag to an

[PATCH 1/4] wt-status: fix possible use of uninitialized variable

2013-03-21 Thread Jeff King
In wt_status_print_change_data, we accept a change_type flag that is meant to be either WT_STATUS_UPDATED or WT_STATUS_CHANGED. We then switch() on this value to set the local variable "status" for each case, but do not provide a fallback "default" label to the switch statement. As a result, the