naccyde / rpms / systemd

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