summaryrefslogtreecommitdiff
path: root/builtin/mailsplit.c
diff options
context:
space:
mode:
authorStefan Beller <stefanbeller@gmail.com>2014-08-12 21:21:27 (GMT)
committerJunio C Hamano <gitster@pobox.com>2014-08-13 16:50:58 (GMT)
commit13b081257a6c996e6c62316be1d1a6f615514ed2 (patch)
tree05c761f0b673197fbae8fca5d9af60739be5d1bf /builtin/mailsplit.c
parente6aaa393478bf3ee9f4cde8d82cd258c034cd335 (diff)
downloadgit-13b081257a6c996e6c62316be1d1a6f615514ed2.zip
git-13b081257a6c996e6c62316be1d1a6f615514ed2.tar.gz
git-13b081257a6c996e6c62316be1d1a6f615514ed2.tar.bz2
mailsplit.c: remove dead code
This was found by coverity. (Id: 290001) The variable 'output' is assigned to a value after all gotos to the corrupt label. Remove the goto by moving the errorhandling code to the condition, which detects the error. Signed-off-by: Stefan Beller <stefanbeller@gmail.com> Helped-by: René Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/mailsplit.c')
-rw-r--r--builtin/mailsplit.c17
1 files changed, 6 insertions, 11 deletions
diff --git a/builtin/mailsplit.c b/builtin/mailsplit.c
index 06296d4..763cda0 100644
--- a/builtin/mailsplit.c
+++ b/builtin/mailsplit.c
@@ -53,14 +53,16 @@ static int keep_cr;
*/
static int split_one(FILE *mbox, const char *name, int allow_bare)
{
- FILE *output = NULL;
+ FILE *output;
int fd;
int status = 0;
int is_bare = !is_from_line(buf.buf, buf.len);
- if (is_bare && !allow_bare)
- goto corrupt;
-
+ if (is_bare && !allow_bare) {
+ unlink(name);
+ fprintf(stderr, "corrupt mailbox\n");
+ exit(1);
+ }
fd = open(name, O_WRONLY | O_CREAT | O_EXCL, 0666);
if (fd < 0)
die_errno("cannot open output file '%s'", name);
@@ -91,13 +93,6 @@ static int split_one(FILE *mbox, const char *name, int allow_bare)
}
fclose(output);
return status;
-
- corrupt:
- if (output)
- fclose(output);
- unlink(name);
- fprintf(stderr, "corrupt mailbox\n");
- exit(1);
}
static int populate_maildir_list(struct string_list *list, const char *path)