On 04/27/15 00:32, Sebastian Herbszt wrote:
Bart Van Assche wrote:
* Switch from snprintf() to scnprintf() because the latter function
guarantees '\0'-termination if the output has to be truncated.
Doesn't snprintf() guarantee this too? The only difference between
snprintf() and scnprintf() seems to be the return value.
snprintf() calls vsnprintf() and scnprintf() calls vscnprintf() which
calls vsnprintf() itself.
Hello Sebastian,
In my e-mail I was referring to the pre-C99 behavior of snprintf().
Apparently the snprintf() function in the Linux kernel is compliant with
the C99 specs. See e.g.
http://pubs.opengroup.org/onlinepubs/7908799/xsh/fprintf.html and
http://pubs.opengroup.org/stage7tc1/functions/fprintf.html#. In the
latter document it has been mentioned that "output bytes beyond the
n-1st shall be discarded", something which has not been mentioned in the
former document.
Bart.
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html