all: assert that native errno numbers are positive
Use the NM_ERRNO_NATIVE() macro that asserts that these errno numbers are indeed positive. Using the macro also serves as a documentation of what the meaning of these numbers is. That is often not obvious, whether we have an nm_errno(), an nm_errno_native() (from <errno.h>), or another error number (e.g. WaitForNlResponseResult). This situation already improved by merging netlink error codes (nle), NMPlatformError enum and <errno.h> as nm_errno(). But we still must always be careful about not to mix error codes from different domains or transform them appropriately (like nm_errno_from_native()).
This commit is contained in:
@@ -84,7 +84,7 @@ socket_handle_init (SocketHandle *shandle, int ifindex)
|
||||
shandle->fd = socket (PF_INET, SOCK_DGRAM | SOCK_CLOEXEC, 0);
|
||||
if (shandle->fd < 0) {
|
||||
shandle->ifindex = 0;
|
||||
return -errno;
|
||||
return -NM_ERRNO_NATIVE (errno);
|
||||
}
|
||||
|
||||
shandle->ifindex = ifindex;
|
||||
@@ -158,7 +158,7 @@ ethtool_call_handle (SocketHandle *shandle, gpointer edata)
|
||||
_ethtool_data_to_string (edata, sbuf, sizeof (sbuf)),
|
||||
shandle->ifname,
|
||||
strerror (errsv));
|
||||
return -errsv;
|
||||
return -NM_ERRNO_NATIVE (errsv);
|
||||
}
|
||||
|
||||
nm_log_trace (LOGD_PLATFORM, "ethtool[%d]: %s, %s: success",
|
||||
|
Reference in New Issue
Block a user