summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2022-03-30 18:39:50 +0900
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2022-03-30 17:22:11 +0200
commitfb544617170418366337f51b67d065c299b44752 (patch)
tree0479a7204159d720cb1c74b34f2c108be2d1b965
parentd360eafb368eda8e16b68e0d5af1d354a076f395 (diff)
downloadsystemd-fb544617170418366337f51b67d065c299b44752.tar.gz
udev: do not append unknown errno or signal name
Follow-up for 6467bda59d571696b645e8bbdf31926676890956. Addresses https://github.com/systemd/systemd/pull/22871#discussion_r837705779.
-rw-r--r--src/udev/udevd.c22
1 files changed, 16 insertions, 6 deletions
diff --git a/src/udev/udevd.c b/src/udev/udevd.c
index 045e5d1319..0a888993c8 100644
--- a/src/udev/udevd.c
+++ b/src/udev/udevd.c
@@ -374,11 +374,16 @@ static void device_broadcast(sd_device_monitor *monitor, sd_device *dev, int res
(void) device_add_property(dev, "UDEV_WORKER_FAILED", "1");
switch (result) {
- case EVENT_RESULT_NERRNO_MIN ... EVENT_RESULT_NERRNO_MAX:
+ case EVENT_RESULT_NERRNO_MIN ... EVENT_RESULT_NERRNO_MAX: {
+ const char *str;
+
(void) device_add_propertyf(dev, "UDEV_WORKER_ERRNO", "%i", -result);
- (void) device_add_propertyf(dev, "UDEV_WORKER_ERRNO_NAME", "%s", strna(errno_to_name(result)));
- break;
+ str = errno_to_name(result);
+ if (str)
+ (void) device_add_property(dev, "UDEV_WORKER_ERRNO_NAME", str);
+ break;
+ }
case EVENT_RESULT_EXIT_STATUS_BASE ... EVENT_RESULT_EXIT_STATUS_MAX:
(void) device_add_propertyf(dev, "UDEV_WORKER_EXIT_STATUS", "%i", result - EVENT_RESULT_EXIT_STATUS_BASE);
break;
@@ -387,11 +392,16 @@ static void device_broadcast(sd_device_monitor *monitor, sd_device *dev, int res
assert_not_reached();
break;
- case EVENT_RESULT_SIGNAL_BASE ... EVENT_RESULT_SIGNAL_MAX:
+ case EVENT_RESULT_SIGNAL_BASE ... EVENT_RESULT_SIGNAL_MAX: {
+ const char *str;
+
(void) device_add_propertyf(dev, "UDEV_WORKER_SIGNAL", "%i", result - EVENT_RESULT_SIGNAL_BASE);
- (void) device_add_propertyf(dev, "UDEV_WORKER_SIGNAL_NAME", "%s", strna(signal_to_string(result - EVENT_RESULT_SIGNAL_BASE)));
- break;
+ str = signal_to_string(result - EVENT_RESULT_SIGNAL_BASE);
+ if (str)
+ (void) device_add_property(dev, "UDEV_WORKER_SIGNAL_NAME", str);
+ break;
+ }
default:
log_device_warning(dev, "Unknown event result \"%i\", ignoring.", result);
}