From 45368fc65aebc892bff3ab4b3e844512af26b566 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Wed, 11 Dec 2024 18:08:26 -0500 Subject: Use zix_remove() everywhere and check its return value --- src/state.c | 2 +- test/lilv_test_utils.c | 16 +++++++++++++--- 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 #include #include +#include #include #include @@ -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); -- cgit v1.2.1