diff options
author | David Robillard <d@drobilla.net> | 2024-12-11 18:08:26 -0500 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2024-12-11 19:08:56 -0500 |
commit | 45368fc65aebc892bff3ab4b3e844512af26b566 (patch) | |
tree | fd067f0211a03736b64e2254441a8fa8c2358265 | |
parent | 8a70f7ab46fa4587a2f3db368f175fa1b8718bfe (diff) | |
download | lilv-45368fc65aebc892bff3ab4b3e844512af26b566.tar.gz lilv-45368fc65aebc892bff3ab4b3e844512af26b566.tar.bz2 lilv-45368fc65aebc892bff3ab4b3e844512af26b566.zip |
Use zix_remove() everywhere and check its return value
-rw-r--r-- | src/state.c | 2 | ||||
-rw-r--r-- | test/lilv_test_utils.c | 16 | ||||
-rw-r--r-- | test/test_state.c | 8 |
3 files changed, 18 insertions, 8 deletions
diff --git a/src/state.c b/src/state.c index b05d455..169ccbe 100644 --- a/src/state.c +++ b/src/state.c @@ -1234,7 +1234,7 @@ lilv_state_make_links(const LilvState* state, const char* dir) if (!strcmp(dir, link_dir)) { // Link directory is save directory, make link at exact path - remove(pat); + (void)zix_remove(pat); maybe_symlink(pm->abs, pat); } else { // Make a link in the link directory to external file diff --git a/test/lilv_test_utils.c b/test/lilv_test_utils.c index 1cb8d13..ba291d7 100644 --- a/test/lilv_test_utils.c +++ b/test/lilv_test_utils.c @@ -8,6 +8,7 @@ #include <zix/allocator.h> #include <zix/filesystem.h> #include <zix/path.h> +#include <zix/status.h> #include <errno.h> #include <stdbool.h> @@ -136,19 +137,28 @@ start_bundle(LilvTestEnv* env, return 0; } +static void +remove_temporary(const char* const path) +{ + const ZixStatus st = zix_remove(path); + if (st) { + fprintf(stderr, "Failed to remove '%s' (%s)\n", path, zix_strerror(st)); + } +} + void delete_bundle(LilvTestEnv* env) { if (env->test_content_path) { - zix_remove(env->test_content_path); + remove_temporary(env->test_content_path); } if (env->test_manifest_path) { - zix_remove(env->test_manifest_path); + remove_temporary(env->test_manifest_path); } if (env->test_bundle_path) { - remove(env->test_bundle_path); + remove_temporary(env->test_bundle_path); } zix_free(NULL, env->test_content_path); diff --git a/test/test_state.c b/test/test_state.c index 378ecfe..aeb3f02 100644 --- a/test/test_state.c +++ b/test/test_state.c @@ -744,7 +744,7 @@ test_multi_save(void) lilv_instance_free(instance); zix_dir_for_each(bundle_1_path, NULL, remove_file); - zix_remove(bundle_1_path); + assert(!zix_remove(bundle_1_path)); cleanup_test_directories(dirs); free(state_path); @@ -852,9 +852,9 @@ test_files_round_trip(void) zix_dir_for_each(bundle_1_1_path, NULL, remove_file); zix_dir_for_each(bundle_1_2_path, NULL, remove_file); zix_dir_for_each(bundle_2_path, NULL, remove_file); - zix_remove(bundle_1_1_path); - zix_remove(bundle_1_2_path); - zix_remove(bundle_2_path); + assert(!zix_remove(bundle_1_1_path)); + assert(!zix_remove(bundle_1_2_path)); + assert(!zix_remove(bundle_2_path)); cleanup_test_directories(dirs); lilv_state_free(state_2_loaded); |