Skip to content

Commit

Permalink
src: Improve genl command error logging.
Browse files Browse the repository at this point in the history
  • Loading branch information
ossama-othman committed Jul 26, 2022
1 parent f2b15a2 commit 04511ee
Showing 1 changed file with 8 additions and 13 deletions.
21 changes: 8 additions & 13 deletions src/commands.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,10 @@ bool mptcpd_check_genl_error(struct l_genl_msg *msg, char const *fname)
int const error = l_genl_msg_get_error(msg);

if (error < 0) {
// Error during send. Likely insufficient perms.
// Error during send.

char errmsg[80] = { 0 };
(void) strerror_r(-error, errmsg, L_ARRAY_SIZE(errmsg));

char const *const genl_errmsg =
#ifdef HAVE_L_GENL_MSG_GET_EXTENDED_ERROR
Expand All @@ -63,18 +66,10 @@ bool mptcpd_check_genl_error(struct l_genl_msg *msg, char const *fname)
NULL;
#endif

if (genl_errmsg != NULL) {
l_error("%s: %s", fname, genl_errmsg);
} else {
char errmsg[80];
int const r = strerror_r(-error,
errmsg,
L_ARRAY_SIZE(errmsg));

l_error("%s error: %s",
fname,
r == 0 ? errmsg : "<unknown error>");
}
if (genl_errmsg != NULL)
l_error("%s: %s: %s", fname, genl_errmsg, errmsg);
else
l_error("%s: %s", fname, errmsg);

return false;
}
Expand Down

0 comments on commit 04511ee

Please sign in to comment.