Skip to content

Commit f407219

Browse files
committed
Check that errno passed log_{interface,link}_*_errno() is non-zero
1 parent e89f6ed commit f407219

File tree

9 files changed

+26
-12
lines changed

9 files changed

+26
-12
lines changed

src/libsystemd-network/dhcp-internal.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ int dhcp_packet_verify_headers(DHCPPacket *packet, size_t len, bool checksum, ui
7070
({ \
7171
int _e = (error); \
7272
if (DEBUG_LOGGING) \
73-
log_interface_full_errno( \
73+
log_interface_full_errno_zerook( \
7474
sd_dhcp_client_get_ifname(client), \
7575
LOG_DEBUG, _e, "DHCPv4 client: " fmt, \
7676
##__VA_ARGS__); \

src/libsystemd-network/dhcp-server-internal.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ int client_id_compare_func(const DHCPClientId *a, const DHCPClientId *b);
102102
({ \
103103
int _e = (error); \
104104
if (DEBUG_LOGGING) \
105-
log_interface_full_errno( \
105+
log_interface_full_errno_zerook( \
106106
sd_dhcp_server_get_ifname(server), \
107107
LOG_DEBUG, _e, "DHCPv4 server: " fmt, \
108108
##__VA_ARGS__); \

src/libsystemd-network/dhcp6-internal.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ int dhcp6_message_status_from_string(const char *s) _pure_;
123123
({ \
124124
int _e = (error); \
125125
if (DEBUG_LOGGING) \
126-
log_interface_full_errno( \
126+
log_interface_full_errno_zerook( \
127127
sd_dhcp6_client_get_ifname(client), \
128128
LOG_DEBUG, _e, "DHCPv6 client: " fmt, \
129129
##__VA_ARGS__); \

src/libsystemd-network/lldp-internal.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ sd_lldp_event_t lldp_event_from_string(const char *s) _pure_;
4040
({ \
4141
int _e = (error); \
4242
if (DEBUG_LOGGING) \
43-
log_interface_full_errno( \
43+
log_interface_full_errno_zerook( \
4444
sd_lldp_get_ifname(lldp), \
4545
LOG_DEBUG, _e, "LLDP: " fmt, \
4646
##__VA_ARGS__); \

src/libsystemd-network/ndisc-internal.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ sd_ndisc_event_t ndisc_event_from_string(const char *s) _pure_;
4545
({ \
4646
int _e = (error); \
4747
if (DEBUG_LOGGING) \
48-
log_interface_full_errno( \
48+
log_interface_full_errno_zerook( \
4949
sd_ndisc_get_ifname(ndisc), \
5050
LOG_DEBUG, _e, "NDISC: " fmt, \
5151
##__VA_ARGS__); \

src/libsystemd-network/radv-internal.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ struct sd_radv_route_prefix {
129129
({ \
130130
int _e = (error); \
131131
if (DEBUG_LOGGING) \
132-
log_interface_full_errno( \
132+
log_interface_full_errno_zerook( \
133133
sd_radv_get_ifname(radv), \
134134
LOG_DEBUG, _e, "RADV: " fmt, \
135135
##__VA_ARGS__); \

src/libsystemd-network/sd-ipv4acd.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ struct sd_ipv4acd {
7979
({ \
8080
int _e = (error); \
8181
if (DEBUG_LOGGING) \
82-
log_interface_full_errno( \
82+
log_interface_full_errno_zerook( \
8383
sd_ipv4acd_get_ifname(acd), \
8484
LOG_DEBUG, _e, "IPv4ACD: " fmt, \
8585
##__VA_ARGS__); \

src/libsystemd-network/sd-ipv4ll.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ struct sd_ipv4ll {
5353
({ \
5454
int _e = (error); \
5555
if (DEBUG_LOGGING) \
56-
log_interface_full_errno( \
56+
log_interface_full_errno_zerook( \
5757
sd_ipv4ll_get_ifname(ll), \
5858
LOG_DEBUG, _e, "IPv4LL: " fmt, \
5959
##__VA_ARGS__); \

src/shared/log-link.h

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,20 @@
33

44
#include "log.h"
55

6-
#define log_interface_full_errno(ifname, level, error, ...) \
6+
#define log_interface_full_errno_zerook(ifname, level, error, ...) \
77
({ \
88
const char *_ifname = (ifname); \
99
_ifname ? log_object_internal(level, error, PROJECT_FILE, __LINE__, __func__, "INTERFACE=", _ifname, NULL, NULL, ##__VA_ARGS__) : \
1010
log_internal(level, error, PROJECT_FILE, __LINE__, __func__, ##__VA_ARGS__); \
1111
})
1212

13+
#define log_interface_full_errno(ifname, level, error, ...) \
14+
({ \
15+
int _error = (error); \
16+
ASSERT_NON_ZERO(_error); \
17+
log_interface_full_errno_zerook(ifname, level, _error, __VA_ARGS__); \
18+
})
19+
1320
/*
1421
* The following macros append INTERFACE= to the message.
1522
* The macros require a struct named 'Link' which contains 'char *ifname':
@@ -21,13 +28,20 @@
2128
* See, network/networkd-link.h for example.
2229
*/
2330

24-
#define log_link_full_errno(link, level, error, ...) \
31+
#define log_link_full_errno_zerook(link, level, error, ...) \
2532
({ \
2633
const Link *_l = (link); \
27-
log_interface_full_errno(_l ? _l->ifname : NULL, level, error, ##__VA_ARGS__); \
34+
log_interface_full_errno_zerook(_l ? _l->ifname : NULL, level, error, __VA_ARGS__); \
35+
})
36+
37+
#define log_link_full_errno(link, level, error, ...) \
38+
({ \
39+
int _error = (error); \
40+
ASSERT_NON_ZERO(_error); \
41+
log_link_full_errno_zerook(link, level, _error, __VA_ARGS__); \
2842
})
2943

30-
#define log_link_full(link, level, ...) (void) log_link_full_errno(link, level, 0, __VA_ARGS__)
44+
#define log_link_full(link, level, ...) (void) log_link_full_errno_zerook(link, level, 0, __VA_ARGS__)
3145

3246
#define log_link_debug(link, ...) log_link_full(link, LOG_DEBUG, __VA_ARGS__)
3347
#define log_link_info(link, ...) log_link_full(link, LOG_INFO, __VA_ARGS__)

0 commit comments

Comments
 (0)