From 9a07ac6f6d76e6a97429f5295df3b9c8e10b6b30 Mon Sep 17 00:00:00 2001 From: Laslo Hunhold Date: Sat, 19 May 2018 19:33:04 +0200 Subject: Implement esnprintf() and make formatted calls more efficient Within the components, snprintf() was unchecked and had inefficient calls in some places. We implement esnprintf() that does all the dirty laundry for us and use it exclusively now. --- slstatus.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'slstatus.c') diff --git a/slstatus.c b/slstatus.c index 0c4605f..3222b02 100644 --- a/slstatus.c +++ b/slstatus.c @@ -91,12 +91,8 @@ main(int argc, char *argv[]) if (!(res = args[i].func(args[i].args))) { res = unknown_str; } - if ((ret = snprintf(status + len, sizeof(status) - len, + if ((ret = esnprintf(status + len, sizeof(status) - len, args[i].fmt, res)) < 0) { - warn("snprintf:"); - break; - } else if ((size_t)ret >= sizeof(status) - len) { - warn("snprintf: Output truncated"); break; } len += ret; -- cgit v1.2.3