mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-01-21 03:40:33 +01:00
daemon-helper: use _nm_strerror_r() to avoid non-thread-safe strerror()
Yes, there probably are not multiple threads here. It's a matter of principle to not use smelly functions. Also, copy the "errno" value we want to print, before calling various functions.
This commit is contained in:
parent
59251cae45
commit
c42f6f0997
1 changed files with 5 additions and 2 deletions
|
|
@ -94,12 +94,15 @@ cmd_resolve_address(void)
|
||||||
NI_NAMEREQD);
|
NI_NAMEREQD);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
if (ret == EAI_SYSTEM) {
|
if (ret == EAI_SYSTEM) {
|
||||||
|
int errsv = errno;
|
||||||
|
char buf[1024];
|
||||||
|
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"getnameinfo() failed: %d (%s), system error: %d (%s)\n",
|
"getnameinfo() failed: %d (%s), system error: %d (%s)\n",
|
||||||
ret,
|
ret,
|
||||||
gai_strerror(ret),
|
gai_strerror(ret),
|
||||||
errno,
|
errsv,
|
||||||
strerror(errno));
|
_nm_strerror_r(errsv, buf, sizeof(buf)));
|
||||||
} else {
|
} else {
|
||||||
fprintf(stderr, "getnameinfo() failed: %d (%s)\n", ret, gai_strerror(ret));
|
fprintf(stderr, "getnameinfo() failed: %d (%s)\n", ret, gai_strerror(ret));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue