From a1bcaa075bba1139378d745569c99b985892f6ca Mon Sep 17 00:00:00 2001 From: =?utf8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Tue, 24 Apr 2018 13:50:46 +0200 Subject: [PATCH] core/device: avoid bogus errno use and invert ratelimit_test() I'm not sure if I understand the original code. AFAICS, errno does not have to be set at all in this callback. ratelimit_test() returns positive if we are under limit. The code would only log if the condition happened very often, which I assume is not inteded, and this check was supposed to prevent too much logging. --- src/core/device.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/device.c b/src/core/device.c index 12dccdb975c..296f763f87f 100644 --- a/src/core/device.c +++ b/src/core/device.c @@ -782,8 +782,8 @@ static int device_dispatch_io(sd_event_source *source, int fd, uint32_t revents, if (revents != EPOLLIN) { static RATELIMIT_DEFINE(limit, 10*USEC_PER_SEC, 5); - if (!ratelimit_test(&limit)) - log_error_errno(errno, "Failed to get udev event: %m"); + if (ratelimit_test(&limit)) + log_warning("Failed to get udev event"); if (!(revents & EPOLLIN)) return 0; } -- 2.47.3