aboutsummaryrefslogtreecommitdiff
path: root/mstatus.c
diff options
context:
space:
mode:
authorMango0x45 <thomasvoss@live.com> 2021-09-07 22:33:12 +0200
committerMango0x45 <thomasvoss@live.com> 2021-09-07 22:33:12 +0200
commit8c811d27cad551babc55188f7d969ffc52c111c7 (patch)
treee2e0fdf1228772e05fb66e5b02630d490e8eb9b2 /mstatus.c
parentf4c5dc7a332b229b8efffdb66f0c219709fd6148 (diff)
Don't syslog recieved commands with a trailing newline
Diffstat (limited to 'mstatus.c')
-rw-r--r--mstatus.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/mstatus.c b/mstatus.c
index f9b341b..83c2a34 100644
--- a/mstatus.c
+++ b/mstatus.c
@@ -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);
}