From 2064b68718ea5f15de76d661ae1f307d67a0cf26 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Mon, 8 Dec 2014 22:39:07 +0100 Subject: with a few exceptions and some remaining files, never return directly on failure, always goto fail by invoking fail_if MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- src/mds-kbdc/make-tree.c | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) (limited to 'src/mds-kbdc/make-tree.c') diff --git a/src/mds-kbdc/make-tree.c b/src/mds-kbdc/make-tree.c index 8a7bb1e..77155b2 100644 --- a/src/mds-kbdc/make-tree.c +++ b/src/mds-kbdc/make-tree.c @@ -425,7 +425,7 @@ static int too_few; * Get the pathname name of the parsed file * * @param filename The filename of the parsed file - * @return The value the caller should return, or 1 if the caller should not return + * @return The value the caller should return, or 1 if the caller should not return, -1 on error */ static int get_pathname(const char* restrict filename) { @@ -769,9 +769,10 @@ static int have_more_parameters(void) */ static int test_for_keyword(const char* restrict keyword) { - int r, ok; - if (r = have_more_parameters(), r <= 0) - return r; + int ok, r = have_more_parameters(); + fail_if (r < 0); + if (r == 0) + return 0; ok = (strstr(line, keyword) == line); line += strlen(keyword); @@ -807,8 +808,10 @@ static int keys(mds_kbdc_tree_t** restrict var) char* arg_end; char* call_end; int r, escape = 0, quote = 0, triangle; - if (r = have_more_parameters(), r <= 0) - return r; + r = have_more_parameters(); + fail_if (r < 0); + if (r == 0) + return 0; arg_end = line; call_end = arg_end; @@ -863,8 +866,10 @@ static int pure_keys(char** restrict var) char* arg_end; char* call_end; int r, escape = 0, quote = 0, triangle; - if (r = have_more_parameters(), r <= 0) - return r; + r = have_more_parameters(); + fail_if (r < 0); + if (r == 0) + return 0; arg_end = line; call_end = arg_end; @@ -1408,8 +1413,10 @@ int parse_to_tree(const char* restrict filename, mds_kbdc_parsed_t* restrict res fail_if (xmalloc(result->source_code, 1, mds_kbdc_source_code_t)); mds_kbdc_source_code_initialise(result->source_code); - if (r = get_pathname(filename), r <= 0) - return r; + r = get_pathname(filename); + fail_if (r < 0); + if (r == 0) + return 0; fail_if (read_source_code()); fail_if (allocate_stacks()); -- cgit v1.2.3-70-g09d2