From 9118fb887063b94bf7efbaecce3de75ec1717e2e Mon Sep 17 00:00:00 2001 From: Aaron Ball Date: Sun, 22 Mar 2015 17:43:42 -0600 Subject: Fixed scenario where no commands specified Was segfaulting because the argument count check (>1) was occuring much later than it should have. --- src/main.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/main.c b/src/main.c index d7e3d25..9ee10f9 100644 --- a/src/main.c +++ b/src/main.c @@ -75,6 +75,13 @@ void list_notes(note_list_t* list) { int main(int argc, char* argv[]) { + // Print helptext if no commands specified + if(argc == 1) { + printf("\nNo command specified. Printing help text.\n"); + get_help(); + return 1; + } + /** * Config variables */ @@ -98,7 +105,10 @@ int main(int argc, char* argv[]) { strcat(conf_path, "/.config/noteless.conf"); config_t c; - config_new(&c, conf_path); + int config_status = config_new(&c, conf_path); + if(config_status == -1) { + printf("Config file could not be found.\n"); + } // Override where notes are to be stored // The local version of note path, in case it isn't set in the config @@ -126,13 +136,6 @@ int main(int argc, char* argv[]) { editor = tmp_editor; } - // Print helptext if no commands specified - if(argc == 1) { - printf("\nNo command specified. Printing help text.\n"); - get_help(); - return 1; - } - // // If the init command was passed, we want to init before checking if the // // note path exists, otherwise the error will display and the store will // // never be initialized. @@ -193,6 +196,8 @@ int main(int argc, char* argv[]) { return 1; } + // DANGER WILL ROBINSON!!! + // Clean up note_list_free(&list); config_free(&c); -- cgit v1.2.3