From: "René Scharfe" <l.s.r@web.de>
To: Jeff King <peff@peff.net>, Junio C Hamano <gitster@pobox.com>
Cc: "SZEDER Gábor" <szeder.dev@gmail.com>, git@vger.kernel.org
Subject: Re: [PATCH] refs.c: use skip_prefix() in prettify_refname()
Date: Thu, 23 Mar 2017 21:06:09 +0100 [thread overview]
Message-ID: <83a38f4d-a80e-e41c-a563-05585377ac13@web.de> (raw)
In-Reply-To: <20170323193919.twwfwdoulo2hjz24@sigill.intra.peff.net>
Am 23.03.2017 um 20:39 schrieb Jeff King:
> On Thu, Mar 23, 2017 at 12:33:06PM -0700, Junio C Hamano wrote:
>
>>>> Nice, but why add the "if" when it's doing nothing?
>>>
>>> It's short-circuiting in the conditional.
>>
>> I think René meant this:
>>
>> /* just for side effects */
>> skip_prefix(name, "refs/heads/", &name) ||
>> skip_prefix(name, "refs/tags/", &name) ||
>> skip_prefix(name, "refs/remotes/", &name);
>>
>> return name;
>>
>> which still short-sircuits, even though I do think it looks
>> strange; "correct but strange".
>
> And it causes the compiler to complain that the value is not used.
Ah, that explains it, thanks. The "if" is strange, but wrapping the
expression in (void)(...) isn't better.
Clang doesn't warn about the code above by the way.
René
prev parent reply other threads:[~2017-03-23 20:06 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-23 15:50 [PATCH] refs.c: use skip_prefix() in prettify_refname() SZEDER Gábor
2017-03-23 19:18 ` René Scharfe
2017-03-23 19:23 ` Jeff King
2017-03-23 19:31 ` Stefan Beller
2017-03-23 19:33 ` Junio C Hamano
2017-03-23 19:36 ` René Scharfe
2017-03-23 19:40 ` Junio C Hamano
2017-03-23 19:39 ` Jeff King
2017-03-23 20:05 ` Junio C Hamano
2017-03-23 20:06 ` SZEDER Gábor
2017-03-23 20:06 ` René Scharfe [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=83a38f4d-a80e-e41c-a563-05585377ac13@web.de \
--to=l.s.r@web.de \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=peff@peff.net \
--cc=szeder.dev@gmail.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 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).