From: Junio C Hamano <gitster@pobox.com>
To: Dan Aloni <alonid@gmail.com>
Cc: git@vger.kernel.org, Jeff King <peff@peff.net>
Subject: Re: [PATCH v4 3/3] ident.c: cleanup wrt ident's source
Date: Thu, 04 Feb 2016 14:42:55 -0800 [thread overview]
Message-ID: <xmqqvb64f66o.fsf@gitster.mtv.corp.google.com> (raw)
In-Reply-To: <1454577160-24484-4-git-send-email-alonid@gmail.com> (Dan Aloni's message of "Thu, 4 Feb 2016 11:12:40 +0200")
Dan Aloni <alonid@gmail.com> writes:
> +static int ident_source_is_sufficient(enum ident_source source)
> +{
> + switch (source) {
> + case IDENT_SOURCE_CONFIG:
> + case IDENT_SOURCE_ENVIRONMENT:
> + return 1;
Without adding these two lines here:
default:
break;
I get this build failure:
ident.c: In function 'ident_source_is_sufficient':
ident.c:444:2: error: enumeration value 'IDENT_SOURCE_UNKNOWN' not handled in switch [-Werror=switch]
switch (source) {
^
ident.c:444:2: error: enumeration value 'IDENT_SOURCE_GUESSED' not handled in switch [-Werror=switch]
ident.c:444:2: error: enumeration value 'IDENT_SOURCE_GUESSED_BOGUS' not handled in switch [-Werror=switch]
> +static int ident_is_sufficient(enum ident_person person)
> {
> + const char *str_name, *str_email;
> + int name, email;
> +
> + switch (person) {
> + case IDENT_PERSON_COMMITTER:
> + str_name = getenv("GIT_COMMITTER_NAME");
> + str_email = getenv("GIT_COMMITTER_EMAIL");
> + break;
> + case IDENT_PERSON_AUTHOR:
> + str_name = getenv("GIT_AUTHOR_NAME");
> + str_email = getenv("GIT_AUTHOR_EMAIL");
> + break;
> + default:
> + die("invalid parameter to ident_is_sufficient()");
> + }
> +
> + name = !!str_name || ident_source_is_sufficient(source_of_default_name);
> + email = !!str_email || ident_source_is_sufficient(source_of_default_email);
> +
> #ifndef WINDOWS
> - return (user_ident_explicitly_given & IDENT_MAIL_GIVEN);
> + return email;
> #else
> - return (user_ident_explicitly_given == IDENT_ALL_GIVEN);
> + return name && email;
> #endif
> }
It appears that str_name and name are unconditionally computed even
though it does not affect the outcome of the whole thing. When
building for !WINDOWS, I get
ident.c: In function 'ident_is_sufficient':
ident.c:456:6: error: variable 'name' set but not used [-Werror=unused-but-set-variable]
int name, email;
^
cc1: all warnings being treated as errors
make: *** [ident.o] Error 1
as the result of this.
next prev parent reply other threads:[~2016-02-04 22:43 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-04 9:12 [PATCH v4] Add user.useConfigOnly boolean for when ident shouldn't be guessed Dan Aloni
2016-02-04 9:12 ` [PATCH v4 1/3] fmt_ident: refactor strictness checks Dan Aloni
2016-02-04 9:12 ` [PATCH v4 2/3] Add user.useConfigOnly boolean for when ident shouldn't be guessed Dan Aloni
2016-02-04 21:53 ` Junio C Hamano
2016-02-05 6:47 ` Dan Aloni
2016-02-04 9:12 ` [PATCH v4 3/3] ident.c: cleanup wrt ident's source Dan Aloni
2016-02-04 21:33 ` Junio C Hamano
2016-02-04 22:42 ` Junio C Hamano [this message]
2016-02-05 6:40 ` Dan Aloni
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=xmqqvb64f66o.fsf@gitster.mtv.corp.google.com \
--to=gitster@pobox.com \
--cc=alonid@gmail.com \
--cc=git@vger.kernel.org \
--cc=peff@peff.net \
/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.