Skip to contentSkip to conversation

util.c: include poll.h instead of sys/poll.h

PATCH Applied Maxin B. John 3 participants 10 messages Feb 5, 2016 – Feb 11, 2016 MD RAID

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 util.c: include poll.h instead of sys/poll.h

From: "Maxin B. John" <[email protected]>

This fixes a compile warning when building with musl:

In file included from util.c:27:0:
|
qemux86-64/usr/include/sys/poll.h:1:2:
error: #warning redirecting incorrect #include <sys/poll.h> to <poll.h> [-Werror=cpp]
| #warning redirecting incorrect #include <sys/poll.h> to <poll.h>
| ^

---
 util.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
util.c +1 -1
index 970d484..3e6d293 100644
@@ -24,7 +24,6 @@
 
 #include	"mdadm.h"
 #include	"md_p.h"
-#include	<sys/poll.h>
 #include	<sys/socket.h>
 #include	<sys/utsname.h>
 #include	<sys/wait.h>
@@ -32,6 +31,7 @@
 #include	<sys/resource.h>
 #include	<sys/vfs.h>
 #include	<linux/magic.h>
+#include	<poll.h>
 #include	<ctype.h>
 #include	<dirent.h>
 #include	<signal.h>
Signature · 1 line
2.1.4
#1 lore raw

PATCH 2/3 mdadm.h: bswap is already defined in uclibc

From: "Maxin B. John" <[email protected]>

Fixes this build error:

| In file included from mdadm.c:28:0:
| mdadm.h:142:0: error: "bswap_16" redefined [-Werror]
|  #define bswap_16(x) (((x) & 0x00ffU) << 8 | \
|  ^
---
 mdadm.h | 9 +++++++++
 1 file changed, 9 insertions(+)
mdadm.h +9 -0
index dd02be7..230e60f 100755
@@ -139,12 +139,20 @@ struct dlm_lksb {
  * and there is no standard conversion function so... */
 /* And dietlibc doesn't think byteswap is ok, so.. */
 /*  #include <byteswap.h> */
+
+#ifndef bswap_16
 #define bswap_16(x) (((x) & 0x00ffU) << 8 | \
 		     ((x) & 0xff00U) >> 8)
+#endif
+
+#ifndef bswap_32
 #define bswap_32(x) (((x) & 0x000000ffU) << 24 | \
 		     ((x) & 0xff000000U) >> 24 | \
 		     ((x) & 0x0000ff00U) << 8  | \
 		     ((x) & 0x00ff0000U) >> 8)
+#endif
+
+#ifndef bswap_64
 #define bswap_64(x) (((x) & 0x00000000000000ffULL) << 56 | \
 		     ((x) & 0xff00000000000000ULL) >> 56 | \
 		     ((x) & 0x000000000000ff00ULL) << 40 | \
@@ -153,6 +161,7 @@ struct dlm_lksb {
 		     ((x) & 0x0000ff0000000000ULL) >> 24 | \
 		     ((x) & 0x00000000ff000000ULL) << 8 | \
 		     ((x) & 0x000000ff00000000ULL) >> 8)
+#endif
 
 #if !defined(__KLIBC__)
 #if BYTE_ORDER == LITTLE_ENDIAN
Signature · 1 line
2.1.4
#2 lore raw

Re: [PATCH 2/3][mdadm] mdadm.h: bswap is already defined in uclibc

Quoted 9 lines · Maxin B. John

From: "Maxin B. John" <[email protected]>

Fixes this build error:

| In file included from mdadm.c:28:0:
| mdadm.h:142:0: error: "bswap_16" redefined [-Werror]
|  #define bswap_16(x) (((x) & 0x00ffU) << 8 | \
|  ^
Quoted 4 lines
---
 mdadm.h | 9 +++++++++
 1 file changed, 9 insertions(+)

Hi Maxin,

I am not opposed to this, but I would like to understand why you see these duplicate defines. What defines it in your build environment?

Cheers,
Jes

Quoted 34 lines
mdadm.h +9 -0
index dd02be7..230e60f 100755
@@ -139,12 +139,20 @@ struct dlm_lksb {
  * and there is no standard conversion function so... */
 /* And dietlibc doesn't think byteswap is ok, so.. */
 /*  #include <byteswap.h> */
+
+#ifndef bswap_16
 #define bswap_16(x) (((x) & 0x00ffU) << 8 | \
 		     ((x) & 0xff00U) >> 8)
+#endif
+
+#ifndef bswap_32
 #define bswap_32(x) (((x) & 0x000000ffU) << 24 | \
 		     ((x) & 0xff000000U) >> 24 | \
 		     ((x) & 0x0000ff00U) << 8  | \
 		     ((x) & 0x00ff0000U) >> 8)
+#endif
+
+#ifndef bswap_64
 #define bswap_64(x) (((x) & 0x00000000000000ffULL) << 56 | \
 		     ((x) & 0xff00000000000000ULL) >> 56 | \
 		     ((x) & 0x000000000000ff00ULL) << 40 | \
