Skip to content

Commit

Permalink
Add logging for errors in strtol()
Browse files Browse the repository at this point in the history
  • Loading branch information
halosghost authored and HalosGhost committed May 24, 2019
1 parent 6b5beb5 commit 9b20d22
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/win_oper.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) \
Expand Down Expand Up @@ -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);
}

0 comments on commit 9b20d22

Please sign in to comment.