Skip to contentSkip to conversation

Define _POSIX_C_SOURCE if undefined

PATCH In review Khem Raj 2 participants 3 messages Jan 14, 2016 MD RAID

lore
Share & tools
lore

Khem Raj

author
#0 lore raw

PATCH v2 1/2 Define _POSIX_C_SOURCE if undefined

config.c uses _POSIX_C_SOURCE which is defined in features.h when glibc/uclibc is used, but isn't defined when musl is used. So provide a reasonable default.

---
Changes since v1:
- Improve the commit meesage
- Divide into separate commit

 config.c | 3 +++
 1 file changed, 3 insertions(+)
config.c +3 -0
index c58c8fe..b308b6c 100644
@@ -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"
Signature · 1 line
2.7.0
author
#1 lore raw

PATCH v2 2/2 Add casts for the addr arg of connect and bind

glibc allows the addr arg to connect and socket to be any of a number of 'sockaddr_*' types, but musl requires 'const struct sockaddr *' which is in line with open group specs. So add casts to allow compilation with musl.

---
Changes since v1:
- Improve the commit meesage
- Divide into separate commit

 mdmon.c | 2 +-
 msg.c   | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
mdmon.c +1 -1
index ee12b7c..e4b73d9 100644
@@ -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;
 	}
msg.c +1 -1
index 754630b..45cd450 100644
@@ -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;
 	}
Signature · 1 line
2.7.0
#2 lore raw

Re: [PATCH V2 2/2] Add casts for the addr arg of connect and bind

Quoted 6 lines · Khem Raj

glibc allows the addr arg to connect and socket to be any of a number of 'sockaddr_*' types, but musl requires 'const struct sockaddr *' which is in line with open group specs. So add casts to allow compilation with musl.

Thanks a lot! Both patches applied.

NeilBrown