@@ -153,6 +161,7 @@ struct dlm_lksb {
 		     ((x) & 0x0000ff0000000000ULL) >> 24 | \
 		     ((x) & 0x00000000ff000000ULL) << 8 | \
 		     ((x) & 0x000000ff00000000ULL) >> 8)
+#endif
 
 #if !defined(__KLIBC__)
 #if BYTE_ORDER == LITTLE_ENDIAN
#3 lore raw

Re: [PATCH 2/3][mdadm] mdadm.h: bswap is already defined in uclibc

Hi Jes,

Quoted 15 lines · Jes Sorensen
Quoted 9 lines · Maxin B. John

From: "Maxin B. John" <[email protected]>

Fixes this build error:

| In file included from mdadm.c:28:0:
| mdadm.h:142:0: error: "bswap_16" redefined [-Werror]
|  #define bswap_16(x) (((x) & 0x00ffU) << 8 | \
|  ^
Quoted 4 lines
---
 mdadm.h | 9 +++++++++
 1 file changed, 9 insertions(+)
Quoted 4 lines

Hi Maxin,

I am not opposed to this, but I would like to understand why you see these duplicate defines. What defines it in your build environment?

I get the below listed error message with uclibc builds:

| x86_64-poky-linux-uclibc-gcc -m64 -march=core2 -mtune=core2 -msse3 -mfpmath=sse --sysroot=/home/maxin/poky/build/tmp/sysroots/qemux86-64 -Wall -Werror -Wstrict-prototypes -Wextra -Wno-unused-parameter -O2 -pipe -g -feliminate-unused-debug-types -fno-strict-aliasing -DSendmail=\""/usr/sbin/sendmail -t"\" -DCONFFILE=\"/etc/mdadm.conf\" -DCONFFILE2=\"/etc/mdadm/mdadm.conf\" -DMAP_DIR=\"/run/mdadm\" -DMAP_FILE=\"map\" -DMDMON_DIR=\"/run/mdadm\" -DFAILED_SLOTS_DIR=\"/run/mdadm/failed-slots\" -DNO_COROSYNC -DNO_DLM
-DUSE_PTHREADS -DBINDIR=\"/sbin\" -c -o mdadm.o mdadm.c
| x86_64-poky-linux-uclibc-gcc -m64 -march=core2 -mtune=core2 -msse3 -mfpmath=sse --sysroot=/home/maxin/poky/build/tmp/sysroots/qemux86-64 -Wall -Werror -Wstrict-prototypes -Wextra -Wno-unused-parameter -O2 -pipe -g -feliminate-unused-debug-types -fno-strict-aliasing -DSendmail=\""/usr/sbin/sendmail -t"\" -DCONFFILE=\"/etc/mdadm.conf\" -DCONFFILE2=\"/etc/mdadm/mdadm.conf\" -DMAP_DIR=\"/run/mdadm\" -DMAP_FILE=\"map\" -DMDMON_DIR=\"/run/mdadm\" -DFAILED_SLOTS_DIR=\"/run/mdadm/failed-slots\" -DNO_COROSYNC -DNO_DLM
-DUSE_PTHREADS -DBINDIR=\"/sbin\" -c -o config.o config.c
| x86_64-poky-linux-uclibc-gcc -m64 -march=core2 -mtune=core2 -msse3 -mfpmath=sse --sysroot=/home/maxin/poky/build/tmp/sysroots/qemux86-64 -Wall -Werror -Wstrict-prototypes -Wextra -Wno-unused-parameter -O2 -pipe -g -feliminate-unused-debug-types -fno-strict-aliasing -DSendmail=\""/usr/sbin/sendmail -t"\" -DCONFFILE=\"/etc/mdadm.conf\" -DCONFFILE2=\"/etc/mdadm/mdadm.conf\" -DMAP_DIR=\"/run/mdadm\" -DMAP_FILE=\"map\" -DMDMON_DIR=\"/run/mdadm\" -DFAILED_SLOTS_DIR=\"/run/mdadm/failed-slots\" -DNO_COROSYNC -DNO_DLM
-DUSE_PTHREADS -DBINDIR=\"/sbin\" -c -o policy.o policy.c
| x86_64-poky-linux-uclibc-gcc -m64 -march=core2 -mtune=core2 -msse3 -mfpmath=sse --sysroot=/home/maxin/poky/build/tmp/sysroots/qemux86-64 -Wall -Werror -Wstrict-prototypes -Wextra -Wno-unused-parameter -O2 -pipe -g -feliminate-unused-debug-types -fno-strict-aliasing -DSendmail=\""/usr/sbin/sendmail -t"\" -DCONFFILE=\"/etc/mdadm.conf\" -DCONFFILE2=\"/etc/mdadm/mdadm.conf\" -DMAP_DIR=\"/run/mdadm\" -DMAP_FILE=\"map\" -DMDMON_DIR=\"/run/mdadm\" -DFAILED_SLOTS_DIR=\"/run/mdadm/failed-slots\" -DNO_COROSYNC -DNO_DLM
-DUSE_PTHREADS -DBINDIR=\"/sbin\" -c -o mdstat.o mdstat.c
| x86_64-poky-linux-uclibc-gcc -m64 -march=core2 -mtune=core2 -msse3 -mfpmath=sse --sysroot=/home/maxin/poky/build/tmp/sysroots/qemux86-64 -Wall -Werror -Wstrict-prototypes -Wextra -Wno-unused-parameter -O2 -pipe -g -feliminate-unused-debug-types -fno-strict-aliasing -DSendmail=\""/usr/sbin/sendmail -t"\" -DCONFFILE=\"/etc/mdadm.conf\" -DCONFFILE2=\"/etc/mdadm/mdadm.conf\" -DMAP_DIR=\"/run/mdadm\" -DMAP_FILE=\"map\" -DMDMON_DIR=\"/run/mdadm\" -DFAILED_SLOTS_DIR=\"/run/mdadm/failed-slots\" -DNO_COROSYNC -DNO_DLM
-DUSE_PTHREADS -DBINDIR=\"/sbin\" -c -o ReadMe.o ReadMe.c
| x86_64-poky-linux-uclibc-gcc -m64 -march=core2 -mtune=core2 -msse3 -mfpmath=sse --sysroot=/home/maxin/poky/build/tmp/sysroots/qemux86-64 -Wall -Werror -Wstrict-prototypes -Wextra -Wno-unused-parameter -O2 -pipe -g -feliminate-unused-debug-types -fno-strict-aliasing -DSendmail=\""/usr/sbin/sendmail -t"\" -DCONFFILE=\"/etc/mdadm.conf\" -DCONFFILE2=\"/etc/mdadm/mdadm.conf\" -DMAP_DIR=\"/run/mdadm\" -DMAP_FILE=\"map\" -DMDMON_DIR=\"/run/mdadm\" -DFAILED_SLOTS_DIR=\"/run/mdadm/failed-slots\" -DNO_COROSYNC -DNO_DLM
-DUSE_PTHREADS -DBINDIR=\"/sbin\" -c -o util.o util.c
| x86_64-poky-linux-uclibc-gcc -m64 -march=core2 -mtune=core2 -msse3 -mfpmath=sse --sysroot=/home/maxin/poky/build/tmp/sysroots/qemux86-64 -Wall -Werror -Wstrict-prototypes -Wextra -Wno-unused-parameter -O2 -pipe -g -feliminate-unused-debug-types -fno-strict-aliasing -DSendmail=\""/usr/sbin/sendmail -t"\" -DCONFFILE=\"/etc/mdadm.conf\" -DCONFFILE2=\"/etc/mdadm/mdadm.conf\" -DMAP_DIR=\"/run/mdadm\" -DMAP_FILE=\"map\" -DMDMON_DIR=\"/run/mdadm\" -DFAILED_SLOTS_DIR=\"/run/mdadm/failed-slots\" -DNO_COROSYNC -DNO_DLM
-DUSE_PTHREADS -DBINDIR=\"/sbin\" -c -o maps.o maps.c

