WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] Re: [Xen-changelog] use format printf style to write to trac

To: Vincent Hanquez <vincent.hanquez@xxxxxxxxxxxx>
Subject: [Xen-devel] Re: [Xen-changelog] use format printf style to write to tracefd instead of using write syscall.
From: Muli Ben-Yehuda <mulix@xxxxxxxxx>
Date: Tue, 24 Jan 2006 21:02:39 +0200
Cc: xen-devel@xxxxxxxxxxxxxxxxxxx
Delivery-date: Tue, 24 Jan 2006 19:11:02 +0000
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <20060124185725.GA4998@xxxxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
References: <E1F1Pzk-0007L4-QX@xxxxxxxxxxxxxxxxxxxxx> <20060124181439.GA17162@xxxxxxxxxxxxxxxxxxx> <20060124185725.GA4998@xxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Mutt/1.5.11
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/


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel

<Prev in Thread] Current Thread [Next in Thread>