From 6ed14d48f6e9a8dfb37cc68472b04cfb3673b7bd Mon Sep 17 00:00:00 2001
From: Lee Duncan <lduncan@suse.com>
Date: Fri, 27 Mar 2020 17:50:41 -0700
Subject: [PATCH 1/3] Change include of <sys/poll.h> to <poll.h>

The proper local is <poll.h>.
---
 iscsiuio/src/unix/nic_nl.c | 2 +-
 usr/discovery.c            | 2 +-
 usr/event_poll.c           | 2 +-
 usr/io.c                   | 2 +-
 usr/netlink.c              | 2 +-
 5 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/iscsiuio/src/unix/nic_nl.c b/iscsiuio/src/unix/nic_nl.c
index f8306563..dee462e7 100644
--- a/iscsiuio/src/unix/nic_nl.c
+++ b/iscsiuio/src/unix/nic_nl.c
@@ -50,7 +50,7 @@
 #include <linux/netlink.h>
 #include <iscsi_if.h>
 #include <sys/ioctl.h>
-#include <sys/poll.h>
+#include <poll.h>
 #include <sys/types.h>
 #include <sys/user.h>
 #include <sys/socket.h>
diff --git a/usr/discovery.c b/usr/discovery.c
index 9ce122e1..7dec696f 100644
--- a/usr/discovery.c
+++ b/usr/discovery.c
@@ -25,7 +25,7 @@
 #include <stdint.h>
 #include <stdlib.h>
 #include <string.h>
-#include <sys/poll.h>
+#include <poll.h>
 #include <sys/time.h>
 #include <sys/param.h>
 #include <sys/socket.h>
diff --git a/usr/event_poll.c b/usr/event_poll.c
index 4cf4ce2b..ffd12a37 100644
--- a/usr/event_poll.c
+++ b/usr/event_poll.c
@@ -23,7 +23,7 @@
  */
 #include <stdlib.h>
 #include <errno.h>
-#include <sys/poll.h>
+#include <poll.h>
 #include <sys/types.h>
 #include <sys/wait.h>
 #include <sys/signalfd.h>
diff --git a/usr/io.c b/usr/io.c
index 210a10ad..a46c9f8c 100644
--- a/usr/io.c
+++ b/usr/io.c
@@ -24,7 +24,7 @@
 #include <signal.h>
 #include <unistd.h>
 #include <fcntl.h>
-#include <sys/poll.h>
+#include <poll.h>
 #include <sys/ioctl.h>
 #include <netinet/tcp.h>
 #include <arpa/inet.h>
diff --git a/usr/netlink.c b/usr/netlink.c
index d42ca4fb..22cad834 100644
--- a/usr/netlink.c
+++ b/usr/netlink.c
@@ -30,7 +30,7 @@
 #include <asm/types.h>
 #include <sys/socket.h>
 #include <sys/types.h>
-#include <sys/poll.h>
+#include <poll.h>
 #include <linux/netlink.h>
 
 #include "types.h"

From fbe6c1c766a88edccb0d7f4168d2d87a3cdb4660 Mon Sep 17 00:00:00 2001
From: Lee Duncan <lduncan@suse.com>
Date: Fri, 27 Mar 2020 17:57:52 -0700
Subject: [PATCH 2/3] Fix type mismatch under musl.

It complains about rl.rlim_cur and rl.rlim_max being
long long unsigned, so cast them, since it's debug
messages anyway.
---
 usr/iscsi_util.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/usr/iscsi_util.c b/usr/iscsi_util.c
index fd8fc0cf..db1dc377 100644
--- a/usr/iscsi_util.c
+++ b/usr/iscsi_util.c
@@ -152,7 +152,9 @@ int increase_max_files(void)
 		log_debug(1, "Could not get file limit (err %d)", errno);
 		return errno;
 	}
-	log_debug(1, "Max file limits %lu %lu", rl.rlim_cur, rl.rlim_max);
+	log_debug(1, "Max file limits %lu %lu",
+		        (long unsigned)rl.rlim_cur,
+			(long unsigned)rl.rlim_max);
 
 	if (rl.rlim_cur < ISCSI_MAX_FILES)
 		rl.rlim_cur = ISCSI_MAX_FILES;
@@ -162,7 +164,8 @@ int increase_max_files(void)
 	err = setrlimit(RLIMIT_NOFILE, &rl);
 	if (err) {
 		log_debug(1, "Could not set file limit to %lu/%lu (err %d)",
-			  rl.rlim_cur, rl.rlim_max, errno);
+			  (long unsigned)rl.rlim_cur,
+			  (long unsigned)rl.rlim_max, errno);
 		return errno;
 	}
 

From a93c2f1cf5a55887074bdda65aa6ad6c533191f0 Mon Sep 17 00:00:00 2001
From: Lee Duncan <lduncan@suse.com>
Date: Sun, 29 Mar 2020 11:01:07 -0700
Subject: [PATCH 3/3] More changes for musl.

Clean up some code that musl complains about. The
changes all seem like a good idea in general, and
should not effect functionality.
---
 usr/iscsistart.c | 1 -
 usr/mgmt_ipc.c   | 1 +
 usr/statics.c    | 3 +--
 3 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/usr/iscsistart.c b/usr/iscsistart.c
index 00a9c78a..ee810f7a 100644
--- a/usr/iscsistart.c
+++ b/usr/iscsistart.c
@@ -30,7 +30,6 @@
 #include <time.h>
 #include <sys/mman.h>
 #include <sys/utsname.h>
-#include <sys/signal.h>
 #include <sys/types.h>
 #include <sys/wait.h>
 
diff --git a/usr/mgmt_ipc.c b/usr/mgmt_ipc.c
index 51267c13..c292161f 100644
--- a/usr/mgmt_ipc.c
+++ b/usr/mgmt_ipc.c
@@ -26,6 +26,7 @@
 #include <unistd.h>
 #include <pwd.h>
 #include <sys/un.h>
+#include <string.h>
 
 #include "iscsid.h"
 #include "idbm.h"
diff --git a/usr/statics.c b/usr/statics.c
index 59fb044d..f59729ba 100644
--- a/usr/statics.c
+++ b/usr/statics.c
@@ -1,6 +1,6 @@
 #include <unistd.h>
 #include <pwd.h>
-#include <sys/errno.h>
+#include <errno.h>
 #include <sys/types.h>
 
 static struct passwd root_pw = {
@@ -17,4 +17,3 @@ getpwuid(uid_t uid)
 		return 0;
 	}
 }
-