basic/errno-util: add helper to protect and set errno in one step
This pattern is used in a few places. Those are changed in this patch. Subsequent patches will add more.
This commit is contained in:
+3
-6
@@ -732,14 +732,12 @@ int log_internalv(
|
||||
const char *format,
|
||||
va_list ap) {
|
||||
|
||||
char buffer[LINE_MAX];
|
||||
PROTECT_ERRNO;
|
||||
|
||||
if (_likely_(LOG_PRI(level) > log_max_level))
|
||||
return -ERRNO_VALUE(error);
|
||||
|
||||
/* Make sure that %m maps to the specified error (or "Success"). */
|
||||
errno = ERRNO_VALUE(error);
|
||||
char buffer[LINE_MAX];
|
||||
LOCAL_ERRNO(ERRNO_VALUE(error));
|
||||
|
||||
(void) vsnprintf(buffer, sizeof buffer, format, ap);
|
||||
|
||||
@@ -777,14 +775,13 @@ int log_object_internalv(
|
||||
const char *format,
|
||||
va_list ap) {
|
||||
|
||||
PROTECT_ERRNO;
|
||||
char *buffer, *b;
|
||||
|
||||
if (_likely_(LOG_PRI(level) > log_max_level))
|
||||
return -ERRNO_VALUE(error);
|
||||
|
||||
/* Make sure that %m maps to the specified error (or "Success"). */
|
||||
errno = ERRNO_VALUE(error);
|
||||
LOCAL_ERRNO(ERRNO_VALUE(error));
|
||||
|
||||
/* Prepend the object name before the message */
|
||||
if (object) {
|
||||
|
||||
Reference in New Issue
Block a user