summaryrefslogtreecommitdiff
path: root/src/basic/terminal-util.c
diff options
context:
space:
mode:
authorLuca Boccassi <luca.boccassi@microsoft.com>2021-04-12 23:10:21 +0100
committerLuca Boccassi <luca.boccassi@microsoft.com>2021-04-14 12:25:06 +0100
commitc2b2df604b845b4e1697d0911935e6644323c5a6 (patch)
tree010d290588b55b7ed97f9e3066f56f9a9d08d77d /src/basic/terminal-util.c
parentbe084c0dd1f1a06320e507c0e6a9de23b37556e1 (diff)
downloadsystemd-c2b2df604b845b4e1697d0911935e6644323c5a6.tar.gz
tree-wide: avoid uninitialized warning on _cleanup_ variables
With some versions of the compiler, the _cleanup_ attr makes it think the variable might be freed/closed when uninitialized, even though it cannot happen. The added cost is small enough to be worth the benefit, and optimized builds will help reduce it even further.
Diffstat (limited to 'src/basic/terminal-util.c')
-rw-r--r--src/basic/terminal-util.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/basic/terminal-util.c b/src/basic/terminal-util.c
index 1a3f9ccb33..fafdaaa090 100644
--- a/src/basic/terminal-util.c
+++ b/src/basic/terminal-util.c
@@ -52,7 +52,7 @@ static volatile int cached_color_mode = _COLOR_INVALID;
static volatile int cached_underline_enabled = -1;
int chvt(int vt) {
- _cleanup_close_ int fd;
+ _cleanup_close_ int fd = -1;
/* Switch to the specified vt number. If the VT is specified <= 0 switch to the VT the kernel log messages go,
* if that's configured. */
@@ -514,7 +514,7 @@ int terminal_vhangup_fd(int fd) {
}
int terminal_vhangup(const char *name) {
- _cleanup_close_ int fd;
+ _cleanup_close_ int fd = -1;
fd = open_terminal(name, O_RDWR|O_NOCTTY|O_CLOEXEC|O_NONBLOCK);
if (fd < 0)