From: Junio C Hamano <gitster@pobox.com>
To: Jeff King <peff@peff.net>
Cc: Johannes Schindelin <johannes.schindelin@gmx.de>,
Stefan Beller <sbeller@google.com>,
Michael Blume <blume.mike@gmail.com>,
peter@lekensteyn.nl, eungjun.yi@navercorp.com,
Git List <git@vger.kernel.org>
Subject: Re: Git compile warnings (under mac/clang)
Date: Fri, 23 Jan 2015 10:48:40 -0800 [thread overview]
Message-ID: <xmqqmw59qqnr.fsf@gitster.dls.corp.google.com> (raw)
In-Reply-To: <20150123183737.GA32191@peff.net> (Jeff King's message of "Fri, 23 Jan 2015 13:37:37 -0500")
Jeff King <peff@peff.net> writes:
> But of all the options outlined, I think I'd much rather just see an
> assert() for something that should never happen, rather than mixing it
> into the logic.
Surely.
> In that vein, 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.
Sounds like a sensible fix to me.
prev parent reply other threads:[~2015-01-23 18:48 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-01-22 19:43 Git compile warnings (under mac/clang) Michael Blume
2015-01-22 19:59 ` Stefan Beller
2015-01-22 21:19 ` Peter Wu
2015-01-22 21:20 ` Johannes Schindelin
2015-01-22 22:01 ` Jeff King
2015-01-23 11:48 ` Johannes Schindelin
2015-01-23 12:23 ` Jeff King
2015-01-23 12:38 ` Johannes Schindelin
2015-01-23 13:30 ` Jeff King
2015-01-23 18:07 ` Junio C Hamano
2015-01-23 18:37 ` Jeff King
2015-01-23 18:46 ` Johannes Schindelin
2015-01-23 18:55 ` Jeff King
2015-01-23 19:20 ` Johannes Schindelin
2015-01-23 18:48 ` Junio C Hamano [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqqmw59qqnr.fsf@gitster.dls.corp.google.com \
--to=gitster@pobox.com \
--cc=blume.mike@gmail.com \
--cc=eungjun.yi@navercorp.com \
--cc=git@vger.kernel.org \
--cc=johannes.schindelin@gmx.de \
--cc=peff@peff.net \
--cc=peter@lekensteyn.nl \
--cc=sbeller@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.