From 58dc09b415891179ff81ff3237af8c229d6b5211 Mon Sep 17 00:00:00 2001 From: Benedikt Heine Date: Fri, 8 Dec 2017 02:34:12 +0100 Subject: [PATCH] Replace PERR macro with appropriate logging macro --- src/dunst.h | 2 -- src/menu.c | 10 +++++----- src/notification.c | 2 +- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/dunst.h b/src/dunst.h index cdb6874..ac5cda6 100644 --- a/src/dunst.h +++ b/src/dunst.h @@ -9,8 +9,6 @@ #include "notification.h" -#define PERR(msg, errnum) printf("(%d) %s : %s\n", __LINE__, (msg), (strerror(errnum))) - #define ColLast 3 #define ColFrame 2 #define ColFG 1 diff --git a/src/menu.c b/src/menu.c index 9a80942..8f94c96 100644 --- a/src/menu.c +++ b/src/menu.c @@ -214,12 +214,12 @@ void context_menu(void) int child_io[2]; int parent_io[2]; if (pipe(child_io) != 0) { - PERR("pipe()", errno); + LOG_W("pipe(): error in child: %s", strerror(errno)); g_free(dmenu_input); return; } if (pipe(parent_io) != 0) { - PERR("pipe()", errno); + LOG_W("pipe(): error in parent: %s", strerror(errno)); g_free(dmenu_input); return; } @@ -230,12 +230,12 @@ void context_menu(void) close(parent_io[0]); close(0); if (dup(child_io[0]) == -1) { - PERR("dup()", errno); + LOG_W("dup(): error in child: %s", strerror(errno)); exit(EXIT_FAILURE); } close(1); if (dup(parent_io[1]) == -1) { - PERR("dup()", errno); + LOG_W("dup(): error in parent: %s", strerror(errno)); exit(EXIT_FAILURE); } execvp(settings.dmenu_cmd[0], settings.dmenu_cmd); @@ -244,7 +244,7 @@ void context_menu(void) close(parent_io[1]); size_t wlen = strlen(dmenu_input); if (write(child_io[1], dmenu_input, wlen) != wlen) { - PERR("write()", errno); + LOG_W("write(): error: %s", strerror(errno)); } close(child_io[1]); diff --git a/src/notification.c b/src/notification.c index 1a5902f..f689193 100644 --- a/src/notification.c +++ b/src/notification.c @@ -108,7 +108,7 @@ void notification_run_script(notification *n) urgency, (char *)NULL); if (ret != 0) { - PERR("Unable to run script", errno); + LOG_W("Unable to run script: %s", strerror(errno)); exit(EXIT_FAILURE); } }