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>
This commit is contained in:
parent
e6aaa39347
commit
13b081257a
@ -53,14 +53,16 @@ static int keep_cr;
|
|||||||
*/
|
*/
|
||||||
static int split_one(FILE *mbox, const char *name, int allow_bare)
|
static int split_one(FILE *mbox, const char *name, int allow_bare)
|
||||||
{
|
{
|
||||||
FILE *output = NULL;
|
FILE *output;
|
||||||
int fd;
|
int fd;
|
||||||
int status = 0;
|
int status = 0;
|
||||||
int is_bare = !is_from_line(buf.buf, buf.len);
|
int is_bare = !is_from_line(buf.buf, buf.len);
|
||||||
|
|
||||||
if (is_bare && !allow_bare)
|
if (is_bare && !allow_bare) {
|
||||||
goto corrupt;
|
unlink(name);
|
||||||
|
fprintf(stderr, "corrupt mailbox\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
fd = open(name, O_WRONLY | O_CREAT | O_EXCL, 0666);
|
fd = open(name, O_WRONLY | O_CREAT | O_EXCL, 0666);
|
||||||
if (fd < 0)
|
if (fd < 0)
|
||||||
die_errno("cannot open output file '%s'", name);
|
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);
|
fclose(output);
|
||||||
return status;
|
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)
|
static int populate_maildir_list(struct string_list *list, const char *path)
|
||||||
|
Loading…
Reference in New Issue
Block a user