All of lore.kernel.org
 help / color / mirror / Atom feed
From: Pete Zaitcev <zaitcev@redhat.com>
To: Jeff Garzik <jeff@garzik.org>
Cc: Project Hail List <hail-devel@vger.kernel.org>
Subject: [Patch] cldcli: permit (much) longer messages
Date: Thu, 27 Aug 2009 12:27:02 -0600	[thread overview]
Message-ID: <20090827122702.4f13193e@redhat.com> (raw)

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);
 }
 

             reply	other threads:[~2009-08-27 18:27 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-08-27 18:27 Pete Zaitcev [this message]
2009-08-27 19:39 ` [Patch] cldcli: permit (much) longer messages Jeff Garzik

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20090827122702.4f13193e@redhat.com \
    --to=zaitcev@redhat.com \
    --cc=hail-devel@vger.kernel.org \
    --cc=jeff@garzik.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.