From 9b20d222ab45262c0d2f3305b24efaad7ddd71b8 Mon Sep 17 00:00:00 2001 From: halosghost Date: Sun, 17 Apr 2016 14:36:16 -0500 Subject: [PATCH] Add logging for errors in strtol() --- src/win_oper.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/win_oper.c b/src/win_oper.c index 9587594..a85d1b2 100644 --- a/src/win_oper.c +++ b/src/win_oper.c @@ -11,7 +11,14 @@ void border_color_write(int wid, const char *buf) { - set_border_color(wid, strtol(buf, NULL, 16)); + errno = 0; + long color = strtol(buf, NULL, 16); + int errsv = errno; + if ( errsv ) { + syslog(LOG_ERR, "failed to parse color in %s: %s\n", __func__, strerror(errsv)); + } + + set_border_color(wid, color); } #define DECLARE_NORM_READER(cat, prop, getter) \ @@ -168,5 +175,12 @@ char *focused_read(int wid) void focused_write(int wid, const char *buf) { (void) wid; - focus(strtol(buf, NULL, 16)); + errno = 0; + long id = strtol(buf, NULL, 16); + int errsv = errno; + if ( errsv ) { + syslog(LOG_ERR, "failed to parse id to focus in %s: %s\n", __func__, strerror(errsv)); + } + + focus(id); }