daandemeyer / rpms / systemd

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