aboutsummaryrefslogtreecommitdiffstats
path: root/src/mds-kbdc/make-tree.c
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2014-12-08 22:39:07 +0100
committerMattias Andrée <maandree@operamail.com>2014-12-08 22:39:07 +0100
commit2064b68718ea5f15de76d661ae1f307d67a0cf26 (patch)
tree3b8f93932cb4a13ab6001f165de7714ec7e86848 /src/mds-kbdc/make-tree.c
parentupdate the texinfo manual for the new use of fail_if (diff)
downloadmds-2064b68718ea5f15de76d661ae1f307d67a0cf26.tar.gz
mds-2064b68718ea5f15de76d661ae1f307d67a0cf26.tar.bz2
mds-2064b68718ea5f15de76d661ae1f307d67a0cf26.tar.xz
with a few exceptions and some remaining files, never return directly on failure, always goto fail by invoking fail_if
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to '')
-rw-r--r--src/mds-kbdc/make-tree.c27
1 files changed, 17 insertions, 10 deletions
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());