Print a notice if chdir fails

Fixes -Wunused-result warning.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
This commit is contained in:
Gilles Peskine 2023-10-03 10:01:43 +02:00
parent 21bff21575
commit ca26082ab7

View file

@ -433,8 +433,7 @@ static void write_outcome_result(FILE *outcome_file,
} }
#if defined(__unix__) || \ #if defined(__unix__) || \
(defined(__APPLE__) && defined(__MACH__)) || \ (defined(__APPLE__) && defined(__MACH__))
defined(_WIN32)
#define MBEDTLS_HAVE_CHDIR #define MBEDTLS_HAVE_CHDIR
#endif #endif
@ -456,11 +455,11 @@ static void try_chdir(const char *argv0)
} }
memcpy(path, argv0, path_size - 1); memcpy(path, argv0, path_size - 1);
path[path_size - 1] = 0; path[path_size - 1] = 0;
#if defined(_WIN32) int ret = chdir(path);
(void) _chdir(path); if (ret != 0) {
#else mbedtls_fprintf(stderr, "%s: note: chdir(\"%s\") failed.\n",
(void) chdir(path); __func__, path);
#endif }
mbedtls_free(path); mbedtls_free(path);
} }
#endif /* MBEDTLS_HAVE_CHDIR */ #endif /* MBEDTLS_HAVE_CHDIR */