Skip to contentSkip to conversation

logrotate: fix up build error with gcc 6

PATCH New Rahul Bedarkar 2 participants 4 messages Aug 19, 2016

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/2 logrotate: fix up build error with gcc 6

With gcc version 6, we see following warnings.

logrotate.c: In function 'postrotateSingleLog':
logrotate.c:1784:5: error: this 'if' clause does not guard... [-Werror=misleading-indentation]

       if (!state->doRotate)
       ^~
  logrotate.c:1787:2: note: ...this statement, but the latter is misleadingly indented as if it is guarded by the 'if'
    if (!hasErrors && log->flags & LOG_FLAG_TMPFILENAME) {
    ^~

Add a upstream patch to fix above warning.

config.c: In function 'strndup':
config.c:87:10: error: nonnull argument 's' compared to NULL [-Werror=nonnull-compare]

          if(!s)
            ^

cc1: all warnings being treated as errors
make[2]: *** [config.o] Error 1
make[2]: *** Waiting for unfinished jobs....
cc1: all warnings being treated as errors
make[2]: *** [logrotate.o] Error 1

Add a patch to drop check for nonnull to fix above warning.

Fixes:

http://autobuild.buildroot.net/results/6dc/6dc2eb22104076920d77425b1e608ef9b9e01c94/

Cc Thomas Petazzoni <[email protected]>

---
Changes v1 -> v2:
- Add upstream patch to fix second build issues instead of version bump on master branch. (Suggested by Thomas Petazzoni)

---
 .../logrotate/0002-fix-up-warning-with-gcc6.patch  | 31 ++++++++++++++++++++++
 package/logrotate/logrotate.hash                   |  1 +
 package/logrotate/logrotate.mk                     |  1 +
 3 files changed, 33 insertions(+)
 create mode 100644 package/logrotate/0002-fix-up-warning-with-gcc6.patch
package/logrotate/0002-fix-up-warning-with-gcc6.patch new file +31 -0
new file mode 100644
index 0000000..49abca3
@@ -0,0 +1,31 @@
+fix up warning with gcc6
+
+With gcc version 6, we see following warning.
+
+  config.c: In function 'strndup':
+  config.c:87:10: error: nonnull argument 's' compared to NULL [-Werror=nonnull-compare]
+          if(!s)
+            ^
+  cc1: all warnings being treated as errors
+
+strndup is declared with nonnull attribute for first parameter. In such
+cases, gcc 6 warns when we check for nonnull explicitly. So drop the
+check for nonnull.
+
+This build is found by Buildroot autobuilder.
+http://autobuild.buildroot.net/results/6dc/6dc2eb22104076920d77425b1e608ef9b9e01c94/
+
+Signed-off-by: Rahul Bedarkar <[email protected]>
+
+--- logrotate-3.9.2/config.c.old	2016-08-18 22:11:53.881100685 +0530
++++ logrotate-3.9.2/config.c	2016-08-18 22:12:58.913100548 +0530
+@@ -84,9 +84,6 @@ char *strndup(const char *s, size_t n)
+        size_t nAvail;
+        char *p;
+ 
+-       if(!s)
+-               return NULL;
+-
+        /* min() */
+        nAvail = strlen(s) + 1;
+        if ( (n + 1) < nAvail)
package/logrotate/logrotate.hash +1 -0
index 77d4dc8..8dee715 100644
@@ -1,2 +1,3 @@
 # Locally calculated
 sha256 2de00c65e23fa9d7909cae6594e550b9abe9a7eb1553669ddeaca92d30f97009 logrotate-3.9.2.tar.gz
+sha256 e0d360908ac506e02f08fa1ad70e17d6985045d8640f383fef8f322886d6e1e1 6a36c105587b07ad14fc937f3ee6e2eb402621a2.patch
package/logrotate/logrotate.mk +1 -0
index de4d837..38f183c 100644
@@ -13,6 +13,7 @@ LOGROTATE_DEPENDENCIES = popt host-pkgconf
 LOGROTATE_AUTORECONF = YES
 LOGROTATE_CONF_ENV = LIBS="`$(PKG_CONFIG_HOST_BINARY) --libs popt`"
 LOGROTATE_CONF_OPTS = --without-selinux
+LOGROTATE_PATCH = https://github.com/logrotate/logrotate/commit/6a36c105587b07ad14fc937f3ee6e2eb402621a2.patch
 
 ifeq ($(BR2_PACKAGE_ACL),y)
 LOGROTATE_DEPENDENCIES += acl
Signature · 1 line
2.6.2
#1 lore raw

PATCH v2 2/2 logrotate: bump version to 3.10.0

Cc Thomas Petazzoni <[email protected]>

---
Changes v1 -> v2:
- Rebase on top of next branch. (Suggested by Thomas Petazzoni)

---
 package/logrotate/logrotate.hash | 2 +-
 package/logrotate/logrotate.mk   | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
package/logrotate/logrotate.hash +1 -1
index 77d4dc8..ee31f8e 100644
@@ -1,2 +1,2 @@
 # Locally calculated
-sha256 2de00c65e23fa9d7909cae6594e550b9abe9a7eb1553669ddeaca92d30f97009 logrotate-3.9.2.tar.gz
+sha256 db63b5932190cba941357c029b595a7fddf43539943aa1e0ca53a96136e4c5d9 logrotate-3.10.0.tar.gz
package/logrotate/logrotate.mk +1 -1
index de4d837..96012c0 100644
@@ -4,7 +4,7 @@
 #
 ################################################################################
 
-LOGROTATE_VERSION = 3.9.2
+LOGROTATE_VERSION = 3.10.0
 LOGROTATE_SITE = $(call github,logrotate,logrotate,$(LOGROTATE_VERSION))
 LOGROTATE_LICENSE = GPLv2+
 LOGROTATE_LICENSE_FILES = COPYING
Signature · 1 line
2.6.2
#2 lore raw

PATCH v2 2/2 logrotate: bump version to 3.10.0

Hello,

Quoted 9 lines · Rahul Bedarkar
Cc Thomas Petazzoni <[email protected]>

---
Changes v1 -> v2:
- Rebase on top of next branch. (Suggested by Thomas Petazzoni)

---
 package/logrotate/logrotate.hash | 2 +-
 package/logrotate/logrotate.mk   | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

I've applied to next, after adding the second patch needed to fix the gcc 6.x build.

Thanks!

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
#3 lore raw

PATCH v2 1/2 logrotate: fix up build error with gcc 6

In reply to Rahul Bedarkar

Hello,

Quoted 21 lines · Rahul Bedarkar

With gcc version 6, we see following warnings.

logrotate.c: In function 'postrotateSingleLog':
logrotate.c:1784:5: error: this 'if' clause does not guard... [-Werror=misleading-indentation]

       if (!state->doRotate)
       ^~
  logrotate.c:1787:2: note: ...this statement, but the latter is misleadingly indented as if it is guarded by the 'if'
    if (!hasErrors && log->flags & LOG_FLAG_TMPFILENAME) {
    ^~

Add a upstream patch to fix above warning.

config.c: In function 'strndup':
config.c:87:10: error: nonnull argument 's' compared to NULL [-Werror=nonnull-compare]

          if(!s)
            ^

cc1: all warnings being treated as errors
make[2]: *** [config.o] Error 1
make[2]: *** Waiting for unfinished jobs....
cc1: all warnings being treated as errors
make[2]: *** [logrotate.o] Error 1

Quoted 8 lines

Add a patch to drop check for nonnull to fix above warning.

Fixes:

http://autobuild.buildroot.net/results/6dc/6dc2eb22104076920d77425b1e608ef9b9e01c94/

Cc Thomas Petazzoni <[email protected]>

Thanks, I've applied, but I've completely changed your patch 0002-fix-up-warning-with-gcc6.patch to use a different approach. strndup() is already in the C library, so there is no reason in our case for logrotate to use its implementation. So I've instead fixed how the availability of strndup() (and also asprintf) is checked, so that the C library version is used.

I've submitted my patch upstream:
https://github.com/logrotate/logrotate/pull/55.

Thanks!

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com