| In file included from mdadm.c:28:0:
| mdadm.h:142:0: error: "bswap_16" redefined [-Werror]
|  #define bswap_16(x) (((x) & 0x00ffU) << 8 | \
|  ^
| In file included from
/home/maxin/poky/build/tmp/sysroots/qemux86-64/usr/include/endian.h:59:0,
|                  from
/home/maxin/poky/build/tmp/sysroots/qemux86-64/usr/include/sys/types.h:216,
|                  from mdadm.h:36,
|                  from mdadm.c:28:
| /home/maxin/poky/build/tmp/sysroots/qemux86-64/usr/include/byteswap.h:29:0:
note: this is the location of the previous definition
|  #define bswap_16(x) __bswap_16 (x)
|  ^
| In file included from mdadm.c:28:0:
| mdadm.h:144:0: error: "bswap_32" redefined [-Werror]
|  #define bswap_32(x) (((x) & 0x000000ffU) << 24 | \
|  ^
| In file included from
/home/maxin/poky/build/tmp/sysroots/qemux86-64/usr/include/endian.h:59:0,
|                  from
/home/maxin/poky/build/tmp/sysroots/qemux86-64/usr/include/sys/types.h:216,
|                  from mdadm.h:36,
|                  from mdadm.c:28:
| /home/maxin/poky/build/tmp/sysroots/qemux86-64/usr/include/byteswap.h:32:0:
note: this is the location of the previous definition
|  #define bswap_32(x) __bswap_32 (x)
|  ^
| In file included from mdadm.c:28:0:
| mdadm.h:148:0: error: "bswap_64" redefined [-Werror]
|  #define bswap_64(x) (((x) & 0x00000000000000ffULL) << 56 | \
|  ^
| In file included from
/home/maxin/poky/build/tmp/sysroots/qemux86-64/usr/include/endian.h:59:0,
|                  from
/home/maxin/poky/build/tmp/sysroots/qemux86-64/usr/include/sys/types.h:216,
|                  from mdadm.h:36,
|                  from mdadm.c:28:
| /home/maxin/poky/build/tmp/sysroots/qemux86-64/usr/include/byteswap.h:36:0:
note: this is the location of the previous definition
|  # define bswap_64(x) __bswap_64 (x)
|  ^
| In file included from config.c:25:0:
| mdadm.h:142:0: error: "bswap_16" redefined [-Werror]
|  #define bswap_16(x) (((x) & 0x00ffU) << 8 | \
|  ^
| In file included from
/home/maxin/poky/build/tmp/sysroots/qemux86-64/usr/include/endian.h:59:0,
|                  from
/home/maxin/poky/build/tmp/sysroots/qemux86-64/usr/include/sys/types.h:216,
|                  from mdadm.h:36,
|                  from config.c:25:
| /home/maxin/poky/build/tmp/sysroots/qemux86-64/usr/include/byteswap.h:29:0:
note: this is the location of the previous definition
|  #define bswap_16(x) __bswap_16 (x)
|  ^

