Skip to content

Commit c3fecdd

Browse files
committed
util: move ERRNO_IS_xyz macros to errno-util.h
It's where they fit much better.
1 parent 594da0a commit c3fecdd

File tree

3 files changed

+14
-12
lines changed

3 files changed

+14
-12
lines changed

src/basic/errno-util.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,16 @@ static inline int negative_errno(void) {
2727
assert_return(errno > 0, -EINVAL);
2828
return -errno;
2929
}
30+
31+
/* Hint #1: ENETUNREACH happens if we try to connect to "non-existing" special IP addresses, such as ::5.
32+
*
33+
* Hint #2: The kernel sends e.g., EHOSTUNREACH or ENONET to userspace in some ICMP error cases. See the
34+
* icmp_err_convert[] in net/ipv4/icmp.c in the kernel sources */
35+
#define ERRNO_IS_DISCONNECT(r) \
36+
IN_SET(abs(r), \
37+
ENOTCONN, ECONNRESET, ECONNREFUSED, ECONNABORTED, EPIPE, \
38+
ENETUNREACH, EHOSTUNREACH, ENOPROTOOPT, EHOSTDOWN, ENONET)
39+
40+
/* Resource exhaustion, could be our fault or general system trouble */
41+
#define ERRNO_IS_RESOURCE(r) \
42+
IN_SET(abs(r), ENOMEM, EMFILE, ENFILE)

src/basic/fd-util.h

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -77,18 +77,6 @@ int acquire_data_fd(const void *data, size_t size, unsigned flags);
7777

7878
int fd_duplicate_data_fd(int fd);
7979

80-
/* Hint: ENETUNREACH happens if we try to connect to "non-existing" special IP addresses, such as ::5 */
81-
/* The kernel sends e.g., EHOSTUNREACH or ENONET to userspace in some ICMP error cases.
82-
* See the icmp_err_convert[] in net/ipv4/icmp.c in the kernel sources */
83-
#define ERRNO_IS_DISCONNECT(r) \
84-
IN_SET(abs(r), \
85-
ENOTCONN, ECONNRESET, ECONNREFUSED, ECONNABORTED, EPIPE, \
86-
ENETUNREACH, EHOSTUNREACH, ENOPROTOOPT, EHOSTDOWN, ENONET)
87-
88-
/* Resource exhaustion, could be our fault or general system trouble */
89-
#define ERRNO_IS_RESOURCE(r) \
90-
IN_SET(abs(r), ENOMEM, EMFILE, ENFILE)
91-
9280
int fd_move_above_stdio(int fd);
9381

9482
int rearrange_stdio(int original_input_fd, int original_output_fd, int original_error_fd);

src/resolve/resolved-dns-transaction.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include "alloc-util.h"
77
#include "dns-domain.h"
88
#include "errno-list.h"
9+
#include "errno-util.h"
910
#include "fd-util.h"
1011
#include "random-util.h"
1112
#include "resolved-dns-cache.h"

0 commit comments

Comments
 (0)