mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2026-02-04 16:20:29 +01:00
evdev: don't execute snprintf if not gonna print
Signed-off-by: Konstantin Kharlamov <Hi-Angel@yandex.ru>
This commit is contained in:
parent
d9338b001c
commit
15e64b7b60
3 changed files with 16 additions and 2 deletions
|
|
@ -713,6 +713,9 @@ evdev_log_msg(struct evdev_device *device,
|
|||
va_list args;
|
||||
char buf[1024];
|
||||
|
||||
if (!is_logged(evdev_libinput_context(device), priority))
|
||||
return;
|
||||
|
||||
/* Anything info and above is user-visible, use the device name */
|
||||
snprintf(buf,
|
||||
sizeof(buf),
|
||||
|
|
@ -741,6 +744,9 @@ evdev_log_msg_ratelimit(struct evdev_device *device,
|
|||
|
||||
enum ratelimit_state state;
|
||||
|
||||
if (!is_logged(evdev_libinput_context(device), priority))
|
||||
return;
|
||||
|
||||
state = ratelimit_test(ratelimit);
|
||||
if (state == RATELIMIT_EXCEEDED)
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -404,6 +404,15 @@ typedef void (*libinput_source_dispatch_t)(void *data);
|
|||
#define log_bug_libinput_ratelimit(li_, r_, ...) log_msg_ratelimit((li_), (r_), LIBINPUT_LOG_PRIORITY_ERROR, "libinput bug: " __VA_ARGS__)
|
||||
#define log_bug_client_ratelimit(li_, r_, ...) log_msg_ratelimit((li_), (r_), LIBINPUT_LOG_PRIORITY_ERROR, "client bug: " __VA_ARGS__)
|
||||
|
||||
static inline bool
|
||||
is_logged(const struct libinput *libinput,
|
||||
enum libinput_log_priority priority)
|
||||
{
|
||||
return libinput->log_handler &&
|
||||
libinput->log_priority <= priority;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
log_msg_ratelimit(struct libinput *libinput,
|
||||
struct ratelimit *ratelimit,
|
||||
|
|
|
|||
|
|
@ -262,8 +262,7 @@ log_msg_va(struct libinput *libinput,
|
|||
const char *format,
|
||||
va_list args)
|
||||
{
|
||||
if (libinput->log_handler &&
|
||||
libinput->log_priority <= priority)
|
||||
if (is_logged(libinput, priority))
|
||||
libinput->log_handler(libinput, priority, format, args);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue