1
0
mirror of https://github.com/systemd/systemd.git synced 2024-12-23 21:35:11 +03:00

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.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2018-04-24 13:50:46 +02:00
parent bb1d9534ae
commit a1bcaa075b

View File

@ -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;
}