git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
Cc: git@vger.kernel.org, Elijah Newren <newren@gmail.com>
Subject: Re: [PATCH 2/2] style: do not "break" in switch() after "return"
Date: Tue, 15 Dec 2020 16:30:57 -0800	[thread overview]
Message-ID: <xmqqtusm618e.fsf@gitster.c.googlers.com> (raw)
In-Reply-To: <20201215235027.10401-3-avarab@gmail.com> ("Ævar Arnfjörð Bjarmason"'s message of "Wed, 16 Dec 2020 00:50:27 +0100")

Ævar Arnfjörð Bjarmason  <avarab@gmail.com> writes:

> Remove this unreachable code. It was found by SunCC, it's found by a
> non-fatal warning emitted by SunCC. It's one of the things it's more
> vehement about than GCC & Clang.

This is a borderline Meh to me.

I am even tempted to suggest that, unless all other case arms
return, iow, if there is even a single arm that breaks, it may even
be more future-proof to end any and all case arms that do not
fall-thru to consistently end with break.

If there is some way to fix the compiler, that may be preferrable,
but as I said, this is borderline Meh and I do not care too deeply
either way.

Thanks.

> These return/break cases are just unnecessary however, and as seen
> here the surrounding code just did a plain "return" without a "break"
> already.
>
> Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
> ---
>  apply.c               | 2 --
>  builtin/fast-export.c | 1 -
>  2 files changed, 3 deletions(-)
>
> diff --git a/apply.c b/apply.c
> index 4a4e9a0158c..668b16e9893 100644
> --- a/apply.c
> +++ b/apply.c
> @@ -3948,10 +3948,8 @@ static int check_patch(struct apply_state *state, struct patch *patch)
>  			break; /* happy */
>  		case EXISTS_IN_INDEX:
>  			return error(_("%s: already exists in index"), new_name);
> -			break;
>  		case EXISTS_IN_INDEX_AS_ITA:
>  			return error(_("%s: does not match index"), new_name);
> -			break;
>  		case EXISTS_IN_WORKTREE:
>  			return error(_("%s: already exists in working directory"),
>  				     new_name);
> diff --git a/builtin/fast-export.c b/builtin/fast-export.c
> index d2e33f50052..0a60356b06e 100644
> --- a/builtin/fast-export.c
> +++ b/builtin/fast-export.c
> @@ -923,7 +923,6 @@ static struct commit *get_commit(struct rev_cmdline_entry *e, char *full_name)
>  		if (!tag)
>  			die("Tag %s points nowhere?", e->name);
>  		return (struct commit *)tag;
> -		break;
>  	}
>  	default:
>  		return NULL;

  reply	other threads:[~2020-12-16  0:34 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-14 20:00 [ANNOUNCE] Git v2.30.0-rc0 Junio C Hamano
2020-12-15 23:50 ` [PATCH 0/2] Make v2.30.0-rc0 compile on SunCC Ævar Arnfjörð Bjarmason
2020-12-15 23:50 ` [PATCH 1/2] strmap: do not "return" in a void function Ævar Arnfjörð Bjarmason
2020-12-16  0:24   ` Junio C Hamano
2020-12-15 23:50 ` [PATCH 2/2] style: do not "break" in switch() after "return" Ævar Arnfjörð Bjarmason
2020-12-16  0:30   ` Junio C Hamano [this message]
2020-12-16  0:35     ` Junio C Hamano

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

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqqtusm618e.fsf@gitster.c.googlers.com \
    --to=gitster@pobox.com \
    --cc=avarab@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=newren@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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).