mirror of
https://git.notmuchmail.org/git/notmuch
synced 2025-01-03 07:11:41 +01:00
notmuch setup: Fix a couple of error paths.
We had early returns instead of goto statments, and sure enough, they were leaking. Much cleaner this way.
This commit is contained in:
parent
a5e619f11f
commit
336deb279e
1 changed files with 11 additions and 9 deletions
20
notmuch.c
20
notmuch.c
|
@ -266,13 +266,14 @@ count_files (const char *path, int *count)
|
||||||
int
|
int
|
||||||
setup_command (int argc, char *argv[])
|
setup_command (int argc, char *argv[])
|
||||||
{
|
{
|
||||||
notmuch_database_t *notmuch;
|
notmuch_database_t *notmuch = NULL;
|
||||||
char *mail_directory, *default_path;
|
char *default_path, *mail_directory = NULL;
|
||||||
size_t line_size;
|
size_t line_size;
|
||||||
int count;
|
int count;
|
||||||
add_files_state_t add_files_state;
|
add_files_state_t add_files_state;
|
||||||
double elapsed;
|
double elapsed;
|
||||||
struct timeval tv_now;
|
struct timeval tv_now;
|
||||||
|
notmuch_status_t ret = NOTMUCH_STATUS_SUCCESS;
|
||||||
|
|
||||||
printf ("Welcome to notmuch!\n\n");
|
printf ("Welcome to notmuch!\n\n");
|
||||||
|
|
||||||
|
@ -298,7 +299,6 @@ setup_command (int argc, char *argv[])
|
||||||
printf ("Top-level mail directory [%s]: ", default_path);
|
printf ("Top-level mail directory [%s]: ", default_path);
|
||||||
fflush (stdout);
|
fflush (stdout);
|
||||||
|
|
||||||
mail_directory = NULL;
|
|
||||||
getline (&mail_directory, &line_size, stdin);
|
getline (&mail_directory, &line_size, stdin);
|
||||||
chomp_newline (mail_directory);
|
chomp_newline (mail_directory);
|
||||||
|
|
||||||
|
@ -328,8 +328,8 @@ setup_command (int argc, char *argv[])
|
||||||
if (notmuch == NULL) {
|
if (notmuch == NULL) {
|
||||||
fprintf (stderr, "Failed to create new notmuch database at %s\n",
|
fprintf (stderr, "Failed to create new notmuch database at %s\n",
|
||||||
mail_directory);
|
mail_directory);
|
||||||
free (mail_directory);
|
ret = NOTMUCH_STATUS_FILE_ERROR;
|
||||||
return 1;
|
goto DONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
printf ("OK. Let's take a look at the mail we can find in the directory\n");
|
printf ("OK. Let's take a look at the mail we can find in the directory\n");
|
||||||
|
@ -355,11 +355,13 @@ setup_command (int argc, char *argv[])
|
||||||
print_formatted_seconds (elapsed);
|
print_formatted_seconds (elapsed);
|
||||||
printf (" (%d messages/sec.). \n", (int) (add_files_state.count / elapsed));
|
printf (" (%d messages/sec.). \n", (int) (add_files_state.count / elapsed));
|
||||||
|
|
||||||
notmuch_database_close (notmuch);
|
DONE:
|
||||||
|
if (mail_directory)
|
||||||
|
free (mail_directory);
|
||||||
|
if (notmuch)
|
||||||
|
notmuch_database_close (notmuch);
|
||||||
|
|
||||||
free (mail_directory);
|
return ret;
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
|
Loading…
Reference in a new issue