......

Quoted 1 line

Jes

Best Regards,
Maxin

Quoted 34 lines
Quoted 34 lines
mdadm.h +9 -0
index dd02be7..230e60f 100755
@@ -139,12 +139,20 @@ struct dlm_lksb {
  * and there is no standard conversion function so... */
 /* And dietlibc doesn't think byteswap is ok, so.. */
 /*  #include <byteswap.h> */
+
+#ifndef bswap_16
 #define bswap_16(x) (((x) & 0x00ffU) << 8 | \
                   ((x) & 0xff00U) >> 8)
+#endif
+
+#ifndef bswap_32
 #define bswap_32(x) (((x) & 0x000000ffU) << 24 | \
                   ((x) & 0xff000000U) >> 24 | \
                   ((x) & 0x0000ff00U) << 8  | \
                   ((x) & 0x00ff0000U) >> 8)
+#endif
+
+#ifndef bswap_64
 #define bswap_64(x) (((x) & 0x00000000000000ffULL) << 56 | \
                   ((x) & 0xff00000000000000ULL) >> 56 | \
                   ((x) & 0x000000000000ff00ULL) << 40 | \
@@ -153,6 +161,7 @@ struct dlm_lksb {
                   ((x) & 0x0000ff0000000000ULL) >> 24 | \
                   ((x) & 0x00000000ff000000ULL) << 8 | \
                   ((x) & 0x000000ff00000000ULL) >> 8)
+#endif
 
 #if !defined(__KLIBC__)
 #if BYTE_ORDER == LITTLE_ENDIAN
#4 lore raw

Re: [PATCH 2/3][mdadm] mdadm.h: bswap is already defined in uclibc

Quoted 18 lines · Maxin B. John

Hi Jes,

Quoted 15 lines · Jes Sorensen
Quoted 13 lines · Maxin B. John

From: "Maxin B. John" <[email protected]>

Fixes this build error:

| In file included from mdadm.c:28:0:
| mdadm.h:142:0: error: "bswap_16" redefined [-Werror]
|  #define bswap_16(x) (((x) & 0x00ffU) << 8 | \
|  ^
---
 mdadm.h | 9 +++++++++
 1 file changed, 9 insertions(+)
Quoted 7 lines
Quoted 4 lines

Hi Maxin,

I am not opposed to this, but I would like to understand why you see these duplicate defines. What defines it in your build environment?

I get the below listed error message with uclibc builds:

<ship>

