On Sat, 2012-12-29 at 14:27 -0800, Roland Dreier wrote:
> On Sat, Dec 29, 2012 at 12:08 PM, Joe Perches <j...@perches.com> wrote:
> > Sylvan Munaut did something similar
> > https://lkml.org/lkml/2012/12/5/168
> 
> Missed that and duplicated the debugging :(
> Sorry Sylvain.
> 
> I guess my patch may be preferable, since I happened to use the snprintf()
> method that you suggest -- all the open-coded digit-counting seems a bit
> verbose and perhaps hard to read and see the equivalence to the sprintf.

the kernel implementation of snprint/vsnprintf does expand on c99
and allow snprintf(NULL, 0... so your code should work fine.

I think the
        snprintf(NULL, 0
might be suspect.
(the same form is already used in drivers/usb/gadget/composite.c)

man snprintf says in part:

       Concerning the return value of snprintf(),  SUSv2  and  C99  contradict
       each other: when snprintf() is called with size=0 then SUSv2 stipulates
       an unspecified return value less than 1, while C99  allows  str  to  be
       NULL in this case, and gives the return value (as always) as the number
       of characters that would have been written in case  the  output  string
       has been large enough.

If not here, maybe the tools/perf/util/values.c code
that uses the same form might need changing.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to