From bf1dd4f1ab8ef70f96704c4e2bd95968e1615b37 Mon Sep 17 00:00:00 2001 From: David Oberhollenzer Date: Sun, 4 Aug 2019 01:18:27 +0200 Subject: Fix functions with side effect being used inside asserts If -DNDEBUG is set, the entire thing is omitted from the output. Signed-off-by: David Oberhollenzer --- lib/fstree/fstree_from_dir.c | 4 +++- tar/sqfs2tar.c | 3 ++- unpack/restore_fstree.c | 5 +++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/fstree/fstree_from_dir.c b/lib/fstree/fstree_from_dir.c index 9066809..a216226 100644 --- a/lib/fstree/fstree_from_dir.c +++ b/lib/fstree/fstree_from_dir.c @@ -22,6 +22,7 @@ static char *get_file_path(tree_node_t *n, const char *name) { char *ptr, *new; + int ret; if (n->parent == NULL) { ptr = strdup(name); @@ -34,7 +35,8 @@ static char *get_file_path(tree_node_t *n, const char *name) if (ptr == NULL) goto fail; - assert(canonicalize_name(ptr) == 0); + ret = canonicalize_name(ptr); + assert(ret == 0); new = realloc(ptr, strlen(ptr) + strlen(name) + 2); if (new == NULL) diff --git a/tar/sqfs2tar.c b/tar/sqfs2tar.c index 3a7d92d..a49efda 100644 --- a/tar/sqfs2tar.c +++ b/tar/sqfs2tar.c @@ -229,7 +229,8 @@ static int write_tree_dfs(fstree_t *fs, tree_node_t *n, data_reader_t *data) return -1; } - assert(canonicalize_name(name) == 0); + ret = canonicalize_name(name); + assert(ret == 0); if (current_subdir != NULL && !keep_as_dir) { if (strcmp(name, current_subdir) == 0) { diff --git a/unpack/restore_fstree.c b/unpack/restore_fstree.c index 7fe074e..5681e0a 100644 --- a/unpack/restore_fstree.c +++ b/unpack/restore_fstree.c @@ -9,8 +9,8 @@ static int create_node(tree_node_t *n, int flags) { tree_node_t *c; + int fd, ret; char *name; - int fd; if (!(flags & UNPACK_QUIET)) { name = fstree_get_path(n); @@ -82,7 +82,8 @@ static int create_node(tree_node_t *n, int flags) return -1; } - assert(canonicalize_name(n->data.file->input_file) == 0); + ret = canonicalize_name(n->data.file->input_file); + assert(ret == 0); break; default: break; -- cgit v1.2.3