Quoted 56 lines
| In file included from mdadm.c:28:0:
| mdadm.h:142:0: error: "bswap_16" redefined [-Werror]
|  #define bswap_16(x) (((x) & 0x00ffU) << 8 | \
|  ^
| In file included from
/home/maxin/poky/build/tmp/sysroots/qemux86-64/usr/include/endian.h:59:0,
|                  from
/home/maxin/poky/build/tmp/sysroots/qemux86-64/usr/include/sys/types.h:216,
|                  from mdadm.h:36,
|                  from mdadm.c:28:
| /home/maxin/poky/build/tmp/sysroots/qemux86-64/usr/include/byteswap.h:29:0:
note: this is the location of the previous definition
|  #define bswap_16(x) __bswap_16 (x)
|  ^
| In file included from mdadm.c:28:0:
| mdadm.h:144:0: error: "bswap_32" redefined [-Werror]
|  #define bswap_32(x) (((x) & 0x000000ffU) << 24 | \
|  ^
| In file included from
/home/maxin/poky/build/tmp/sysroots/qemux86-64/usr/include/endian.h:59:0,
|                  from
/home/maxin/poky/build/tmp/sysroots/qemux86-64/usr/include/sys/types.h:216,
|                  from mdadm.h:36,
|                  from mdadm.c:28:
| /home/maxin/poky/build/tmp/sysroots/qemux86-64/usr/include/byteswap.h:32:0:
note: this is the location of the previous definition
|  #define bswap_32(x) __bswap_32 (x)
|  ^
| In file included from mdadm.c:28:0:
| mdadm.h:148:0: error: "bswap_64" redefined [-Werror]
|  #define bswap_64(x) (((x) & 0x00000000000000ffULL) << 56 | \
|  ^
| In file included from
/home/maxin/poky/build/tmp/sysroots/qemux86-64/usr/include/endian.h:59:0,
|                  from
/home/maxin/poky/build/tmp/sysroots/qemux86-64/usr/include/sys/types.h:216,
|                  from mdadm.h:36,
|                  from mdadm.c:28:
| /home/maxin/poky/build/tmp/sysroots/qemux86-64/usr/include/byteswap.h:36:0:
note: this is the location of the previous definition
|  # define bswap_64(x) __bswap_64 (x)
|  ^
| In file included from config.c:25:0:
| mdadm.h:142:0: error: "bswap_16" redefined [-Werror]
|  #define bswap_16(x) (((x) & 0x00ffU) << 8 | \
|  ^
| In file included from
/home/maxin/poky/build/tmp/sysroots/qemux86-64/usr/include/endian.h:59:0,
|                  from
/home/maxin/poky/build/tmp/sysroots/qemux86-64/usr/include/sys/types.h:216,
|                  from mdadm.h:36,
|                  from config.c:25:
| /home/maxin/poky/build/tmp/sysroots/qemux86-64/usr/include/byteswap.h:29:0:
note: this is the location of the previous definition
|  #define bswap_16(x) __bswap_16 (x)
|  ^
Quoted 1 line

......

Maxin,

I think it's actually wrong for uClibc to expose those macros with such a common name, but rather than picking up outside macros randomly I prefer to rename the mdadm ones to be sure we know what we are getting.

Instead of your patch, I applied this one instead. I hope that is fine with you.

Cheers,
Jes

From dd47b4e0c45fd72b94a9a7d0f0a5046ef9c8d97b Mon Sep 17 00:00:00 2001
From: Jes Sorensen <[email protected]>
Date: Wed, 10 Feb 2016 14:15:38 -0500
Subject: [PATCH] mdadm.h: rename bswap macros to avoid clash with uClibc
definitions

uClibc exposes it's own version of bswap_<X> macros. Rather than pulling in random macros by change, rename the mdadm ones to make sure we know what we are getting.

---
 mdadm.h | 52 ++++++++++++++++++++++++++--------------------------
 1 file changed, 26 insertions(+), 26 deletions(-)
mdadm.h +26 -26
index dd02be7..72888e2 100755
@@ -139,20 +139,20 @@ struct dlm_lksb {
  * and there is no standard conversion function so... */
 /* And dietlibc doesn't think byteswap is ok, so.. */
 /*  #include <byteswap.h> */
-#define bswap_16(x) (((x) & 0x00ffU) << 8 | \
-		     ((x) & 0xff00U) >> 8)
-#define bswap_32(x) (((x) & 0x000000ffU) << 24 | \
-		     ((x) & 0xff000000U) >> 24 | \
-		     ((x) & 0x0000ff00U) << 8  | \
-		     ((x) & 0x00ff0000U) >> 8)
-#define bswap_64(x) (((x) & 0x00000000000000ffULL) << 56 | \
-		     ((x) & 0xff00000000000000ULL) >> 56 | \
-		     ((x) & 0x000000000000ff00ULL) << 40 | \
-		     ((x) & 0x00ff000000000000ULL) >> 40 | \
-		     ((x) & 0x0000000000ff0000ULL) << 24 | \
-		     ((x) & 0x0000ff0000000000ULL) >> 24 | \
-		     ((x) & 0x00000000ff000000ULL) << 8 | \
-		     ((x) & 0x000000ff00000000ULL) >> 8)
+#define __mdadm_bswap_16(x) (((x) & 0x00ffU) << 8 | \
+			     ((x) & 0xff00U) >> 8)
+#define __mdadm_bswap_32(x) (((x) & 0x000000ffU) << 24 | \
+			     ((x) & 0xff000000U) >> 24 | \
+			     ((x) & 0x0000ff00U) << 8  | \
+			     ((x) & 0x00ff0000U) >> 8)
+#define __mdadm_bswap_64(x) (((x) & 0x00000000000000ffULL) << 56 | \
+			     ((x) & 0xff00000000000000ULL) >> 56 | \
+			     ((x) & 0x000000000000ff00ULL) << 40 | \
+			     ((x) & 0x00ff000000000000ULL) >> 40 | \
+			     ((x) & 0x0000000000ff0000ULL) << 24 | \
+			     ((x) & 0x0000ff0000000000ULL) >> 24 | \
+			     ((x) & 0x00000000ff000000ULL) << 8 |  \
+			     ((x) & 0x000000ff00000000ULL) >> 8)
 
 #if !defined(__KLIBC__)
 #if BYTE_ORDER == LITTLE_ENDIAN
