From faa52bdcc0221de2d8fae950e409a8ac5e05bfcd Mon Sep 17 00:00:00 2001 From: Aaron Marcher Date: Wed, 28 Mar 2018 19:46:27 +0200 Subject: Format error messages properly Make use of strerror(errno) and format all errors equally: function ['parameters']: error message --- components/hostname.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'components/hostname.c') diff --git a/components/hostname.c b/components/hostname.c index 45dbb5b..d7c10c8 100644 --- a/components/hostname.c +++ b/components/hostname.c @@ -1,5 +1,7 @@ /* See LICENSE file for copyright and license details. */ +#include #include +#include #include #include "../util.h" @@ -8,7 +10,7 @@ const char * hostname(void) { if (gethostname(buf, sizeof(buf)) == -1) { - fprintf(stderr, "gethostbyname failed"); + fprintf(stderr, "gethostbyname: %s\n", strerror(errno)); return NULL; } -- cgit v1.2.3