[U-Boot] [PATCH v6 2/4] Add safe vsnprintf and snprintf library functions

Wolfgang Denk wd at denx.de
Sat Dec 17 23:33:40 CET 2011


Dear Simon Glass,

In message <1320263530-22843-3-git-send-email-sjg at chromium.org> you wrote:
> From: Sonny Rao <sonnyrao at chromium.org>
> 
> From: Sonny Rao <sonnyrao at 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 at chromium.org> modified this commit a little)
> 
> Signed-off-by: Sonny Rao <sonnyrao at 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

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
"IBM uses what I like to call the 'hole-in-the-ground  technique'  to
destroy  the  competition.....  IBM digs a big HOLE in the ground and
covers it with leaves. It then puts a big POT OF GOLD nearby. Then it
gives the call, 'Hey, look at all this gold, get over here fast.'  As
soon  as  the competitor approaches the pot, he falls into the pit"
                                                     - John C. Dvorak


More information about the U-Boot mailing list