On 31/01/2022 19.48, Waiman Long wrote:Thanks for the clarification.
On 1/31/22 05:34, Andy Shevchenko wrote:Even if it did, the "i < size" comparison in vscnprintf() is "int v
Also it seems currently the kernel documentation is not aligned withAFAICS, the kernel's vsnprintf() function will not return -1.
the code
"If @size is == 0 the function returns 0."
It should mention the (theoretical?) possibility of getting negative
value,
if vsnprintf() returns negative value.
size_t", so integer promotion says that even if i were negative, that
comparison would be false, so we wouldn't forward that negative value
anyway.
So in thatOf course it's not, but not because it doesn't return -1. POSIX just
sense it is not fully POSIX compliant.
says to return that in case of an error, and as a matter of QoI, the
kernel's implementation simply can't (and must not) fail. There are
other cases where we don't follow POSIX/C, e.g. in some corner cases
around field length and precision (documented in test_printf.c), and the
non-support of %n (and floating point and handling of wchar_t*), and the
whole %p<> extension etc.
Rasmus