1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2025-01-08 21:17:47 +03:00

libsystemd-network: use macro for definitions of log_{lldp,dhcp,…}_errno

No functional change.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2021-04-14 23:12:50 +02:00
parent f407219cd1
commit a0c2541b6b
9 changed files with 55 additions and 84 deletions

View File

@ -66,15 +66,10 @@ int dhcp_packet_verify_headers(DHCPPacket *packet, size_t len, bool checksum, ui
#define DHCP_CLIENT_DONT_DESTROY(client) \
_cleanup_(sd_dhcp_client_unrefp) _unused_ sd_dhcp_client *_dont_destroy_##client = sd_dhcp_client_ref(client)
#define log_dhcp_client_errno(client, error, fmt, ...) \
({ \
int _e = (error); \
if (DEBUG_LOGGING) \
log_interface_full_errno_zerook( \
sd_dhcp_client_get_ifname(client), \
LOG_DEBUG, _e, "DHCPv4 client: " fmt, \
##__VA_ARGS__); \
-ERRNO_VALUE(_e); \
})
#define log_dhcp_client_errno(client, error, fmt, ...) \
log_interface_prefix_full_errno_zerook( \
"DHCPv4 client: ", \
sd_dhcp_client_get_ifname(client), \
error, fmt, ##__VA_ARGS__)
#define log_dhcp_client(client, fmt, ...) \
log_dhcp_client_errno(client, 0, fmt, ##__VA_ARGS__)

View File

@ -98,15 +98,10 @@ int dhcp_server_send_packet(sd_dhcp_server *server,
void client_id_hash_func(const DHCPClientId *p, struct siphash *state);
int client_id_compare_func(const DHCPClientId *a, const DHCPClientId *b);
#define log_dhcp_server_errno(server, error, fmt, ...) \
({ \
int _e = (error); \
if (DEBUG_LOGGING) \
log_interface_full_errno_zerook( \
sd_dhcp_server_get_ifname(server), \
LOG_DEBUG, _e, "DHCPv4 server: " fmt, \
##__VA_ARGS__); \
-ERRNO_VALUE(_e); \
})
#define log_dhcp_server_errno(server, error, fmt, ...) \
log_interface_prefix_full_errno_zerook( \
"DHCPv4 server: ", \
sd_dhcp_server_get_ifname(server), \
error, fmt, ##__VA_ARGS__)
#define log_dhcp_server(server, fmt, ...) \
log_dhcp_server_errno(server, 0, fmt, ##__VA_ARGS__)

View File

@ -119,15 +119,10 @@ int dhcp6_message_type_from_string(const char *s) _pure_;
const char *dhcp6_message_status_to_string(int s) _const_;
int dhcp6_message_status_from_string(const char *s) _pure_;
#define log_dhcp6_client_errno(client, error, fmt, ...) \
({ \
int _e = (error); \
if (DEBUG_LOGGING) \
log_interface_full_errno_zerook( \
sd_dhcp6_client_get_ifname(client), \
LOG_DEBUG, _e, "DHCPv6 client: " fmt, \
##__VA_ARGS__); \
-ERRNO_VALUE(_e); \
})
#define log_dhcp6_client(client, fmt, ...) \
#define log_dhcp6_client_errno(client, error, fmt, ...) \
log_interface_prefix_full_errno_zerook( \
"DHCPv6 client: ", \
sd_dhcp6_client_get_ifname(client), \
error, fmt, ##__VA_ARGS__)
#define log_dhcp6_client(client, fmt, ...) \
log_dhcp6_client_errno(client, 0, fmt, ##__VA_ARGS__)

View File

@ -36,15 +36,10 @@ struct sd_lldp {
const char* lldp_event_to_string(sd_lldp_event_t e) _const_;
sd_lldp_event_t lldp_event_from_string(const char *s) _pure_;
#define log_lldp_errno(lldp, error, fmt, ...) \
({ \
int _e = (error); \
if (DEBUG_LOGGING) \
log_interface_full_errno_zerook( \
sd_lldp_get_ifname(lldp), \
LOG_DEBUG, _e, "LLDP: " fmt, \
##__VA_ARGS__); \
-ERRNO_VALUE(_e); \
})
#define log_lldp(lldp, fmt, ...) \
#define log_lldp_errno(lldp, error, fmt, ...) \
log_interface_prefix_full_errno_zerook( \
"LLDP: ", \
sd_lldp_get_ifname(lldp), \
error, fmt, ##__VA_ARGS__)
#define log_lldp(lldp, fmt, ...) \
log_lldp_errno(lldp, 0, fmt, ##__VA_ARGS__)

View File

@ -41,15 +41,10 @@ struct sd_ndisc {
const char* ndisc_event_to_string(sd_ndisc_event_t e) _const_;
sd_ndisc_event_t ndisc_event_from_string(const char *s) _pure_;
#define log_ndisc_errno(ndisc, error, fmt, ...) \
({ \
int _e = (error); \
if (DEBUG_LOGGING) \
log_interface_full_errno_zerook( \
sd_ndisc_get_ifname(ndisc), \
LOG_DEBUG, _e, "NDISC: " fmt, \
##__VA_ARGS__); \
-ERRNO_VALUE(_e); \
})
#define log_ndisc(ndisc, fmt, ...) \
#define log_ndisc_errno(ndisc, error, fmt, ...) \
log_interface_prefix_full_errno_zerook( \
"NDISC: ", \
sd_ndisc_get_ifname(ndisc), \
error, fmt, ##__VA_ARGS__)
#define log_ndisc(ndisc, fmt, ...) \
log_ndisc_errno(ndisc, 0, fmt, ##__VA_ARGS__)

View File

@ -125,15 +125,10 @@ struct sd_radv_route_prefix {
LIST_FIELDS(struct sd_radv_route_prefix, prefix);
};
#define log_radv_errno(radv, error, fmt, ...) \
({ \
int _e = (error); \
if (DEBUG_LOGGING) \
log_interface_full_errno_zerook( \
sd_radv_get_ifname(radv), \
LOG_DEBUG, _e, "RADV: " fmt, \
##__VA_ARGS__); \
-ERRNO_VALUE(_e); \
})
#define log_radv(radv, fmt, ...) \
#define log_radv_errno(radv, error, fmt, ...) \
log_interface_prefix_full_errno_zerook( \
"RADV: ", \
sd_radv_get_ifname(radv), \
error, fmt, ##__VA_ARGS__)
#define log_radv(radv, fmt, ...) \
log_radv_errno(radv, 0, fmt, ##__VA_ARGS__)

View File

@ -75,16 +75,11 @@ struct sd_ipv4acd {
void* userdata;
};
#define log_ipv4acd_errno(acd, error, fmt, ...) \
({ \
int _e = (error); \
if (DEBUG_LOGGING) \
log_interface_full_errno_zerook( \
sd_ipv4acd_get_ifname(acd), \
LOG_DEBUG, _e, "IPv4ACD: " fmt, \
##__VA_ARGS__); \
-ERRNO_VALUE(_e); \
})
#define log_ipv4acd_errno(acd, error, fmt, ...) \
log_interface_prefix_full_errno_zerook( \
"IPv4ACD: ", \
sd_ipv4acd_get_ifname(acd), \
error, fmt, ##__VA_ARGS__)
#define log_ipv4acd(acd, fmt, ...) \
log_ipv4acd_errno(acd, 0, fmt, ##__VA_ARGS__)

View File

@ -49,16 +49,11 @@ struct sd_ipv4ll {
void* userdata;
};
#define log_ipv4ll_errno(ll, error, fmt, ...) \
({ \
int _e = (error); \
if (DEBUG_LOGGING) \
log_interface_full_errno_zerook( \
sd_ipv4ll_get_ifname(ll), \
LOG_DEBUG, _e, "IPv4LL: " fmt, \
##__VA_ARGS__); \
-ERRNO_VALUE(_e); \
})
#define log_ipv4ll_errno(ll, error, fmt, ...) \
log_interface_prefix_full_errno_zerook( \
"IPv4LL: ", \
sd_ipv4ll_get_ifname(ll), \
error, fmt, ##__VA_ARGS__)
#define log_ipv4ll(ll, fmt, ...) \
log_ipv4ll_errno(ll, 0, fmt, ##__VA_ARGS__)

View File

@ -17,6 +17,17 @@
log_interface_full_errno_zerook(ifname, level, _error, __VA_ARGS__); \
})
#define log_interface_prefix_full_errno_zerook(prefix, ifname_expr, error, fmt, ...) \
({ \
int _e = (error); \
if (DEBUG_LOGGING) \
log_interface_full_errno_zerook( \
ifname_expr, \
LOG_DEBUG, _e, prefix fmt, \
##__VA_ARGS__); \
-ERRNO_VALUE(_e); \
})
/*
* The following macros append INTERFACE= to the message.
* The macros require a struct named 'Link' which contains 'char *ifname':