summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-08-04 01:18:27 +0200
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-08-04 01:18:27 +0200
commitbf1dd4f1ab8ef70f96704c4e2bd95968e1615b37 (patch)
tree807ca034531c8470c5128642be118352dbbf8775
parent85e2e1629ba43ea2b2a11b1f81e3538e3cea64da (diff)
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 <david.oberhollenzer@sigma-star.at>
-rw-r--r--lib/fstree/fstree_from_dir.c4
-rw-r--r--tar/sqfs2tar.c3
-rw-r--r--unpack/restore_fstree.c5
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;