Skip to contentSkip to conversation

cldcli: permit (much) longer messages

PATCH Applied Pete Zaitcev 2 participants 2 messages Aug 27, 2009

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cldcli: permit (much) longer messages

A thought just occured to me that it's dumb to expand the message itself when you can expand the format. This way all the potentially long things like CLD pathnames do not count against your stack and there's essentially no chance to get any messages truncated.

The first snprintf is actually a strncat, but it's more concise.

tools/cldcli.c +2 -2
index eb4ebc4..60ab301 100644
@@ -131,8 +131,8 @@ static void applog(int prio, const char *fmt, ...)
 	va_list ap;
 
 	va_start(ap, fmt);
-	vsnprintf(buf, 200, fmt, ap);
-	fprintf(stderr, "%s\n", buf);
+	snprintf(buf, 200, "%s\n", fmt);
+	vfprintf(stderr, buf, ap);
 	va_end(ap);
 }
 
Applied
#1 lore raw
Quoted 8 lines · Pete Zaitcev

A thought just occured to me that it's dumb to expand the message itself when you can expand the format. This way all the potentially long things like CLD pathnames do not count against your stack and there's essentially no chance to get any messages truncated.

The first snprintf is actually a strncat, but it's more concise.

applied