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>
Stefan Beller committed
Aug 12, 2014 at 23:21 UTC
13b081257a6c996e6c62316be1d1a6f615514ed2
1 file changed
+6
-11
builtin/mailsplit.c
+6
-11
@@ -53,14 +53,16 @@ static int keep_cr;
53
*/
54
static int split_one(FILE *mbox, const char *name, int allow_bare)
55
{
56
- FILE *output = NULL;
56
+ FILE *output;
57
int fd;
58
int status = 0;
59
int is_bare = !is_from_line(buf.buf, buf.len);
60
61
- if (is_bare && !allow_bare)
62
- goto corrupt;
63
-
61
+ if (is_bare && !allow_bare) {
62
+ unlink(name);
63
+ fprintf(stderr, "corrupt mailbox\n");
64
+ exit(1);
65
+ }
66
fd = open(name, O_WRONLY | O_CREAT | O_EXCL, 0666);
67
if (fd < 0)
68
die_errno("cannot open output file '%s'", name);
@@ -91,13 +93,6 @@ static int split_one(FILE *mbox, const char *name, int allow_bare)
93
}
94
fclose(output);
95
return status;
94
-
95
- corrupt:
96
- if (output)
97
- fclose(output);
98
- unlink(name);
99
- fprintf(stderr, "corrupt mailbox\n");
100
- exit(1);
96
}
97
98
static int populate_maildir_list(struct string_list *list, const char *path)