summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/libudev/libudev-device-private.c6
-rw-r--r--src/libudev/libudev-device.c6
-rw-r--r--src/shared/log.h13
-rw-r--r--src/udev/udev-rules.c8
4 files changed, 15 insertions, 18 deletions
diff --git a/src/libudev/libudev-device-private.c b/src/libudev/libudev-device-private.c
index be3f17fd47..fb4c6e2940 100644
--- a/src/libudev/libudev-device-private.c
+++ b/src/libudev/libudev-device-private.c
@@ -128,10 +128,8 @@ int udev_device_update_db(struct udev_device *udev_device)
strscpyl(filename_tmp, sizeof(filename_tmp), filename, ".tmp", NULL);
mkdir_parents(filename_tmp, 0755);
f = fopen(filename_tmp, "we");
- if (f == NULL) {
- log_debug_errno(errno, "unable to create temporary db file '%s': %m", filename_tmp);
- return -errno;
- }
+ if (f == NULL)
+ return log_debug_errno(errno, "unable to create temporary db file '%s': %m", filename_tmp);
/*
* set 'sticky' bit to indicate that we should not clean the
diff --git a/src/libudev/libudev-device.c b/src/libudev/libudev-device.c
index 400fb74d83..5f196bd9b8 100644
--- a/src/libudev/libudev-device.c
+++ b/src/libudev/libudev-device.c
@@ -534,10 +534,8 @@ int udev_device_read_db(struct udev_device *udev_device, const char *dbfile)
}
f = fopen(dbfile, "re");
- if (f == NULL) {
- log_debug_errno(errno, "no db file to read %s: %m", dbfile);
- return -errno;
- }
+ if (f == NULL)
+ return log_debug_errno(errno, "no db file to read %s: %m", dbfile);
/* devices with a database entry are initialized */
udev_device->is_initialized = true;
diff --git a/src/shared/log.h b/src/shared/log.h
index 3e317a5e94..8eda7bf695 100644
--- a/src/shared/log.h
+++ b/src/shared/log.h
@@ -89,11 +89,13 @@ noreturn void log_assert_failed_unreachable(
/* Logging with level */
-#define log_full_errno(level, error, ...) \
- do { \
- if (log_get_max_level() >= (level)) \
- log_internal((level), error, __FILE__, __LINE__, __func__, __VA_ARGS__); \
- } while (false)
+#define log_full_errno(level, error, ...) \
+ ({ \
+ int _l = (level), _e = (error); \
+ (log_get_max_level() >= _l) \
+ ? log_internal(_l, _e, __FILE__, __LINE__, __func__, __VA_ARGS__) \
+ : -abs(_e); \
+ })
#define log_full(level, ...) log_full_errno(level, 0, __VA_ARGS__)
@@ -120,7 +122,6 @@ noreturn void log_assert_failed_unreachable(
#endif
/* This modifies the buffer passed! */
-//#define log_dump(level, buffer) log_dump_internal(level, 0, __FILE__, __LINE__, __func__, buffer)
#define log_oom() log_oom_internal(__FILE__, __LINE__, __func__)
diff --git a/src/udev/udev-rules.c b/src/udev/udev-rules.c
index 5e901598f5..ddbde5a784 100644
--- a/src/udev/udev-rules.c
+++ b/src/udev/udev-rules.c
@@ -2719,10 +2719,10 @@ int udev_rules_apply_static_dev_perms(struct udev_rules *rules) {
strscpyl(tag_symlink, sizeof(tag_symlink), tags_dir, unescaped_filename, NULL);
r = symlink(device_node, tag_symlink);
- if (r < 0 && errno != EEXIST) {
- log_error_errno(errno, "failed to create symlink %s -> %s: %m", tag_symlink, device_node);
- return -errno;
- } else
+ if (r < 0 && errno != EEXIST)
+ return log_error_errno(errno, "failed to create symlink %s -> %s: %m",
+ tag_symlink, device_node);
+ else
r = 0;
}
}