Open MPI logo

Hardware Locality Development Mailing List Archives

  |   Home   |   Support   |   FAQ   |   all Hardware Locality Development mailing list

Subject: Re: [hwloc-devel] documentation/implementation questions with the snprintf routines
From: Brice Goglin (Brice.Goglin_at_[hidden])
Date: 2011-01-06 11:29:28


Le 06/01/2011 17:13, Guy Streeter a écrit :
> The man pages for the various snprintf routines indicate that they
> return the number of characters written. My testing indicates that
> they always return the number of characters required, which can be
> more or less than the space supplied.

Indeed, most comments in the API are wrong. All our snprintf functions
return the number of required characters.

> My testing also indicates that if the buffer size is indicated as
> zero, the buffer pointer is not referenced.

This is *mostly* true. We only have a couple corner cases that I should
be able to fix.

> This allows me to pass in NULL and zero to determine the required size
> before allocating the space. I would like to see that explicitly
> promised so I can count on it going forward.

Once I fix the aforementioned corner cases, we'll explicitly promise
this in the API comments. Should be ok for 1.1.

Brice