From 81dbf2bee644ef035d054e2101fceea86c50e07d Mon Sep 17 00:00:00 2001 From: Topi Miettinen Date: Mon, 23 Dec 2019 18:58:13 +0200 Subject: libkmod-module: convert return value from system() to errno Don't use exit status of a command directly as errno code, callers will be confused. Signed-off-by: Topi Miettinen --- libkmod/libkmod-module.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/libkmod/libkmod-module.c b/libkmod/libkmod-module.c index 8044a8f..714ee21 100644 --- a/libkmod/libkmod-module.c +++ b/libkmod/libkmod-module.c @@ -980,14 +980,19 @@ static int command_do(struct kmod_module *mod, const char *type, err = system(cmd); unsetenv("MODPROBE_MODULE"); - if (err == -1 || WEXITSTATUS(err)) { - ERR(mod->ctx, "Error running %s command for %s\n", - type, modname); - if (err != -1) - err = -WEXITSTATUS(err); + if (err == -1) { + ERR(mod->ctx, "Could not run %s command '%s' for module %s: %m\n", + type, cmd, modname); + return -EINVAL; } - return err; + if (WEXITSTATUS(err)) { + ERR(mod->ctx, "Error running %s command '%s' for module %s: retcode %d\n", + type, cmd, modname, WEXITSTATUS(err)); + return -EINVAL; + } + + return 0; } struct probe_insert_cb { -- cgit v1.2.3