diff mbox

[2/2] logrotate: fix up build error with gcc 6

Message ID 1471539849-3766-2-git-send-email-rahul.bedarkar@imgtec.com
State Changes Requested
Headers show

Commit Message

Rahul Bedarkar Aug. 18, 2016, 5:04 p.m. UTC
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.

Fixes:

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

Signed-off-by: Rahul Bedarkar <rahul.bedarkar@imgtec.com>
---
 .../logrotate/0002-fix-up-warning-with-gcc6.patch  | 31 ++++++++++++++++++++++
 1 file changed, 31 insertions(+)
 create mode 100644 package/logrotate/0002-fix-up-warning-with-gcc6.patch

Comments

Thomas Petazzoni Aug. 18, 2016, 7:21 p.m. UTC | #1
Hello,

On Thu, 18 Aug 2016 22:34:09 +0530, Rahul Bedarkar wrote:
> 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.
> 
> Fixes:
> 
>   http://autobuild.buildroot.net/results/6dc/6dc2eb22104076920d77425b1e608ef9b9e01c94/
> 
> Signed-off-by: Rahul Bedarkar <rahul.bedarkar@imgtec.com>

Can this apply without the 3.10.0 bump?

Indeed PATCH 2/2 being a bug fix, it would be a candidate for the
"master" branch, while PATCH 1/2 being a version bump, we can only
commit it to the "next" branch.

Thanks,

Thomas
Rahul Bedarkar Aug. 19, 2016, 5:44 a.m. UTC | #2
Hi Thomas,

On Friday 19 August 2016 12:51 AM, Thomas Petazzoni wrote:
> Hello,
>
> Can this apply without the 3.10.0 bump?

Yes, but this patch fixes only one build error out of two.

We see following two build errors

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) {
   ^~
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

Another build error is fixed in upstream so PATCH 1/2 does version bump. 
Upstream commit - 
https://github.com/logrotate/logrotate/commit/6a36c105587b07ad14fc937f3ee6e2eb402621a2

>
> Indeed PATCH 2/2 being a bug fix, it would be a candidate for the
> "master" branch, while PATCH 1/2 being a version bump, we can only
> commit it to the "next" branch.

In that case, I will spin v2 of this patch and backport upstream commit 
to fix second build error.

Thanks,
Rahul
Thomas Petazzoni Aug. 19, 2016, 10:27 a.m. UTC | #3
Hello,

On Fri, 19 Aug 2016 11:14:30 +0530, Rahul Bedarkar wrote:

> > Indeed PATCH 2/2 being a bug fix, it would be a candidate for the
> > "master" branch, while PATCH 1/2 being a version bump, we can only
> > commit it to the "next" branch.  
> 
> In that case, I will spin v2 of this patch and backport upstream commit 
> to fix second build error.

OK, thanks. I've marked both of your patches as Changes Requested, so
please send a series with two patches:

 * One patch that adds the necessary fixes for the gcc 6.x build, which
   can be applied on master.

 * One patch that bumps the version of lograte to the latest one.

Thanks!

Thomas
diff mbox

Patch

diff --git a/package/logrotate/0002-fix-up-warning-with-gcc6.patch b/package/logrotate/0002-fix-up-warning-with-gcc6.patch
new file mode 100644
index 0000000..4226984
--- /dev/null
+++ b/package/logrotate/0002-fix-up-warning-with-gcc6.patch
@@ -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 <rahul.bedarkar@imgtec.com>
+
+--- logrotate-3.10.0/config.c.old	2016-08-18 22:11:53.881100685 +0530
++++ logrotate-3.10.0/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)