diff options
author | Mango0x45 <thomasvoss@live.com> | 2021-09-07 22:33:12 +0200 |
---|---|---|
committer | Mango0x45 <thomasvoss@live.com> | 2021-09-07 22:33:12 +0200 |
commit | 8c811d27cad551babc55188f7d969ffc52c111c7 (patch) | |
tree | e2e0fdf1228772e05fb66e5b02630d490e8eb9b2 /mstatus.c | |
parent | f4c5dc7a332b229b8efffdb66f0c219709fd6148 (diff) |
Don't syslog recieved commands with a trailing newline
Diffstat (limited to 'mstatus.c')
-rw-r--r-- | mstatus.c | 13 |
1 files changed, 7 insertions, 6 deletions
@@ -161,12 +161,8 @@ update_bar:; } static bool -process(char *line, ssize_t len, struct Block *b) +process(char *line, struct Block *b) { - /* For some reason output with newlines can cause performance issues */ - if (line[--len] == '\n') - line[len] = '\0'; - if (*line == '-') { b->remove = true; line++; @@ -273,9 +269,14 @@ main(int argc, char **argv) ssize_t nr; while ((nr = getline(&line, &len, fp)) != -1) { + /* For some reason output with newlines can cause performance issues */ + if (line[--nr] == '\n') + line[nr] = '\0'; + syslog(LOG_INFO, "Recieved command '%s'", line); + struct Block b; - if (!process(line, nr, &b)) + if (!process(line, &b)) continue; write_status(b); } |