@@ -163,19 +163,19 @@ struct dlm_lksb {
 #define __le32_to_cpu(_x) (unsigned int)(_x)
 #define __le64_to_cpu(_x) (unsigned long long)(_x)
 
-#define	__cpu_to_be16(_x) bswap_16(_x)
-#define __cpu_to_be32(_x) bswap_32(_x)
-#define __cpu_to_be64(_x) bswap_64(_x)
-#define	__be16_to_cpu(_x) bswap_16(_x)
-#define __be32_to_cpu(_x) bswap_32(_x)
-#define __be64_to_cpu(_x) bswap_64(_x)
+#define	__cpu_to_be16(_x) __mdadm_bswap_16(_x)
+#define __cpu_to_be32(_x) __mdadm_bswap_32(_x)
+#define __cpu_to_be64(_x) __mdadm_bswap_64(_x)
+#define	__be16_to_cpu(_x) __mdadm_bswap_16(_x)
+#define __be32_to_cpu(_x) __mdadm_bswap_32(_x)
+#define __be64_to_cpu(_x) __mdadm_bswap_64(_x)
 #elif BYTE_ORDER == BIG_ENDIAN
-#define	__cpu_to_le16(_x) bswap_16(_x)
-#define __cpu_to_le32(_x) bswap_32(_x)
-#define __cpu_to_le64(_x) bswap_64(_x)
-#define	__le16_to_cpu(_x) bswap_16(_x)
-#define __le32_to_cpu(_x) bswap_32(_x)
-#define __le64_to_cpu(_x) bswap_64(_x)
+#define	__cpu_to_le16(_x) __mdadm_bswap_16(_x)
+#define __cpu_to_le32(_x) __mdadm_bswap_32(_x)
+#define __cpu_to_le64(_x) __mdadm_bswap_64(_x)
+#define	__le16_to_cpu(_x) __mdadm_bswap_16(_x)
+#define __le32_to_cpu(_x) __mdadm_bswap_32(_x)
+#define __le64_to_cpu(_x) __mdadm_bswap_64(_x)
 
 #define	__cpu_to_be16(_x) (unsigned int)(_x)
 #define __cpu_to_be32(_x) (unsigned int)(_x)
Signature · 1 line
2.5.0
#5 lore raw

Re: [PATCH 2/3][mdadm] mdadm.h: bswap is already defined in uclibc

Hi Jes,

Quoted 27 lines · Jes Sorensen
Quoted 25 lines · Maxin B. John

Hi Jes,

Quoted 15 lines · Jes Sorensen
Quoted 9 lines · Maxin B. John

From: "Maxin B. John" <[email protected]>

Fixes this build error:

| In file included from mdadm.c:28:0:
| mdadm.h:142:0: error: "bswap_16" redefined [-Werror]
|  #define bswap_16(x) (((x) & 0x00ffU) << 8 | \
|  ^
Quoted 4 lines
---
 mdadm.h | 9 +++++++++
 1 file changed, 9 insertions(+)
Quoted 4 lines

Hi Maxin,

I am not opposed to this, but I would like to understand why you see these duplicate defines. What defines it in your build environment?

I get the below listed error message with uclibc builds:

<snip>

Quoted 6 lines

Maxin,

I think it's actually wrong for uClibc to expose those macros with such a common name, but rather than picking up outside macros randomly I prefer to rename the mdadm ones to be sure we know what we are getting.

That looks reasonable to me.

Quoted 2 lines

Instead of your patch, I applied this one instead. I hope that is fine with you.

Yes, this fix looks much better. Thank you!

Quoted 2 lines

Cheers,
Jes

Best Regards,
Maxin

Quoted 91 lines

From dd47b4e0c45fd72b94a9a7d0f0a5046ef9c8d97b Mon Sep 17 00:00:00 2001
From: Jes Sorensen <[email protected]>
Date: Wed, 10 Feb 2016 14:15:38 -0500
Subject: [PATCH] mdadm.h: rename bswap macros to avoid clash with uClibc
definitions

uClibc exposes it's own version of bswap_<X> macros. Rather than pulling in random macros by change, rename the mdadm ones to make sure we know what we are getting.

---
 mdadm.h | 52 ++++++++++++++++++++++++++--------------------------
 1 file changed, 26 insertions(+), 26 deletions(-)
mdadm.h +26 -27
index dd02be7..72888e2 100755
@@ -139,20 +139,20 @@ struct dlm_lksb {
  * and there is no standard conversion function so... */
 /* And dietlibc doesn't think byteswap is ok, so.. */
 /*  #include <byteswap.h> */
-#define bswap_16(x) (((x) & 0x00ffU) << 8 | \
-                    ((x) & 0xff00U) >> 8)
-#define bswap_32(x) (((x) & 0x000000ffU) << 24 | \
-                    ((x) & 0xff000000U) >> 24 | \
-                    ((x) & 0x0000ff00U) << 8  | \
-                    ((x) & 0x00ff0000U) >> 8)
-#define bswap_64(x) (((x) & 0x00000000000000ffULL) << 56 | \
-                    ((x) & 0xff00000000000000ULL) >> 56 | \
-                    ((x) & 0x000000000000ff00ULL) << 40 | \
-                    ((x) & 0x00ff000000000000ULL) >> 40 | \
-                    ((x) & 0x0000000000ff0000ULL) << 24 | \
-                    ((x) & 0x0000ff0000000000ULL) >> 24 | \
-                    ((x) & 0x00000000ff000000ULL) << 8 | \
-                    ((x) & 0x000000ff00000000ULL) >> 8)
+#define __mdadm_bswap_16(x) (((x) & 0x00ffU) << 8 | \
+                            ((x) & 0xff00U) >> 8)
+#define __mdadm_bswap_32(x) (((x) & 0x000000ffU) << 24 | \
+                            ((x) & 0xff000000U) >> 24 | \
+                            ((x) & 0x0000ff00U) << 8  | \
+                            ((x) & 0x00ff0000U) >> 8)
+#define __mdadm_bswap_64(x) (((x) & 0x00000000000000ffULL) << 56 | \
+                            ((x) & 0xff00000000000000ULL) >> 56 | \
+                            ((x) & 0x000000000000ff00ULL) << 40 | \
+                            ((x) & 0x00ff000000000000ULL) >> 40 | \
+                            ((x) & 0x0000000000ff0000ULL) << 24 | \
+                            ((x) & 0x0000ff0000000000ULL) >> 24 | \
+                            ((x) & 0x00000000ff000000ULL) << 8 |  \
+                            ((x) & 0x000000ff00000000ULL) >> 8)
 
 #if !defined(__KLIBC__)
 #if BYTE_ORDER == LITTLE_ENDIAN
