Hi Peff,

On 2015-01-23 19:37, Jeff King wrote:
> On Fri, Jan 23, 2015 at 10:07:18AM -0800, Junio C Hamano wrote:
> 
> [...] one thing that puzzles me is that the current code looks
> like:
> 
>   if (options->msg_severity && msg_id >= 0 && msg_id < FSCK_MSG_MAX)
>         severity = options->msg_severity[msg_id];
>   else {
>         severity = msg_id_info[msg_id].severity;
>         ...
>   }
> 
> So if the severity override list given by "options" exists, _and_ if we
> are in the enum range, then we use that. Otherwise, we dereference the
> global list. But wouldn't an out-of-range condition have the exact same
> problem dereferencing that global list?
> 
> IOW, should this really be:
> 
>   if (msg_id < 0 || msg_id >= FSCK_MSG_MAX)
>       die("BUG: broken enum");
> 
>   if (options->msg_severity)
>       severity = options->msg_severity[msg_id];
>   else
>       severity = msg_id_info[msg_id].severity;
> 
> ? And then you can spell that first part as assert(), which I suspect
> (but did not test) may shut up clang's warnings.

To be quite honest, I assumed that Git's source code was assert()-free. But I 
was wrong! So I'll go with that solution; it is by far the nicest one IMHO.

Thanks!
Dscho
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to