Re: [PATCH] refs.c: use skip_prefix() in prettify_refname()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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é



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]