summaryrefslogtreecommitdiffstats
path: root/src/login
diff options
context:
space:
mode:
authorLuca Boccassi <luca.boccassi@microsoft.com>2021-04-13 00:10:21 +0200
committerLuca Boccassi <luca.boccassi@microsoft.com>2021-04-14 13:25:06 +0200
commitc2b2df604b845b4e1697d0911935e6644323c5a6 (patch)
tree010d290588b55b7ed97f9e3066f56f9a9d08d77d /src/login
parentmeson: build tests with -Wno-maybe-uninitialized if -O2/-flto are used (diff)
downloadsystemd-c2b2df604b845b4e1697d0911935e6644323c5a6.tar.xz
systemd-c2b2df604b845b4e1697d0911935e6644323c5a6.zip
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/login')
-rw-r--r--src/login/logind-core.c2
-rw-r--r--src/login/logind-dbus.c4
-rw-r--r--src/login/logind-session.c8
3 files changed, 7 insertions, 7 deletions
diff --git a/src/login/logind-core.c b/src/login/logind-core.c
index 2ecf2120fd..cd3a374201 100644
--- a/src/login/logind-core.c
+++ b/src/login/logind-core.c
@@ -485,7 +485,7 @@ int config_parse_n_autovts(
static int vt_is_busy(unsigned vtnr) {
struct vt_stat vt_stat;
int r;
- _cleanup_close_ int fd;
+ _cleanup_close_ int fd = -1;
assert(vtnr >= 1);
diff --git a/src/login/logind-dbus.c b/src/login/logind-dbus.c
index 694a99fba1..feeacc2d99 100644
--- a/src/login/logind-dbus.c
+++ b/src/login/logind-dbus.c
@@ -1371,7 +1371,7 @@ static int attach_device(Manager *m, const char *seat, const char *sysfs) {
}
static int flush_devices(Manager *m) {
- _cleanup_closedir_ DIR *d;
+ _cleanup_closedir_ DIR *d = NULL;
assert(m);
@@ -2073,7 +2073,7 @@ static int update_schedule_file(Manager *m) {
m->scheduled_shutdown_type);
if (!isempty(m->wall_message)) {
- _cleanup_free_ char *t;
+ _cleanup_free_ char *t = NULL;
t = cescape(m->wall_message);
if (!t) {
diff --git a/src/login/logind-session.c b/src/login/logind-session.c
index 34fcde92aa..6a3dd860db 100644
--- a/src/login/logind-session.c
+++ b/src/login/logind-session.c
@@ -266,7 +266,7 @@ int session_save(Session *s) {
fprintf(f, "DISPLAY=%s\n", s->display);
if (s->remote_host) {
- _cleanup_free_ char *escaped;
+ _cleanup_free_ char *escaped = NULL;
escaped = cescape(s->remote_host);
if (!escaped) {
@@ -278,7 +278,7 @@ int session_save(Session *s) {
}
if (s->remote_user) {
- _cleanup_free_ char *escaped;
+ _cleanup_free_ char *escaped = NULL;
escaped = cescape(s->remote_user);
if (!escaped) {
@@ -290,7 +290,7 @@ int session_save(Session *s) {
}
if (s->service) {
- _cleanup_free_ char *escaped;
+ _cleanup_free_ char *escaped = NULL;
escaped = cescape(s->service);
if (!escaped) {
@@ -302,7 +302,7 @@ int session_save(Session *s) {
}
if (s->desktop) {
- _cleanup_free_ char *escaped;
+ _cleanup_free_ char *escaped = NULL;
escaped = cescape(s->desktop);
if (!escaped) {