[openib-general] [PATCH] diags/saquery: fix node_desc.description as string usages

Jason Gunthorpe jgunthorpe at obsidianresearch.com
Mon Oct 30 21:13:22 PST 2006


On Tue, Oct 31, 2006 at 06:59:02AM +0200, Sasha Khapyorsky wrote:

> > > This would be simpler. However some web searching shows that not all
> > > printf() implementation permits not null terminated arrays even when
> > > precision is specified (some issues were reported even with glibc-2.3.2).
> > 
> > Hmm, couldn't find it.
> 
> Look at this for example:
> http://sourceware.org/ml/bug-glibc/2005-02/msg00123.html

Interestingly SUSv3 (aka POSIX 2001) only requires the terminating
null if the precision is longer than the array size.

s
    The argument shall be a pointer to an array of char. Bytes from
    the array shall be written up to (but not including) any
    terminating null byte. If the precision is specified, no more than
    that many bytes shall be written. If the precision is not specified or
    is greater than the size of the array, the application shall ensure
    that the array contains a null byte. 

Regards,
Jason




More information about the general mailing list