log: remove all uses of %m specifier in pr_* functions

As our pr_* functions are complex and can call different system calls
inside before actual printing (e.g. gettimeofday for timestamps) actual
errno at the time of printing may be changed.

Let's just use %s + strerror(errno) instead of %m with pr_* functions to
be explicit that errno to string transformation happens before calling
anything else.

Note: tcp_repair_off is called from pie with no pr_perror defined due to
CR_NOGLIBC set and if I use errno variable there I get "Unexpected
undefined symbol: `__errno_location'. External symbol in PIE?", so it
seems there is no way to print errno there, so let's just skip it.

Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
This commit is contained in:
Pavel Tikhomirov 2023-01-25 11:01:56 +03:00 committed by Andrei Vagin
parent 7459d02043
commit 8cfda2748c
5 changed files with 12 additions and 8 deletions

View file

@ -1,6 +1,9 @@
#ifndef COMPEL_LOG_H__
#define COMPEL_LOG_H__
#include <errno.h>
#include <string.h>
#include "uapi/compel/log.h"
#ifndef LOG_PREFIX
@ -45,6 +48,6 @@ extern void compel_print_on_level(unsigned int loglevel, const char *format, ...
#define pr_debug(fmt, ...) compel_print_on_level(COMPEL_LOG_DEBUG, LOG_PREFIX fmt, ##__VA_ARGS__)
#define pr_perror(fmt, ...) pr_err(fmt ": %m\n", ##__VA_ARGS__)
#define pr_perror(fmt, ...) pr_err(fmt ": %s\n", ##__VA_ARGS__, strerror(errno))
#endif /* COMPEL_LOG_H__ */