
Dear Simon Glass,
In message 1320263530-22843-3-git-send-email-sjg@chromium.org you wrote:
From: Sonny Rao sonnyrao@chromium.org
From: Sonny Rao sonnyrao@chromium.org
These functions are useful in U-Boot because they allow a graceful failure rather than an unpredictable stack overflow when printf() buffers are exceeded.
Mostly copied from the Linux kernel. I copied vscnprintf and scnprintf so we can change printf and vprintf to use the safe implementation but still return the correct values.
(Simon Glass sjg@chromium.org modified this commit a little)
Signed-off-by: Sonny Rao sonnyrao@chromium.org
Changes in v3:
- Add CONFIG_SYS_VSNPRINT option to enable vsnprintf() functions
- Update README with CONFIG_SYS_VSNPRINT docs
- Use ADDCH macro to support checking/not checking end pointer
Changes in v4:
- Add these changes in unless CONFIG_NO_SYS_VSNPRINT is defined
- Reduce code size overhead if disabled to only 4 bytes on ARM
- Remove the ugly #ifdef patch from series since it only saves 4 bytes
Changes in v5:
- Define INT_MAX locally within vsprintf.c
Changes in v6:
- Change the config option to CONFIG_SYS_VSNPRINTF
- Make the default be to NOT include safe printf functions
README | 9 ++ include/vsprintf.h | 19 ++++ lib/vsprintf.c | 265 +++++++++++++++++++++++++++++++++++++++++---------- 3 files changed, 241 insertions(+), 52 deletions(-)
Applied to "next" branch, thanks.
Best regards,
Wolfgang Denk