log: make sure not to override errno
This makes things easier in the common case of <some error> -> <log error> -> <goto error handler> - <do something with errno> Signed-off-by: Ran Benita <ran234@gmail.com>
This commit is contained in:
parent
9e99726ca7
commit
9a51e10e32
@ -30,6 +30,7 @@
|
||||
* prefixes.
|
||||
*/
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@ -49,5 +50,9 @@ void log_printf(const char *format, ...)
|
||||
__attribute__ ((format (printf, 1, 0)))
|
||||
void log_vprintf(const char *format, va_list list)
|
||||
{
|
||||
int saved_errno = errno;
|
||||
|
||||
vfprintf(stderr, format, list);
|
||||
|
||||
errno = saved_errno;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user