]> git.ipfire.org Git - thirdparty/kmod.git/commitdiff
libkmod-module: convert return value from system() to errno
authorTopi Miettinen <toiwoton@gmail.com>
Mon, 23 Dec 2019 16:58:13 +0000 (18:58 +0200)
committerLucas De Marchi <lucas.demarchi@intel.com>
Mon, 30 Dec 2019 00:13:35 +0000 (16:13 -0800)
Don't use exit status of a command directly as errno code, callers
will be confused.

Signed-off-by: Topi Miettinen <toiwoton@gmail.com>
libkmod/libkmod-module.c

index 8044a8fb4360213dc6c76835ddc2455ba81aa0bc..714ee217a69f08774ccd2fcdcdf1dcad657b362f 100644 (file)
@@ -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 {