From mboxrd@z Thu Jan 1 00:00:00 1970 From: Pete Zaitcev Subject: [Patch] cldcli: permit (much) longer messages Date: Thu, 27 Aug 2009 12:27:02 -0600 Message-ID: <20090827122702.4f13193e@redhat.com> Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Return-path: Sender: hail-devel-owner@vger.kernel.org List-ID: Content-Type: text/plain; charset="us-ascii" 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 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); }