]> git.ipfire.org Git - thirdparty/git.git/commitdiff
style: do not "break" in switch() after "return"
authorÆvar Arnfjörð Bjarmason <avarab@gmail.com>
Tue, 15 Dec 2020 23:50:27 +0000 (00:50 +0100)
committerJunio C Hamano <gitster@pobox.com>
Wed, 16 Dec 2020 00:32:50 +0000 (16:32 -0800)
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.

It complains about a lot of other similarly unreachable code, e.g. a
BUG(...) without a "return", and a "return 0" after a long if/else,
both of whom have "return" statements. Those are also genuine
redundancies to a compiler, but arguably make the code a bit easier to
read & less fragile to maintain.

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>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
apply.c
builtin/fast-export.c

diff --git a/apply.c b/apply.c
index 76dba93c974b3814117e3856d875e7e4381d2f62..66cf94393e698de4124f0a6f9ebe3a7c2899f473 100644 (file)
--- 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);
index d2e33f500521bfb5f175ac407875b40a2ca22ee8..0a60356b06eea06c70ae6560769363264000fca3 100644 (file)
@@ -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;