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>
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
This commit is contained in:
Ran Benita authored and David Herrmann committed 2012-01-11 13:28:47 +01:00
1 parent e823d283c5
commit 86ec128d91
1 file changed
+5
+5
View File
@@ -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;
}