923a60
From 382877acc6c029e59e359a076d203ca03b4b9e9e Mon Sep 17 00:00:00 2001
923a60
From: Jan Synacek <jsynacek@redhat.com>
923a60
Date: Wed, 3 May 2017 14:34:36 +0200
923a60
Subject: [PATCH] compile with -Werror
923a60
923a60
The maybe-uninitialized flag has to be disabled, because gcc on RHEL7
923a60
reports tons of obvious false-positive warnings when variables are
923a60
wrapped with _cleanup_.
923a60
923a60
Also, LTO is better to be disabled. According to gcc folks, it makes
923a60
debugging really hard and is not really recommended on RHEL7. Plus it
923a60
makes the compilation fail with
923a60
923a60
In function '__ppoll_alias',
923a60
    inlined from 'bus_poll' at src/libsystemd/sd-bus/sd-bus.c:2822:11:
923a60
/usr/include/bits/poll2.h:71:9: warning: call to '__ppoll_chk_warn' declared with attribute warning: ppoll called with fds buffer too small file nfds entries
923a60
  return __ppoll_chk (__fds, __nfds, __timeout, __ss, __bos (__fds));
923a60
923a60
That is also a gcc bug, already fixed in the gcc upstream
923a60
(https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61886).
923a60
923a60
Resolves: #1447937
923a60
---
923a60
 configure.ac               | 12 ++----------
923a60
 src/core/main.c            |  1 -
923a60
 src/login/logind-session.c |  2 +-
923a60
 3 files changed, 3 insertions(+), 12 deletions(-)
923a60
923a60
diff --git a/configure.ac b/configure.ac
923a60
index 2734368dc0..def9fe5ce7 100644
923a60
--- a/configure.ac
923a60
+++ b/configure.ac
923a60
@@ -187,7 +187,8 @@ CC_CHECK_FLAGS_APPEND([with_cflags], [CFLAGS], [\
923a60
         -Wno-unused-parameter \
923a60
         -Wno-missing-field-initializers \
923a60
         -Wno-unused-result \
923a60
-        -Werror=overflow \
923a60
+        -Werror \
923a60
+        -Wno-error=maybe-uninitialized \
923a60
         -Wdate-time \
923a60
         -Wnested-externs \
923a60
         -ffast-math \
923a60
@@ -208,15 +209,6 @@ AS_CASE([$CC], [*clang*],
923a60
                -Wno-gnu-variable-sized-type-not-at-end \
923a60
         ])])
923a60
 
923a60
-AC_ARG_ENABLE([lto], AS_HELP_STRING([--disable-lto], [Disable Link time optimization]))
923a60
-AS_IF([test "x$enable_lto" != "xno"], [
923a60
-AS_CASE([$CFLAGS], [*-O[[12345\ ]]*], [
923a60
-         CC_CHECK_FLAGS_APPEND([with_cflags], [CFLAGS], [-flto -ffat-lto-objects])
923a60
-         CC_CHECK_FLAGS_APPEND([with_ldflags], [LDFLAGS],[-Wl,-fuse-ld=gold])
923a60
-         ],
923a60
-[AC_MSG_RESULT([skipping -flto, optimization not enabled])])
923a60
-])
923a60
-
923a60
 AC_SUBST([OUR_CFLAGS], "$with_cflags $sanitizer_cflags")
923a60
 
923a60
 AS_CASE([$CFLAGS], [*-O[[12345sz\ ]]*],
923a60
diff --git a/src/core/main.c b/src/core/main.c
923a60
index 50c9714f78..37e3ea0ced 100644
923a60
--- a/src/core/main.c
923a60
+++ b/src/core/main.c
923a60
@@ -1205,7 +1205,6 @@ static int status_welcome(void) {
923a60
 
923a60
 static int write_container_id(void) {
923a60
         const char *c;
923a60
-        int r;
923a60
 
923a60
         c = getenv("container");
923a60
         if (isempty(c))
923a60
diff --git a/src/login/logind-session.c b/src/login/logind-session.c
923a60
index 4575a029fe..daf875a7d3 100644
923a60
--- a/src/login/logind-session.c
923a60
+++ b/src/login/logind-session.c
923a60
@@ -183,7 +183,7 @@ int session_save(Session *s) {
923a60
                 "STATE=%s\n"
923a60
                 "REMOTE=%i\n"
923a60
                 "STOPPING=%i\n",
923a60
-                (unsigned long) s->user->uid,
923a60
+                s->user->uid,
923a60
                 s->user->name,
923a60
                 session_is_active(s),
923a60
                 session_state_to_string(session_get_state(s)),