diff options
author | Patrick Georgi <patrick.georgi@coresystems.de> | 2009-05-26 14:31:37 +0000 |
---|---|---|
committer | Patrick Georgi <patrick.georgi@coresystems.de> | 2009-05-26 14:31:37 +0000 |
commit | 736221f1b2c37cdcd5073d269484b4f1cf7a4e36 (patch) | |
tree | 1175c7823d30aea1eaf32be91be1eb82f0a620fe /src | |
parent | f2152ecf4f5c09eb262c99557c2adc4c413ad897 (diff) | |
download | coreboot-736221f1b2c37cdcd5073d269484b4f1cf7a4e36.tar.gz coreboot-736221f1b2c37cdcd5073d269484b4f1cf7a4e36.tar.bz2 coreboot-736221f1b2c37cdcd5073d269484b4f1cf7a4e36.zip |
Make vsprintf reentrant. More importantly, eliminate global variable.
Signed-off-by: Patrick Georgi <patrick.georgi@coresystems.de>
Acked-by: Myles Watson <mylesgw@gmail.com>
git-svn-id: svn://svn.coreboot.org/coreboot/trunk@4307 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
Diffstat (limited to 'src')
-rw-r--r-- | src/console/vsprintf.c | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/src/console/vsprintf.c b/src/console/vsprintf.c index 1ce6bd1e88df..1cfb91f02cce 100644 --- a/src/console/vsprintf.c +++ b/src/console/vsprintf.c @@ -13,22 +13,22 @@ int vtxprintf(void (*tx_byte)(unsigned char byte), const char *fmt, va_list args); -/* FIXME this global makes vsprintf non-reentrant */ - -static char *str_buf; -static void str_tx_byte(unsigned char byte) -{ - *str_buf = byte; - str_buf++; -} - int vsprintf(char * buf, const char *fmt, va_list args) { + char *str_buf; + + /* this function is only used by vsprint. + To keep str_buf local (for reentrancy + and to avoid .bss use, nest it */ + void str_tx_byte(unsigned char byte) + { + *str_buf = byte; + str_buf++; + } + int i; str_buf = buf; i = vtxprintf(str_tx_byte, fmt, args); - /* maeder/Ispiri -- The null termination was missing a deference */ - /* and was just zeroing out the pointer instead */ *str_buf = '\0'; return i; } |