summaryrefslogtreecommitdiff
path: root/src/shared/log.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2013-04-02 16:31:55 +0200
committerLennart Poettering <lennart@poettering.net>2013-04-02 17:47:59 +0200
commit5c0aa72a4999bdcf03fe93ed5c8213c2b4c681f0 (patch)
tree470f285684f6b3e79f9ff8c561deaa07a166cb07 /src/shared/log.c
parent2875e22b65452896d5569eecb3a08265dd658173 (diff)
util: add a bit of syntactic sugar for saving/restoring errno
Diffstat (limited to 'src/shared/log.c')
-rw-r--r--src/shared/log.c31
1 files changed, 8 insertions, 23 deletions
diff --git a/src/shared/log.c b/src/shared/log.c
index 293c261f9e..0dd04bc51e 100644
--- a/src/shared/log.c
+++ b/src/shared/log.c
@@ -598,18 +598,14 @@ int log_dump_internal(
const char *func,
char *buffer) {
- int saved_errno, r;
+ PROTECT_ERRNO;
/* This modifies the buffer... */
if (_likely_(LOG_PRI(level) > log_max_level))
return 0;
- saved_errno = errno;
- r = log_dispatch(level, file, line, func, NULL, NULL, buffer);
- errno = saved_errno;
-
- return r;
+ return log_dispatch(level, file, line, func, NULL, NULL, buffer);
}
int log_metav(
@@ -620,20 +616,16 @@ int log_metav(
const char *format,
va_list ap) {
+ PROTECT_ERRNO;
char buffer[LINE_MAX];
- int saved_errno, r;
if (_likely_(LOG_PRI(level) > log_max_level))
return 0;
- saved_errno = errno;
vsnprintf(buffer, sizeof(buffer), format, ap);
char_array_0(buffer);
- r = log_dispatch(level, file, line, func, NULL, NULL, buffer);
- errno = saved_errno;
-
- return r;
+ return log_dispatch(level, file, line, func, NULL, NULL, buffer);
}
int log_meta(
@@ -663,21 +655,17 @@ int log_metav_object(
const char *format,
va_list ap) {
+ PROTECT_ERRNO;
char buffer[LINE_MAX];
- int saved_errno, r;
if (_likely_(LOG_PRI(level) > log_max_level))
return 0;
- saved_errno = errno;
vsnprintf(buffer, sizeof(buffer), format, ap);
char_array_0(buffer);
- r = log_dispatch(level, file, line, func,
- object_name, object, buffer);
- errno = saved_errno;
-
- return r;
+ return log_dispatch(level, file, line, func,
+ object_name, object, buffer);
}
int log_meta_object(
@@ -735,7 +723,7 @@ int log_struct_internal(
const char *func,
const char *format, ...) {
- int saved_errno;
+ PROTECT_ERRNO;
va_list ap;
int r;
@@ -748,8 +736,6 @@ int log_struct_internal(
if ((level & LOG_FACMASK) == 0)
level = log_facility | LOG_PRI(level);
- saved_errno = errno;
-
if ((log_target == LOG_TARGET_AUTO ||
log_target == LOG_TARGET_JOURNAL_OR_KMSG ||
log_target == LOG_TARGET_JOURNAL) &&
@@ -843,7 +829,6 @@ int log_struct_internal(
r = -EINVAL;
}
- errno = saved_errno;
return r;
}