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
This commit is contained in:
parent
f2152ecf4f
commit
736221f1b2
|
@ -13,22 +13,22 @@
|
||||||
|
|
||||||
int vtxprintf(void (*tx_byte)(unsigned char byte), const char *fmt, va_list args);
|
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)
|
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;
|
int i;
|
||||||
str_buf = buf;
|
str_buf = buf;
|
||||||
i = vtxprintf(str_tx_byte, fmt, args);
|
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';
|
*str_buf = '\0';
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue