From faa6da3e9447e477681b650d1e38ab5a61298f71 Mon Sep 17 00:00:00 2001 From: Filip Kolev Date: Sun, 24 Nov 2024 20:41:40 +0000 Subject: [PATCH] Use perror() in case getifaddrs() call fails According to https://man7.org/linux/man-pages/man3/getifaddrs.3.html getifaddrs() returns -1 on error and sets errno. Use the perror() function to provide a more informative error message in such cases. --- chap01/unix_list.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chap01/unix_list.c b/chap01/unix_list.c index eeb5910..03213a8 100644 --- a/chap01/unix_list.c +++ b/chap01/unix_list.c @@ -34,7 +34,7 @@ int main() { struct ifaddrs *addresses; if (getifaddrs(&addresses) == -1) { - printf("getifaddrs call failed\n"); + perror("getifaddrs call failed"); return -1; }