Skip to contentSkip to conversation

atop: fix minor() major() build failure

PATCH Superseded Giulio Benetti 2 participants 3 messages Aug 28, 2018 1 message not in the archive

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 atop: fix minor() major() build failure

On arm / cortex-a8 Arch/Subarch sys/types.h doesn't include sys/sysmacros.h which contains minor() and major() macros.

Add patch to directly include <sys/sysmacros.h> into photosyst.c where minor() and major() macros are used.

Patch has been taken from atop upstream pull request:
https://github.com/Atoptool/atop/pull/35

Fixes
http://autobuild.buildroot.net/results/3fc/3fc0f18ed94697c404e7ff3751781789170c4fe5//

---
 ...ysmacros.h-to-compile-with-newer-gcc.patch | 52 +++++++++++++++++++
 1 file changed, 52 insertions(+)
 create mode 100644 package/atop/0001-Include-sysmacros.h-to-compile-with-newer-gcc.patch
package/atop/0001-Include-sysmacros.h-to-compile-with-newer-gcc.patch new file +52 -0
new file mode 100644
index 0000000000..a80be7b736
@@ -0,0 +1,52 @@
+From 414127c03669b4eedc85778a7bff80cf601311d8 Mon Sep 17 00:00:00 2001
+From: SjonHortensius <[email protected]>
+Date: Fri, 24 Aug 2018 18:26:58 +0200
+Subject: [PATCH] Include sysmacros.h to compile with newer gcc
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Older gcc throws a warning
+```
+photosyst.c: In function 'lvmmapname':
+photosyst.c:1465:13: warning: In the GNU C Library, "major" is defined
+ by <sys/sysmacros.h>. For historical compatibility, it is
+ currently defined by <sys/types.h> as well, but we plan to
+ remove this soon. To use "major", include <sys/sysmacros.h>
+ directly. If you did not intend to use a system-defined macro
+ "major", you should undefine it after including <sys/types.h>.
+     dmp->major  = major(statbuf.st_rdev);
+```
+
+Newer gcc throws an error:
+
+```
+photosyst.c: In function ?lvmmapname?:
+photosyst.c:1482:19: error: called object ?major? is not a function or function pointer
+     dmp->major  = major(statbuf.st_rdev);
+                   ^~~~~
+photosyst.c:1437:25: note: declared here
+ lvmmapname(unsigned int major, unsigned int minor,
+            ~~~~~~~~~~~~~^~~~~
+```
+
+Signed-off-by: Giulio Benetti <[email protected]>
+---
+ photosyst.c | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/photosyst.c b/photosyst.c
+index 19cbbe1..50841a1 100644
+--- a/photosyst.c
++++ b/photosyst.c
+@@ -152,6 +152,7 @@
+ static const char rcsid[] = "$Id: photosyst.c,v 1.38 2010/11/19 07:40:40 gerlof Exp $";
+ 
+ #include <sys/types.h>
++#include <sys/sysmacros.h>
+ #include <stdio.h>
+ #include <string.h>
+ #include <unistd.h>
+-- 
+2.17.1
+
Signature · 1 line
2.17.1

A message that is not in the archive (sent off-list or not yet received): [email protected]

#2 lore raw

PATCH v3 1/1 atop: fix minor() major() build failure

Hello,

Il 28/08/2018 18:17, Ricardo Martincoski ha scritto:

Quoted 21 lines

Hello,

Quoted 6 lines · Giulio Benetti

On arm / cortex-a8 Arch/Subarch sys/types.h doesn't include sys/sysmacros.h which contains minor() and major() macros.

Add patch to directly include <sys/sysmacros.h> into photosyst.c where minor() and major() macros are used.

Quoted 7 lines

Patch has been taken from atop upstream pull request:
https://github.com/Atoptool/atop/pull/35

Fixes
http://autobuild.buildroot.net/results/3fc/3fc0f18ed94697c404e7ff3751781789170c4fe5//

Quoted 10 lines

Regards,
--
Ricardo Martincoski
DATACOM
Ethernet Switches
Rua Am?rica, 1000 - Eldorado do Sul, RS - 92990-000 - Brasil +55 51 3933 3000 - Ramal 3307
ricardo.martincoski at datacom.com.br www.datacom.com.br

Thanks for reviewing.

Giulio Benetti

#3 lore raw

PATCH v3 1/1 atop: fix minor() major() build failure

In reply to Giulio Benetti

Hello,

Quoted 1 line · Giulio Benetti

On arm / cortex-a8 Arch/Subarch sys/types.h doesn't include

This has nothing to do with ARM/Cortex-A8, and it is the same on all architectures. The key thing is that this happens with glibc 2.28, where sys/types.h no longer includes sys/sysmacros.h.

So I've reworded the commit log as follows:

atop: fix minor()/major() build failure due to glibc 2.28

glibc 2.28 no longer includes <sys/sysmacros.h> from <sys/types.h>, and therefore <sys/sysmacros.h> must be included explicitly when major()/minor() are used. See glibc upstream commit:

https://sourceware.org/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=e16deca62e16f645213dffd4ecd1153c37765f17

This commit adds a patch to directly include <sys/sysmacros.h> into photosyst.c where minor() and major() macros are used.

Patch has been taken from atop upstream pull request:

https://github.com/Atoptool/atop/pull/35

Fixes:

http://autobuild.buildroot.net/results/3fc0f18ed94697c404e7ff3751781789170c4fe5/

[Thomas: improve commit log.]

But it's not really all your fault, because even the upstream commit log is wrong: it's talking about "old gcc" vs. "new gcc", while this problem has nothing to do with gcc, but is related to a glibc change.

Applied to next with the updated commit log. Thanks!

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com