@@ -163,19 +163,19 @@ struct dlm_lksb {
 #define __le32_to_cpu(_x) (unsigned int)(_x)
 #define __le64_to_cpu(_x) (unsigned long long)(_x)
 
-#define        __cpu_to_be16(_x) bswap_16(_x)
-#define __cpu_to_be32(_x) bswap_32(_x)
-#define __cpu_to_be64(_x) bswap_64(_x)
-#define        __be16_to_cpu(_x) bswap_16(_x)
-#define __be32_to_cpu(_x) bswap_32(_x)
-#define __be64_to_cpu(_x) bswap_64(_x)
+#define        __cpu_to_be16(_x) __mdadm_bswap_16(_x)
+#define __cpu_to_be32(_x) __mdadm_bswap_32(_x)
+#define __cpu_to_be64(_x) __mdadm_bswap_64(_x)
+#define        __be16_to_cpu(_x) __mdadm_bswap_16(_x)
+#define __be32_to_cpu(_x) __mdadm_bswap_32(_x)
+#define __be64_to_cpu(_x) __mdadm_bswap_64(_x)
 #elif BYTE_ORDER == BIG_ENDIAN
-#define        __cpu_to_le16(_x) bswap_16(_x)
-#define __cpu_to_le32(_x) bswap_32(_x)
-#define __cpu_to_le64(_x) bswap_64(_x)
-#define        __le16_to_cpu(_x) bswap_16(_x)
-#define __le32_to_cpu(_x) bswap_32(_x)
-#define __le64_to_cpu(_x) bswap_64(_x)
+#define        __cpu_to_le16(_x) __mdadm_bswap_16(_x)
+#define __cpu_to_le32(_x) __mdadm_bswap_32(_x)
+#define __cpu_to_le64(_x) __mdadm_bswap_64(_x)
+#define        __le16_to_cpu(_x) __mdadm_bswap_16(_x)
+#define __le32_to_cpu(_x) __mdadm_bswap_32(_x)
+#define __le64_to_cpu(_x) __mdadm_bswap_64(_x)
 
 #define        __cpu_to_be16(_x) (unsigned int)(_x)
 #define __cpu_to_be32(_x) (unsigned int)(_x)
--

2.5.0

#6 lore raw

PATCH 3/3 Monitor.c: fix compiler error with x32 toolchain

In reply to Maxin B. John

From: "Maxin B. John" <[email protected]>

With x32 toolchain, this code caused the below listed error:

| Monitor.c: In function 'check_array':
| Monitor.c:545:16: error: comparison between signed and unsigned integer expressions [-Werror=sign-compare]
| if (st->utime == array.utime &&

---
 Monitor.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Monitor.c +1 -1
index f19c2e5..748d61b 100644
@@ -542,7 +542,7 @@ static int check_array(struct state *st, struct mdstat_ent *mdstat,
 		alert("NewArray", st->devname, NULL, ainfo);
 	}
 
-	if (st->utime == array.utime &&
+	if ((unsigned long)st->utime == array.utime &&
 	    st->failed == array.failed_disks &&
 	    st->working == array.working_disks &&
 	    st->spare == array.spare_disks &&
Signature · 1 line
2.1.4
#7 lore raw

Re: [PATCH 3/3][mdadm] Monitor.c: fix compiler error with x32 toolchain

----- Original Message -----

Quoted 33 lines

From: "Maxin B. John" <[email protected]>
To: [email protected]
Cc: "Maxin B. John" <[email protected]>
Sent: Saturday, February 6, 2016 6:28:18 AM
Subject: [PATCH 3/3][mdadm] Monitor.c: fix compiler error with x32 toolchain

From: "Maxin B. John" <[email protected]>

With x32 toolchain, this code caused the below listed error:

| Monitor.c: In function 'check_array':
| Monitor.c:545:16: error: comparison between signed and unsigned integer expressions [-Werror=sign-compare]
| if (st->utime == array.utime &&

---
 Monitor.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Monitor.c +1 -1
index f19c2e5..748d61b 100644
@@ -542,7 +542,7 @@ static int check_array(struct state *st, struct
 mdstat_ent *mdstat,
 		alert("NewArray", st->devname, NULL, ainfo);
 	}
 
-	if (st->utime == array.utime &&
+	if ((unsigned long)st->utime == array.utime &&
 	    st->failed == array.failed_disks &&
 	    st->working == array.working_disks &&
Quoted 1 line

st->spare == array.spare_disks &&

Hi Maxin

I sent the patch some days ago and I think it's not what Jes wanted. You can see the mails in the list. I'll send the patch again.

Best Regards
Xiao

#8 lore raw

Re: [PATCH 3/3][mdadm] Monitor.c: fix compiler error with x32 toolchain

Hi Xiao,

Quoted 40 lines · Xiao Ni

----- Original Message -----

Quoted 33 lines

From: "Maxin B. John" <[email protected]>
To: [email protected]
Cc: "Maxin B. John" <[email protected]>
Sent: Saturday, February 6, 2016 6:28:18 AM
Subject: [PATCH 3/3][mdadm] Monitor.c: fix compiler error with x32 toolchain

From: "Maxin B. John" <[email protected]>

With x32 toolchain, this code caused the below listed error:

| Monitor.c: In function 'check_array':
| Monitor.c:545:16: error: comparison between signed and unsigned integer expressions [-Werror=sign-compare]
| if (st->utime == array.utime &&

---
 Monitor.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Monitor.c +1 -1
index f19c2e5..748d61b 100644
@@ -542,7 +542,7 @@ static int check_array(struct state *st, struct
 mdstat_ent *mdstat,
              alert("NewArray", st->devname, NULL, ainfo);
      }
 
-     if (st->utime == array.utime &&
+     if ((unsigned long)st->utime == array.utime &&
          st->failed == array.failed_disks &&
          st->working == array.working_disks &&
Quoted 1 line
          st->spare == array.spare_disks &&

Hi Maxin

Quoted 3 lines

I sent the patch some days ago and I think it's not what Jes wanted. You can see the mails in the list. I'll send the patch again.

Ah, I missed it. Thanks for fixing it.

Quoted 2 lines

Best Regards
Xiao

Thanks and Regards,
Maxin

Applied
#9 lore raw
In reply to Maxin B. John
Quoted 12 lines · Maxin B. John

From: "Maxin B. John" <[email protected]>

This fixes a compile warning when building with musl:

In file included from util.c:27:0:
|
qemux86-64/usr/include/sys/poll.h:1:2:
error: #warning redirecting incorrect #include <sys/poll.h> to <poll.h> [-Werror=cpp]
| #warning redirecting incorrect #include <sys/poll.h> to <poll.h>
| ^

Quoted 4 lines
---
 util.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Applied!

Thanks,
Jes

Quoted 21 lines
util.c +1 -1
index 970d484..3e6d293 100644
@@ -24,7 +24,6 @@
 
 #include	"mdadm.h"
 #include	"md_p.h"
-#include	<sys/poll.h>
 #include	<sys/socket.h>
 #include	<sys/utsname.h>
 #include	<sys/wait.h>
@@ -32,6 +31,7 @@
 #include	<sys/resource.h>
 #include	<sys/vfs.h>
 #include	<linux/magic.h>
+#include	<poll.h>
 #include	<ctype.h>
 #include	<dirent.h>
 #include	<signal.h>