On 07/18/2013 02:42 PM, George Spelvin wrote: >> When "str >= end", necessary to reset 'str' to "end - 1", or the return >> > value will be larger than the real one, the callers which depend on the >> > return value, may cause memory overflow. > NAK. This is the documented (by both the function itself and the > ANSI/ISO C standard) and desired return value: the number of bytes that > *would* have been in the output string if the buffer were large enough. > In particular, it is common to do: > > size = vsnprintf(NULL, 0, fmt, args) + 1; > p = malloc(size, GFP_KERNEL); > vsnprintf(p, size, fmt, args); >
OK, it is my fault, thank you very much. > You want vscnprintf. If you have a caller that needs the *actual* number of > bytes written, use that. > > Yeah, my another patch need use vscnprintf() instead of vsnprintf(), thanks again. Thanks. -- Chen Gang -- 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/