[PATCH 68/73] mdadm: Fix build with musl

Khem Raj
2016-01-17T11:38:00Z

Define _POSIX_C_SOURCE if not defined
Add sockaddr_un* to sockaddr* typecast to make compiler happy

Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
.../0001-Define-_POSIX_C_SOURCE-if-undefined.patch | 59 ++++++++++++++++++++++
meta/recipes-extended/mdadm/mdadm_3.3.4.bb | 2 +-
2 files changed, 60 insertions(+), 1 deletion(-)
create mode 100644 meta/recipes-extended/mdadm/files/0001-Define-_POSIX_C_SOURCE-if-undefined.patch

diff --git a/meta/recipes-extended/mdadm/files/0001-Define-_POSIX_C_SOURCE-if-undefined.patch b/meta/recipes-extended/mdadm/files/0001-Define-_POSIX_C_SOURCE-if-undefined.patch
new file mode 100644
index 0000000..a461b76
--- /dev/null
+++ b/meta/recipes-extended/mdadm/files/0001-Define-_POSIX_C_SOURCE-if-undefined.patch
@@ -0,0 +1,59 @@
+From d74b02d4653d1ea26029c2528eb93d7268b83eb3 Mon Sep 17 00:00:00 2001
+From: Khem Raj <raj.khem@gmail.com>
+Date: Wed, 13 Jan 2016 07:28:33 +0000
+Subject: [PATCH] Define _POSIX_C_SOURCE if undefined
+
+typecast second argument of connect() API to use struct sockaddr*
+
+Signed-off-by: Khem Raj <raj.khem@gmail.com>
+---
+Upstream-Status: Pending
+
+ config.c | 3 +++
+ mdmon.c | 2 +-
+ msg.c | 2 +-
+ 3 files changed, 5 insertions(+), 2 deletions(-)
+
+diff --git a/config.c b/config.c
+index a882ed3..a675688 100644
+--- a/config.c
++++ b/config.c
+@@ -63,6 +63,9 @@
+ * but may not wrap over lines
+ *
+ */
++#ifndef _POSIX_C_SOURCE
++#define _POSIX_C_SOURCE 200809L
++#endif
+
+ #ifndef CONFFILE
+ #define CONFFILE "/etc/mdadm.conf"
+diff --git a/mdmon.c b/mdmon.c
+index ee12b7c..e4b73d9 100644
+--- a/mdmon.c
++++ b/mdmon.c
+@@ -235,7 +235,7 @@ static int make_control_sock(char *devname)
+ addr.sun_family = PF_LOCAL;
+ strcpy(addr.sun_path, path);
+ umask(077); /* ensure no world write access */
+- if (bind(sfd, &addr, sizeof(addr)) < 0) {
++ if (bind(sfd, (struct sockaddr*)&addr, sizeof(addr)) < 0) {
+ close(sfd);
+ return -1;
+ }
+diff --git a/msg.c b/msg.c
+index 754630b..45cd450 100644
+--- a/msg.c
++++ b/msg.c
+@@ -170,7 +170,7 @@ int connect_monitor(char *devname)
+
+ addr.sun_family = PF_LOCAL;
+ strcpy(addr.sun_path, path);
+- if (connect(sfd, &addr, sizeof(addr)) < 0) {
++ if (connect(sfd, (struct sockaddr*)&addr, sizeof(addr)) < 0) {
+ close(sfd);
+ return -1;
+ }
+--
+2.7.0
+
diff --git a/meta/recipes-extended/mdadm/mdadm_3.3.4.bb b/meta/recipes-extended/mdadm/mdadm_3.3.4.bb
index 0993611..e004030 100644
--- a/meta/recipes-extended/mdadm/mdadm_3.3.4.bb
+++ b/meta/recipes-extended/mdadm/mdadm_3.3.4.bb
@@ -14,13 +14,13 @@ SRC_URI = "${KERNELORG_MIRROR}/linux/utils/raid/mdadm/${BPN}-${PV}.tar.xz \
file://mdadm-3.3.2_x32_abi_time_t.patch \
file://0001-Fix-typo-in-comparision.patch \
file://mdadm-fix-ptest-build-errors.patch \
+ file://0001-Define-_POSIX_C_SOURCE-if-undefined.patch \
file://run-ptest \
"
SRC_URI[md5sum] = "7ca8b114710f98f53f20c5787b674a09"
SRC_URI[sha256sum] = "8ae5f45306b873190e91f410709b00e51997b633c072b33f8efd9f7df022ca68"

CFLAGS += "-fno-strict-aliasing"
-
inherit autotools-brokensep

EXTRA_OEMAKE = 'CHECK_RUN_DIR=0 CXFLAGS="${CFLAGS}"'
--
2.7.0