From ca26082ab7cac79268b98920632656d0c39ff18c Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Tue, 3 Oct 2023 10:01:43 +0200 Subject: [PATCH] Print a notice if chdir fails Fixes -Wunused-result warning. Signed-off-by: Gilles Peskine --- tests/suites/host_test.function | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/tests/suites/host_test.function b/tests/suites/host_test.function index 3a3cb3414..1f95fb4b5 100644 --- a/tests/suites/host_test.function +++ b/tests/suites/host_test.function @@ -433,8 +433,7 @@ static void write_outcome_result(FILE *outcome_file, } #if defined(__unix__) || \ - (defined(__APPLE__) && defined(__MACH__)) || \ - defined(_WIN32) + (defined(__APPLE__) && defined(__MACH__)) #define MBEDTLS_HAVE_CHDIR #endif @@ -456,11 +455,11 @@ static void try_chdir(const char *argv0) } memcpy(path, argv0, path_size - 1); path[path_size - 1] = 0; -#if defined(_WIN32) - (void) _chdir(path); -#else - (void) chdir(path); -#endif + int ret = chdir(path); + if (ret != 0) { + mbedtls_fprintf(stderr, "%s: note: chdir(\"%s\") failed.\n", + __func__, path); + } mbedtls_free(path); } #endif /* MBEDTLS_HAVE_CHDIR */