Subject: Re: Adding /proc/swaps to linux compat code
To: None <tech-kern@NetBSD.org>
From: Christian Biere <email@example.com>
Date: 02/02/2007 20:00:06
Arnaud Lacombe wrote:
> On Thu, Feb 01, 2007 at 10:03:10PM +0000, David Laight wrote:
> > On Thu, Feb 01, 2007 at 12:11:36AM +0100, Christian Biere wrote:
> > > Arnaud Lacombe wrote:
> > > > A first patch is available here:
> > > > http://www.sigfpe.info/netbsd/proc_swaps.diff
> > >
> > > * You should check the return value of snprintf() with "<= 0" instead of "== 0".
> > > At least when remaining reached zero, snprintf() will return -1 and not 0.
> > Will it? Does a conformant  snprintf() ever return -1 ?
> > Time to RTFM...
> libc' snprintf can return -1 at least with negative `len' and set
> `errno' to EINVAL.
> libsa' snprintf ends up in vsnprintf() which return `sbuf - buf', `buf'
> is our buffer, `sbuf' is a cursor inside the buffer, so it can't
> return -1.
Ok, I was looking at the wrong implementation (sys/kern/subr_prf.c). sys/lib/libsa/subr_prf.c
seems to be the relevant one. Is that just a fallback which is effectively unused? I don't
see how that code supports field-widths (e.g., "%-39s").