aboutgitcodebugslistschat
path: root/arch.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch.c')
-rw-r--r--arch.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/arch.c b/arch.c
index 80a41bc..e1ee729 100644
--- a/arch.c
+++ b/arch.c
@@ -18,6 +18,9 @@
#include <string.h>
#include <unistd.h>
+#include "log.h"
+#include "util.h"
+
/**
* arch_avx2_exec() - Switch to AVX2 build if supported
* @argv: Arguments from command line
@@ -28,10 +31,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"))
@@ -40,9 +41,12 @@ void arch_avx2_exec(char **argv)
if (__builtin_cpu_supports("avx2")) {
char new_path[PATH_MAX + sizeof(".avx2")];
- 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");
+ if (snprintf_check(new_path, PATH_MAX + sizeof(".avx2"),
+ "%s.avx2", exe))
+ die_perror("Can't build AVX2 executable path");
+
+ execv(new_path, argv);
+ warn_perror("Can't run AVX2 build, using non-AVX2 version");
}
}
#else