Skip to contentSkip to conversation

alfred: add more debug output for libc errors

PATCH Applied Sven Eckelmann 2 participants 2 messages Jul 29, 2014 – Jul 30, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 alfred: add more debug output for libc errors

perror(..) can automatically decode the errno variable and print more information for an error.

---
 gpsd/alfred-gpsd.c | 2 +-
 main.c             | 2 +-
 send.c             | 2 +-
 vis/vis.c          | 4 ++--
 4 files changed, 5 insertions(+), 5 deletions(-)
gpsd/alfred-gpsd.c +1 -1
index 6e88dc7..d736ad1 100644
@@ -443,7 +443,7 @@ static struct globals *gpsd_init(int argc, char *argv[])
 		gpsd_source_spec(NULL, &globals->gpsdsource);
 
 	if (signal(SIGPIPE, SIG_IGN) == SIG_ERR)
-		fprintf(stderr, "could not register SIGPIPE handler\n");
+		perror("could not register SIGPIPE handler");
 	return globals;
 }
 
main.c +1 -1
index 0a79e08..1add44e 100644
@@ -150,7 +150,7 @@ static struct globals *alfred_init(int argc, char *argv[])
 	}
 
 	if (signal(SIGPIPE, SIG_IGN) == SIG_ERR)
-		fprintf(stderr, "could not register SIGPIPE handler\n");
+		perror("could not register SIGPIPE handler");
 	return globals;
 }
 
send.c +1 -1
index dc0e428..32b7cbb 100644
@@ -170,7 +170,7 @@ ssize_t send_alfred_packet(struct globals *globals, const struct in6_addr *dest,
 		     (struct sockaddr *)&dest_addr,
 		     sizeof(struct sockaddr_in6));
 	if (ret == -EPERM) {
-		fprintf(stderr, "Error during sent\n");
+		perror("Error during sent");
 		netsock_close(globals->netsock);
 		globals->netsock = -1;
 	}
vis/vis.c +2 -2
index 6cc4034..00372ab 100644
@@ -258,7 +258,7 @@ static int register_interfaces(struct globals *globals)
 
 	path_buff = malloc(PATH_BUFF_LEN);
 	if (!path_buff) {
-		fprintf(stderr, "Error - could not allocate path buffer: out of memory ?\n");
+		perror("Error - could not allocate path buffer");
 		goto err;
 	}
 
@@ -880,7 +880,7 @@ static struct globals *vis_init(int argc, char *argv[])
 	}
 
 	if (signal(SIGPIPE, SIG_IGN) == SIG_ERR)
-		fprintf(stderr, "could not register SIGPIPE handler\n");
+		perror("could not register SIGPIPE handler");
 	return globals;
 }
 
Signature · 1 line
2.0.1