summaryrefslogtreecommitdiff
path: root/src/basic
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2021-04-14 06:05:47 -0400
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2021-04-14 16:19:54 +0200
commitcbe97b9c92728e96c9987314a7e1e05bbdffda16 (patch)
tree7d514b60e098d2b27e38f78aefe4ae82b1327597 /src/basic
parent111a3aae71fa019710216cc5b7aa95b7c8db0937 (diff)
downloadsystemd-cbe97b9c92728e96c9987314a7e1e05bbdffda16.tar.gz
basic/log: force log_*_errno() to return negative
This silences some warnigns where gcc thinks that some variables are unitialized. One particular case: ../src/journal/journald-server.c: In function 'ache_space_refresh': ../src/journal/journald-server.c:136:28: error: 'vfs_avail' may be used uninitialized in this function [-Werror=maybe-uninitialized] 136 | uint64_t vfs_used, vfs_avail, avail; | ^~~~~~~~~ ../src/journal/journald-server.c:136:18: error: 'vfs_used' may be used uninitialized in this function [-Werror=maybe-uninitialized] 136 | uint64_t vfs_used, vfs_avail, avail; | ^~~~~~~~ cc1: all warnings being treated as errors which is caused by d = opendir(path); if (!d) return log_full_errno(errno == ENOENT ? LOG_DEBUG : LOG_ERR, errno, "Failed to open %s: %m", path); if (fstatvfs(dirfd(d), &ss) < 0) return log_error_errno(errno, "Failed to fstatvfs(%s): %m", path); For some reason on aarch64 gcc thinks we might return non-negative here. In principle errno must be set in both cases, but it's hard to say for certain. So let's make sure that our code flow is correct, even if somebody forgot to set the global variable somewhere.
Diffstat (limited to 'src/basic')
-rw-r--r--src/basic/log.h3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/basic/log.h b/src/basic/log.h
index b3d32abfc8..4b621097d4 100644
--- a/src/basic/log.h
+++ b/src/basic/log.h
@@ -191,9 +191,10 @@ void log_assert_failed_return(
#define log_full_errno(level, error, ...) \
({ \
int _level = (level), _e = (error); \
- (log_get_max_level() >= LOG_PRI(_level)) \
+ _e = (log_get_max_level() >= LOG_PRI(_level)) \
? log_internal(_level, _e, PROJECT_FILE, __LINE__, __func__, __VA_ARGS__) \
: -ERRNO_VALUE(_e); \
+ _e < 0 ? _e : -EIO; \
})
#define log_full(level, ...) (void) log_full_errno((level), 0, __VA_ARGS__)