All of lore.kernel.org
 help / color / mirror / Atom feed
From: Muli Ben-Yehuda <mulix@mulix.org>
To: Vincent Hanquez <vincent.hanquez@cl.cam.ac.uk>
Cc: xen-devel@lists.xensource.com
Subject: Re: [Xen-changelog] use format printf style to write to tracefd instead of using write syscall.
Date: Tue, 24 Jan 2006 21:02:39 +0200	[thread overview]
Message-ID: <20060124190239.GD17162@granada.merseine.nu> (raw)
In-Reply-To: <20060124185725.GA4998@snarc.org>

On Tue, Jan 24, 2006 at 07:57:25PM +0100, Vincent Hanquez wrote:
> On Tue, Jan 24, 2006 at 08:14:40PM +0200, Muli Ben-Yehuda wrote:
> > > +	/* try to use a static buffer */
> > 
> > sbuf isn't static here...
> 
> static as contrary to dynamicly allocated, not as a static C variable
> 
> do you prefer s/static/stack/ ?

Doesn't really matter.

> > vsnprintf can return a negative error value on output failure, in
> > which case calling write is not a good idea.
> 
> Did you really saw a *vsnprintf* fail ever with a negative value ?

Not that I can recall.

> I cannot find any reason that it will have an output error, which is the
> only reason listed in the manual, since the output is a string in memory.
> 
> I think the return value of -1 is only related to:
> fprintf, vfprintf, printf (redirection of output), vprintf
> 
> If that's not true, I think that there's lots of other place that can
> have this problem.

It's not exactly the bug of the decade, but I don't see any downsides
to handling all possible errors here since we're already checking the
return value...

> > trace("%s", "\n***\n")? it's slightly slower but more future proof.
> 
> well it could not be that slower anyway actually:
> 
> the algo can just strlen+strcpy the first argument for the output
> instead of going through the format string char by char for an escape.
> for a short string that doesn't really matters though.
> 
> I'm happy either way, but patch welcome, although that's just nitpicking
> now ;)

Guilty as charged :-)

Cheers,
Muli
-- 
Muli Ben-Yehuda
http://www.mulix.org | http://mulix.livejournal.com/

      reply	other threads:[~2006-01-24 19:02 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <E1F1Pzk-0007L4-QX@xenbits.xensource.com>
2006-01-24 18:14 ` [Xen-changelog] use format printf style to write to tracefd instead of using write syscall Muli Ben-Yehuda
2006-01-24 18:57   ` Vincent Hanquez
2006-01-24 19:02     ` Muli Ben-Yehuda [this message]

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=20060124190239.GD17162@granada.merseine.nu \
    --to=mulix@mulix.org \
    --cc=vincent.hanquez@cl.cam.ac.uk \
    --cc=xen-devel@lists.xensource.com \
    /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.