universal7885: dlopener: Use more common exit code

This commit is contained in:
roynatech2544 2022-11-30 17:42:18 +09:00
commit 12ee518097

View file

@ -1,27 +1,26 @@
#include <dlfcn.h> #include <dlfcn.h>
#include <errno.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[]) { int main(int argc, char *argv[]) {
const char *path; const char *path;
int status = -EINVAL;
void *handle = NULL; void *handle = NULL;
int ret = EXIT_FAILURE;
if (argc <= 1) { if (argc <= 1) {
printf("Please specify a module to load!\n"); printf("Please specify a module to load!\n");
return status; return ret;
} }
path = argv[1]; path = argv[1];
handle = dlopen(path, RTLD_NOW); handle = dlopen(path, RTLD_NOW);
if (handle == NULL) { if (handle == NULL) {
char const *err_str = dlerror(); const char *err_str = dlerror();
printf("load: module=%s\n%s\n", path, err_str ? err_str : "unknown"); printf("load: module=%s\n%s\n", path, err_str ? err_str : "unknown");
status = -EINVAL;
} else { } else {
printf("load: module=%s %s\n", path, "Success!"); printf("load: module=%s %s\n", path, "Success!");
ret = EXIT_SUCCESS;
} }
return ret;
return status;
} }