From 92a22fef93a528030669e357a32c19f143a2d3b5 Mon Sep 17 00:00:00 2001 From: Stefano Brivio Date: Sat, 15 Jun 2024 00:37:11 +0200 Subject: treewide: Replace perror() calls with calls to logging functions perror() prints directly to standard error, but in many cases standard error might be already closed, or we might want to skip logging, based on configuration. Our logging functions provide all that. While at it, make errors more descriptive, replacing some of the existing basic perror-style messages. Signed-off-by: Stefano Brivio Reviewed-by: David Gibson --- arch.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'arch.c') diff --git a/arch.c b/arch.c index 80a41bc..04bebfc 100644 --- a/arch.c +++ b/arch.c @@ -18,6 +18,8 @@ #include #include +#include "log.h" + /** * arch_avx2_exec() - Switch to AVX2 build if supported * @argv: Arguments from command line @@ -28,10 +30,8 @@ void arch_avx2_exec(char **argv) char exe[PATH_MAX] = { 0 }; const char *p; - if (readlink("/proc/self/exe", exe, PATH_MAX - 1) < 0) { - perror("readlink /proc/self/exe"); - exit(EXIT_FAILURE); - } + if (readlink("/proc/self/exe", exe, PATH_MAX - 1) < 0) + die_perror("Failed to read own /proc/self/exe link"); p = strstr(exe, ".avx2"); if (p && strlen(p) == strlen(".avx2")) @@ -42,7 +42,7 @@ void arch_avx2_exec(char **argv) snprintf(new_path, PATH_MAX + sizeof(".avx2"), "%s.avx2", exe); execve(new_path, argv, environ); - perror("Can't run AVX2 build, using non-AVX2 version"); + warn_perror("Can't run AVX2 build, using non-AVX2 version"); } } #else -- cgit v1.2.3