mirror of
https://github.com/systemd/systemd-stable.git
synced 2024-12-22 13:33:56 +03:00
Check that errno passed log_{interface,link}_*_errno() is non-zero
This commit is contained in:
parent
e89f6ed476
commit
f407219cd1
@ -70,7 +70,7 @@ int dhcp_packet_verify_headers(DHCPPacket *packet, size_t len, bool checksum, ui
|
||||
({ \
|
||||
int _e = (error); \
|
||||
if (DEBUG_LOGGING) \
|
||||
log_interface_full_errno( \
|
||||
log_interface_full_errno_zerook( \
|
||||
sd_dhcp_client_get_ifname(client), \
|
||||
LOG_DEBUG, _e, "DHCPv4 client: " fmt, \
|
||||
##__VA_ARGS__); \
|
||||
|
@ -102,7 +102,7 @@ int client_id_compare_func(const DHCPClientId *a, const DHCPClientId *b);
|
||||
({ \
|
||||
int _e = (error); \
|
||||
if (DEBUG_LOGGING) \
|
||||
log_interface_full_errno( \
|
||||
log_interface_full_errno_zerook( \
|
||||
sd_dhcp_server_get_ifname(server), \
|
||||
LOG_DEBUG, _e, "DHCPv4 server: " fmt, \
|
||||
##__VA_ARGS__); \
|
||||
|
@ -123,7 +123,7 @@ int dhcp6_message_status_from_string(const char *s) _pure_;
|
||||
({ \
|
||||
int _e = (error); \
|
||||
if (DEBUG_LOGGING) \
|
||||
log_interface_full_errno( \
|
||||
log_interface_full_errno_zerook( \
|
||||
sd_dhcp6_client_get_ifname(client), \
|
||||
LOG_DEBUG, _e, "DHCPv6 client: " fmt, \
|
||||
##__VA_ARGS__); \
|
||||
|
@ -40,7 +40,7 @@ sd_lldp_event_t lldp_event_from_string(const char *s) _pure_;
|
||||
({ \
|
||||
int _e = (error); \
|
||||
if (DEBUG_LOGGING) \
|
||||
log_interface_full_errno( \
|
||||
log_interface_full_errno_zerook( \
|
||||
sd_lldp_get_ifname(lldp), \
|
||||
LOG_DEBUG, _e, "LLDP: " fmt, \
|
||||
##__VA_ARGS__); \
|
||||
|
@ -45,7 +45,7 @@ sd_ndisc_event_t ndisc_event_from_string(const char *s) _pure_;
|
||||
({ \
|
||||
int _e = (error); \
|
||||
if (DEBUG_LOGGING) \
|
||||
log_interface_full_errno( \
|
||||
log_interface_full_errno_zerook( \
|
||||
sd_ndisc_get_ifname(ndisc), \
|
||||
LOG_DEBUG, _e, "NDISC: " fmt, \
|
||||
##__VA_ARGS__); \
|
||||
|
@ -129,7 +129,7 @@ struct sd_radv_route_prefix {
|
||||
({ \
|
||||
int _e = (error); \
|
||||
if (DEBUG_LOGGING) \
|
||||
log_interface_full_errno( \
|
||||
log_interface_full_errno_zerook( \
|
||||
sd_radv_get_ifname(radv), \
|
||||
LOG_DEBUG, _e, "RADV: " fmt, \
|
||||
##__VA_ARGS__); \
|
||||
|
@ -79,7 +79,7 @@ struct sd_ipv4acd {
|
||||
({ \
|
||||
int _e = (error); \
|
||||
if (DEBUG_LOGGING) \
|
||||
log_interface_full_errno( \
|
||||
log_interface_full_errno_zerook( \
|
||||
sd_ipv4acd_get_ifname(acd), \
|
||||
LOG_DEBUG, _e, "IPv4ACD: " fmt, \
|
||||
##__VA_ARGS__); \
|
||||
|
@ -53,7 +53,7 @@ struct sd_ipv4ll {
|
||||
({ \
|
||||
int _e = (error); \
|
||||
if (DEBUG_LOGGING) \
|
||||
log_interface_full_errno( \
|
||||
log_interface_full_errno_zerook( \
|
||||
sd_ipv4ll_get_ifname(ll), \
|
||||
LOG_DEBUG, _e, "IPv4LL: " fmt, \
|
||||
##__VA_ARGS__); \
|
||||
|
@ -3,13 +3,20 @@
|
||||
|
||||
#include "log.h"
|
||||
|
||||
#define log_interface_full_errno(ifname, level, error, ...) \
|
||||
#define log_interface_full_errno_zerook(ifname, level, error, ...) \
|
||||
({ \
|
||||
const char *_ifname = (ifname); \
|
||||
_ifname ? log_object_internal(level, error, PROJECT_FILE, __LINE__, __func__, "INTERFACE=", _ifname, NULL, NULL, ##__VA_ARGS__) : \
|
||||
log_internal(level, error, PROJECT_FILE, __LINE__, __func__, ##__VA_ARGS__); \
|
||||
})
|
||||
|
||||
#define log_interface_full_errno(ifname, level, error, ...) \
|
||||
({ \
|
||||
int _error = (error); \
|
||||
ASSERT_NON_ZERO(_error); \
|
||||
log_interface_full_errno_zerook(ifname, level, _error, __VA_ARGS__); \
|
||||
})
|
||||
|
||||
/*
|
||||
* The following macros append INTERFACE= to the message.
|
||||
* The macros require a struct named 'Link' which contains 'char *ifname':
|
||||
@ -21,13 +28,20 @@
|
||||
* See, network/networkd-link.h for example.
|
||||
*/
|
||||
|
||||
#define log_link_full_errno(link, level, error, ...) \
|
||||
#define log_link_full_errno_zerook(link, level, error, ...) \
|
||||
({ \
|
||||
const Link *_l = (link); \
|
||||
log_interface_full_errno(_l ? _l->ifname : NULL, level, error, ##__VA_ARGS__); \
|
||||
log_interface_full_errno_zerook(_l ? _l->ifname : NULL, level, error, __VA_ARGS__); \
|
||||
})
|
||||
|
||||
#define log_link_full(link, level, ...) (void) log_link_full_errno(link, level, 0, __VA_ARGS__)
|
||||
#define log_link_full_errno(link, level, error, ...) \
|
||||
({ \
|
||||
int _error = (error); \
|
||||
ASSERT_NON_ZERO(_error); \
|
||||
log_link_full_errno_zerook(link, level, _error, __VA_ARGS__); \
|
||||
})
|
||||
|
||||
#define log_link_full(link, level, ...) (void) log_link_full_errno_zerook(link, level, 0, __VA_ARGS__)
|
||||
|
||||
#define log_link_debug(link, ...) log_link_full(link, LOG_DEBUG, __VA_ARGS__)
|
||||
#define log_link_info(link, ...) log_link_full(link, LOG_INFO, __VA_ARGS__)
|
||||
|
Loading…
Reference in New Issue
Block a user