All of lore.kernel.org
 help / color / mirror / Atom feed
* [Patch] cldcli: permit (much) longer messages
@ 2009-08-27 18:27 Pete Zaitcev
  2009-08-27 19:39 ` Jeff Garzik
  0 siblings, 1 reply; 2+ messages in thread
From: Pete Zaitcev @ 2009-08-27 18:27 UTC (permalink / raw)
  To: Jeff Garzik; +Cc: Project Hail List

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.

Signed-off-by: Pete Zaitcev <zaitcev@redhat.com>

diff --git a/tools/cldcli.c b/tools/cldcli.c
index eb4ebc4..60ab301 100644
--- a/tools/cldcli.c
+++ b/tools/cldcli.c
@@ -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);
 }
 

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [Patch] cldcli: permit (much) longer messages
  2009-08-27 18:27 [Patch] cldcli: permit (much) longer messages Pete Zaitcev
@ 2009-08-27 19:39 ` Jeff Garzik
  0 siblings, 0 replies; 2+ messages in thread
From: Jeff Garzik @ 2009-08-27 19:39 UTC (permalink / raw)
  To: Pete Zaitcev; +Cc: Project Hail List

On 08/27/2009 02:27 PM, Pete Zaitcev wrote:
> 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.
>
> Signed-off-by: Pete Zaitcev<zaitcev@redhat.com>

applied



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2009-08-27 19:39 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-08-27 18:27 [Patch] cldcli: permit (much) longer messages Pete Zaitcev
2009-08-27 19:39 ` Jeff Garzik

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.