summaryrefslogtreecommitdiff
path: root/src/udev
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2014-11-28 10:13:40 -0500
committerAnthony G. Basile <blueness@gentoo.org>2014-11-28 10:13:40 -0500
commit107530eaa336ae23f53a0f573901799564379106 (patch)
treec210091f470b6fe895cfac3bfcbcf9d107153e14 /src/udev
parent62d9908a8432f115833f07bb9dadd8f7d8e1c316 (diff)
log: add an "error" parameter to all low-level logging calls and intrdouce log_error_errno() as log calls that take error numbers
This change has two benefits: - The format string %m will now resolve to the specified error (or to errno if the specified error is 0. This allows getting rid of a ton of strerror() invocations, a function that is not thread-safe. - The specified error can be passed to the journal in the ERRNO= field. Now of course, we just need somebody to convert all cases of this: log_error("Something happened: %s", strerror(-r)); into thus: log_error_errno(-r, "Something happened: %m"); Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
Diffstat (limited to 'src/udev')
-rw-r--r--src/udev/udev-builtin-kmod.c24
1 files changed, 11 insertions, 13 deletions
diff --git a/src/udev/udev-builtin-kmod.c b/src/udev/udev-builtin-kmod.c
index 5c50f7856d..0d9c9d9c1a 100644
--- a/src/udev/udev-builtin-kmod.c
+++ b/src/udev/udev-builtin-kmod.c
@@ -34,7 +34,7 @@
#include "udev.h"
-static struct kmod_ctx *ctx;
+static struct kmod_ctx *ctx = NULL;
static int load_module(struct udev *udev, const char *alias) {
int err;
@@ -47,18 +47,18 @@ static int load_module(struct udev *udev, const char *alias) {
return err;
if (list == NULL)
- log_debug("no module matches '%s'", alias);
+ log_debug("No module matches '%s'", alias);
kmod_list_foreach(l, list) {
struct kmod_module *mod = kmod_module_get_module(l);
err = kmod_module_probe_insert_module(mod, KMOD_PROBE_APPLY_BLACKLIST, NULL, NULL, NULL, NULL);
if (err == KMOD_PROBE_APPLY_BLACKLIST)
- log_debug("module '%s' is blacklisted", kmod_module_get_name(mod));
+ log_debug("Module '%s' is blacklisted", kmod_module_get_name(mod));
else if (err == 0)
- log_debug("inserted '%s'", kmod_module_get_name(mod));
+ log_debug("Inserted '%s'", kmod_module_get_name(mod));
else
- log_debug("failed to insert '%s'", kmod_module_get_name(mod));
+ log_debug("Failed to insert '%s'", kmod_module_get_name(mod));
kmod_module_unref(mod);
}
@@ -85,10 +85,8 @@ static int load_module(struct udev *udev, const char *alias) {
return err;
}
-_printf_(6,0)
-static void udev_kmod_log(void *data, int priority, const char *file, int line,
- const char *fn, const char *format, va_list args) {
- log_metav(priority, file, line, fn, format, args);
+_printf_(6,0) static void udev_kmod_log(void *data, int priority, const char *file, int line, const char *fn, const char *format, va_list args) {
+ log_metav(priority, 0, file, line, fn, format, args);
}
static int builtin_kmod(struct udev_device *dev, int argc, char *argv[], bool test) {
@@ -106,7 +104,7 @@ static int builtin_kmod(struct udev_device *dev, int argc, char *argv[], bool te
}
for (i = 2; argv[i]; i++) {
- log_debug("execute '%s' '%s'", argv[1], argv[i]);
+ log_debug("Execute '%s' '%s'", argv[1], argv[i]);
load_module(udev, argv[i]);
}
@@ -123,7 +121,7 @@ static int builtin_kmod_init(struct udev *udev) {
if (!ctx)
return -ENOMEM;
- log_debug("load module index");
+ log_debug("Load module index");
kmod_set_log_fn(ctx, udev_kmod_log, udev);
kmod_load_resources(ctx);
#endif
@@ -133,7 +131,7 @@ static int builtin_kmod_init(struct udev *udev) {
/* called on udev shutdown and reload request */
static void builtin_kmod_exit(struct udev *udev) {
#ifdef HAVE_LIBKMOD
- log_debug("unload module index");
+ log_debug("Unload module index");
ctx = kmod_unref(ctx);
#endif
}
@@ -141,7 +139,7 @@ static void builtin_kmod_exit(struct udev *udev) {
#ifdef HAVE_LIBKMOD
/* called every couple of seconds during event activity; 'true' if config has changed */
static bool builtin_kmod_validate(struct udev *udev) {
- log_debug("validate module index");
+ log_debug("Validate module index");
if (!ctx)
return false;
return (kmod_validate_resources(ctx) != KMOD_RESOURCES_OK);