From: "Jakub Narębski" <jnareb@gmail.com>
To: Johannes Schindelin <johannes.schindelin@gmx.de>, git@vger.kernel.org
Cc: "Junio C Hamano" <gitster@pobox.com>,
"Torsten Bögershausen" <tboegi@web.de>,
"Lars Schneider" <larsxschneider@gmail.com>,
"Jeff King" <peff@peff.net>
Subject: Re: [PATCH] sequencer: shut up clang warning
Date: Wed, 9 Nov 2016 23:28:24 +0100 [thread overview]
Message-ID: <11e953de-956d-d4eb-8117-ebbfc410676b@gmail.com> (raw)
In-Reply-To: <efbba4b32515fed7096c1c81dbe97eedd44083b0.1478699713.git.johannes.schindelin@gmx.de>
W dniu 09.11.2016 o 14:56, Johannes Schindelin pisze:
> When comparing a value of type `enum todo_command` with a value that is
> outside the defined enum constants, clang greets the developer with this
> warning:
>
> comparison of constant 2 with expression of type
> 'const enum todo_command' is always true
>
> While this is arguably true *iff* the value was never cast from a
> free-form int, we should keep the cautious code in place.
>
> To shut up clang, we simply introduce an otherwise pointless enum constant
> and compare against that.
>
> Noticed by Torsten Bögershausen.
>
> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
> ---
> sequencer.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/sequencer.c b/sequencer.c
> index 5fd75f3..f80e9c0 100644
> --- a/sequencer.c
> +++ b/sequencer.c
> @@ -619,7 +619,8 @@ static int allow_empty(struct replay_opts *opts, struct commit *commit)
>
> enum todo_command {
> TODO_PICK = 0,
> - TODO_REVERT
> + TODO_REVERT,
> + TODO_INVALID
> };
Why not name it TODO_N, or N_TODO, or something like that?
--
Jakub Narębski
prev parent reply other threads:[~2016-11-09 22:28 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-11-09 13:56 [PATCH] sequencer: shut up clang warning Johannes Schindelin
2016-11-09 15:37 ` Jeff King
2016-11-09 22:28 ` Jakub Narębski [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=11e953de-956d-d4eb-8117-ebbfc410676b@gmail.com \
--to=jnareb@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=johannes.schindelin@gmx.de \
--cc=larsxschneider@gmail.com \
--cc=peff@peff.net \
--cc=tboegi@web.de \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).