diff --git a/server/src/hist.c b/server/src/hist.c index 361375c41..a2564201c 100644 --- a/server/src/hist.c +++ b/server/src/hist.c @@ -139,17 +139,14 @@ void hist_plot(struct hist *h) void hist_dump(struct hist *h, char *buf, int len) { - char tok[8]; - memset(buf, 0, len); + *buf = 0; - strncat(buf, "[ ", len); + strap(buf, len, "[ "); - for (int i = 0; i < h->length; i++) { - snprintf(tok, sizeof(tok), "%u ", h->data[i]); - strncat(buf, tok, len - strlen(buf)); - } - - strncat(buf, "]", len - strlen(buf)); + for (int i = 0; i < h->length; i++) + strap(buf, len, "%u ", h->data[i]); + + strap(buf, len, "]"); } void hist_matlab(struct hist *h, FILE *f) diff --git a/server/src/utils.c b/server/src/utils.c index d30dd2503..f77d3862f 100644 --- a/server/src/utils.c +++ b/server/src/utils.c @@ -101,16 +101,15 @@ struct timespec timespec_rate(double rate) /** @todo: Proper way: create additional pipe for stderr in child process */ int system2(const char *cmd, ...) { + va_list ap; char buf[1024]; - va_list ap; va_start(ap, cmd); - - vsnprintf(buf, sizeof(buf), cmd, ap); - strncat(buf, " 2>&1", sizeof(buf)); - + vsnprintf(buf, sizeof(buf), cmd, ap); va_end(ap); + strap(buf, sizeof(buf), " 2>&1", sizeof(buf)); /* redirect stderr to stdout */ + debug(1, "System: %s", buf); FILE *f = popen(buf, "r");