Skip to content

Commit

Permalink
linux: add error logs to ipadapter
Browse files Browse the repository at this point in the history
  • Loading branch information
Danielius1922 committed Aug 15, 2023
1 parent 1597367 commit 1afeea7
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions port/linux/ipadapter.c
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ get_data_size(int sock)
if (errno == EINTR) {
continue;
}
return -1;
return -errno;
}
} while ((size_t)response_len == guess);
return response_len;
Expand All @@ -270,7 +270,7 @@ get_data(int sock, uint8_t *buffer, size_t buffer_size)
if (errno == EINTR) {
continue;
}
return -1;
return -errno;
}
break;
} while (true);
Expand Down Expand Up @@ -327,12 +327,14 @@ get_interface_addresses(ip_context_t *dev, unsigned char family, int port,
while (!done) {
ssize_t response_len = get_data_size(nl_sock);
if (response_len < 0) {
OC_ERR("failed to get data size: %d", (int)-response_len);
close(nl_sock);
return false;
}
uint8_t buffer[response_len];
response_len = get_data(nl_sock, buffer, sizeof(buffer));
if (response_len < 0) {
OC_ERR("failed to get data: %d", (int)-response_len);
close(nl_sock);
return false;
}
Expand Down Expand Up @@ -546,13 +548,15 @@ process_interface_change_event(void)
{
ssize_t response_len = get_data_size(g_ifchange_sock);
if (response_len < 0) {
OC_ERR("reading payload size from netlink interface");
OC_ERR("failed reading payload size from netlink interface: error(%d)",
(int)-response_len);
return -1;
}
uint8_t buffer[response_len];
response_len = get_data(g_ifchange_sock, buffer, sizeof(buffer));
if (response_len < 0) {
OC_ERR("reading payload from netlink interface");
OC_ERR("failed reading payload from netlink interface: error(%d)",
(int)-response_len);
return -1;
}

Expand Down

0 comments on commit 1afeea7

Please sign in to comment.