[5/9] alpine: cast addresses to struct sockaddr *

Submitted by Andrei Vagin on Sept. 29, 2017, 10:41 p.m.

Details

Message ID 20170929224145.6764-5-avagin@openvz.org
State New
Series "Series without cover letter"
Headers show

Commit Message

Andrei Vagin Sept. 29, 2017, 10:41 p.m.
From: Andrei Vagin <avagin@virtuozzo.com>

Otherwise we get errors like this:

/usr/include/sys/socket.h:315:5: note: expected 'const struct sockaddr *' but argument is of type 'struct sockaddr_un *'
 int bind (int, const struct sockaddr *, socklen_t);

Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
---
 test/zdtm/static/del_standalone_un.c   |  2 +-
 test/zdtm/static/packet_sock_spkt.c    |  2 +-
 test/zdtm/static/sk-unix-rel.c         |  4 ++--
 test/zdtm/static/socket-ext.c          |  4 ++--
 test/zdtm/static/socket_close_data01.c |  2 +-
 test/zdtm/static/socket_dgram_data.c   |  6 +++---
 test/zdtm/static/socket_snd_addr.c     |  6 +++---
 test/zdtm/static/sockets00.c           |  6 +++---
 test/zdtm/static/sockets03.c           |  4 ++--
 test/zdtm/static/sockets_dgram.c       | 16 ++++++++--------
 10 files changed, 26 insertions(+), 26 deletions(-)

Patch hide | download patch | download mbox

diff --git a/test/zdtm/static/del_standalone_un.c b/test/zdtm/static/del_standalone_un.c
index b512ff710..f62edb2ed 100644
--- a/test/zdtm/static/del_standalone_un.c
+++ b/test/zdtm/static/del_standalone_un.c
@@ -39,7 +39,7 @@  static int bind_and_listen(struct sockaddr_un *addr)
 		return -1;
 	}
 
-	if (bind(sk, addr, sizeof(*addr))) {
+	if (bind(sk, (struct sockaddr *) addr, sizeof(*addr))) {
 		fail("bind %s", addr->sun_path);
 		close(sk);
 		return -1;
diff --git a/test/zdtm/static/packet_sock_spkt.c b/test/zdtm/static/packet_sock_spkt.c
index 4e9540fb4..55cd16518 100644
--- a/test/zdtm/static/packet_sock_spkt.c
+++ b/test/zdtm/static/packet_sock_spkt.c
@@ -23,7 +23,7 @@  static int do_bind(int sk)
 	addr.sa_family = AF_PACKET;
 	strcpy(addr.sa_data, "lo");
 
-	return bind(sk, &addr, sizeof(addr));
+	return bind(sk, (struct sockaddr *) &addr, sizeof(addr));
 }
 
 static int check_socket_binding(int sk, char *dev)
diff --git a/test/zdtm/static/sk-unix-rel.c b/test/zdtm/static/sk-unix-rel.c
index f69a81697..4f0b186d1 100644
--- a/test/zdtm/static/sk-unix-rel.c
+++ b/test/zdtm/static/sk-unix-rel.c
@@ -64,7 +64,7 @@  int main(int argc, char *argv[])
 		exit(1);
 	}
 
-	ret = bind(sock[0], &addr, addrlen);
+	ret = bind(sock[0], (struct sockaddr *) &addr, addrlen);
 	if (ret) {
 		fail("bind\n");
 		exit(1);
@@ -79,7 +79,7 @@  int main(int argc, char *argv[])
 	test_daemon();
 	test_waitsig();
 
-	if (connect(sock[1], &addr, addrlen)) {
+	if (connect(sock[1], (struct sockaddr *) &addr, addrlen)) {
 		fail("connect\n");
 		exit(1);
 	}
diff --git a/test/zdtm/static/socket-ext.c b/test/zdtm/static/socket-ext.c
index 4e550534b..c33960dbf 100644
--- a/test/zdtm/static/socket-ext.c
+++ b/test/zdtm/static/socket-ext.c
@@ -55,7 +55,7 @@  int main(int argc, char *argv[])
 			pr_perror("Can't create socket");
 			return 1;
 		}
-		ret = bind(sk, &addr, addrlen);
+		ret = bind(sk, (struct sockaddr *) &addr, addrlen);
 		if (ret < 0) {
 			pr_perror("Can't bind socket to %s", path);
 			return 1;
@@ -82,7 +82,7 @@  int main(int argc, char *argv[])
 		return 1;
 	}
 
-	ret = connect(sk, &addr, addrlen);
+	ret = connect(sk, (struct sockaddr *) &addr, addrlen);
 	if (ret < 0) {
 		pr_perror("Can't connect socket");
 		return 1;
diff --git a/test/zdtm/static/socket_close_data01.c b/test/zdtm/static/socket_close_data01.c
index 123e882db..df4b894b2 100644
--- a/test/zdtm/static/socket_close_data01.c
+++ b/test/zdtm/static/socket_close_data01.c
@@ -30,7 +30,7 @@  static int client(const char *iter)
 	addr.sun_family = AF_UNIX;
 	strcpy(addr.sun_path, filename);
 
-	if (connect(sk, (void *)&addr, sizeof(struct sockaddr_un)) < 0) {
+	if (connect(sk, (struct sockaddr *) &addr, sizeof(struct sockaddr_un)) < 0) {
 		pr_perror("connect failed %s", iter);
 		return 1;
 	}
diff --git a/test/zdtm/static/socket_dgram_data.c b/test/zdtm/static/socket_dgram_data.c
index 9437d44a3..2f635b6e6 100644
--- a/test/zdtm/static/socket_dgram_data.c
+++ b/test/zdtm/static/socket_dgram_data.c
@@ -42,15 +42,15 @@  int main(int argc, char **argv)
 	memcpy(addr.sun_path, SK_SRV, sizeof(SK_SRV));
 	addrlen = sizeof(addr.sun_family) + sizeof(SK_SRV);
 
-	if (bind(srv, &addr, addrlen)) {
+	if (bind(srv, (struct sockaddr *) &addr, addrlen)) {
 		fail("bind\n");
 		exit(1);
 	}
-	if (connect(clnt1, &addr, addrlen)) {
+	if (connect(clnt1, (struct sockaddr *) &addr, addrlen)) {
 		fail("connect\n");
 		exit(1);
 	}
-	if (connect(clnt2, &addr, addrlen)) {
+	if (connect(clnt2, (struct sockaddr *) &addr, addrlen)) {
 		fail("connect\n");
 		exit(1);
 	}
diff --git a/test/zdtm/static/socket_snd_addr.c b/test/zdtm/static/socket_snd_addr.c
index fa587a03e..7e5376e72 100644
--- a/test/zdtm/static/socket_snd_addr.c
+++ b/test/zdtm/static/socket_snd_addr.c
@@ -44,7 +44,7 @@  int main(int argc, char **argv)
 	memcpy(addr.sun_path, SK_SRV, sizeof(SK_SRV));
 	addrlen = sizeof(addr.sun_family) + sizeof(SK_SRV);
 
-	if (bind(srv, &addr, addrlen)) {
+	if (bind(srv, (struct sockaddr *) &addr, addrlen)) {
 		fail("bind\n");
 		exit(1);
 	}
@@ -58,14 +58,14 @@  int main(int argc, char **argv)
 		memcpy(addr.sun_path, sk_names[i], sizeof(SK_NAME));
 		addrlen = sizeof(addr.sun_family) + sizeof(SK_NAME);
 
-		if (bind(clnt, &addr, addrlen)) {
+		if (bind(clnt, (struct sockaddr *) &addr, addrlen)) {
 			fail("bind\n");
 			exit(1);
 		}
 
 		memcpy(addr.sun_path, SK_SRV, sizeof(SK_SRV));
 		addrlen = sizeof(addr.sun_family) + sizeof(SK_SRV);
-		if (connect(clnt, &addr, addrlen)) {
+		if (connect(clnt, (struct sockaddr *) &addr, addrlen)) {
 			fail("connect\n");
 			exit(1);
 		}
diff --git a/test/zdtm/static/sockets00.c b/test/zdtm/static/sockets00.c
index a9558d7ad..ab5d2e450 100644
--- a/test/zdtm/static/sockets00.c
+++ b/test/zdtm/static/sockets00.c
@@ -63,7 +63,7 @@  int main(int argc, char *argv[])
 		exit(1);
 	}
 
-	ret = bind(ssk_icon[0], &addr, addrlen);
+	ret = bind(ssk_icon[0], (struct sockaddr *) &addr, addrlen);
 	if (ret) {
 		fail("bind\n");
 		exit(1);
@@ -87,7 +87,7 @@  int main(int argc, char *argv[])
 		exit(1);
 	}
 
-	ret = connect(ssk_icon[2], &addr, addrlen);
+	ret = connect(ssk_icon[2], (struct sockaddr *) &addr, addrlen);
 	if (ret) {
 		fail("connect\n");
 		exit(1);
@@ -99,7 +99,7 @@  int main(int argc, char *argv[])
 		exit(1);
 	}
 
-	ret = connect(ssk_icon[1], &addr, addrlen);
+	ret = connect(ssk_icon[1], (struct sockaddr *) &addr, addrlen);
 	if (ret) {
 		fail("connect\n");
 		exit(1);
diff --git a/test/zdtm/static/sockets03.c b/test/zdtm/static/sockets03.c
index 309e7a080..f62f565c0 100644
--- a/test/zdtm/static/sockets03.c
+++ b/test/zdtm/static/sockets03.c
@@ -56,7 +56,7 @@  int main(int argc, char *argv[])
 		exit(1);
 	}
 
-	ret = bind(sk[0], &addr, addrlen);
+	ret = bind(sk[0], (struct sockaddr *) &addr, addrlen);
 	if (ret) {
 		fail("bind\n");
 		exit(1);
@@ -74,7 +74,7 @@  int main(int argc, char *argv[])
 		exit(1);
 	}
 
-	ret = connect(sk[1], &addr, addrlen);
+	ret = connect(sk[1], (struct sockaddr *) &addr, addrlen);
 	if (ret) {
 		fail("connect\n");
 		exit(1);
diff --git a/test/zdtm/static/sockets_dgram.c b/test/zdtm/static/sockets_dgram.c
index 952453d01..f135a3bbf 100644
--- a/test/zdtm/static/sockets_dgram.c
+++ b/test/zdtm/static/sockets_dgram.c
@@ -102,38 +102,38 @@  int main(int argc, char *argv[])
 	name_bound_conn.sun_family = AF_UNIX;
 	strncpy(name_bound_conn.sun_path, path, sizeof(name_bound_conn.sun_path));
 
-	ret = bind(sk_dgram_bound_server, &name_bound, sizeof(name_bound));
+	ret = bind(sk_dgram_bound_server, (struct sockaddr *) &name_bound, sizeof(name_bound));
 	if (ret) {
 		fail("bind");
 		exit(1);
 	}
 
-	ret = bind(sk_dgram_conn_server, &name_conn, sizeof(name_conn));
+	ret = bind(sk_dgram_conn_server, (struct sockaddr *) &name_conn, sizeof(name_conn));
 	if (ret) {
 		fail("bind");
 		exit(1);
 	}
 
-	ret = connect(sk_dgram_conn_client, &name_conn, sizeof(name_conn));
+	ret = connect(sk_dgram_conn_client, (struct sockaddr *) &name_conn, sizeof(name_conn));
 	if (ret) {
 		fail("connect");
 		exit(1);
 	}
 
-	ret = connect(sk_dgram_conn_client2, &name_conn, sizeof(name_conn));
+	ret = connect(sk_dgram_conn_client2, (struct sockaddr *) &name_conn, sizeof(name_conn));
 	if (ret) {
 		fail("connect");
 		exit(1);
 	}
 
-	ret = bind(sk_dgram_bound_conn, &name_bound_conn, sizeof(name_bound_conn));
+	ret = bind(sk_dgram_bound_conn, (struct sockaddr *) &name_bound_conn, sizeof(name_bound_conn));
 	if (ret) {
 		fail("bind");
 		exit(1);
 	}
 
 	/* Note, it's already bound, so make it more idiotic! */
-	ret = connect(sk_dgram_bound_conn, &name_bound_conn, sizeof(name_bound_conn));
+	ret = connect(sk_dgram_bound_conn, (struct sockaddr *) &name_bound_conn, sizeof(name_bound_conn));
 	if (ret) {
 		fail("connect");
 		exit(1);
@@ -141,7 +141,7 @@  int main(int argc, char *argv[])
 
 	memset(buf, 0, sizeof(buf));
 	sendto(sk_dgram_bound_client, SK_DATA_BOUND, sizeof(SK_DATA_BOUND), 0,
-	       &name_bound, sizeof(name_bound));
+	       (struct sockaddr *) &name_bound, sizeof(name_bound));
 	read(sk_dgram_bound_server, &buf, sizeof(buf));
 	if (strcmp(buf, SK_DATA_BOUND)) {
 		fail("data corrupted\n");
@@ -172,7 +172,7 @@  int main(int argc, char *argv[])
 
 	memset(buf, 0, sizeof(buf));
 	sendto(sk_dgram_bound_client, SK_DATA_BOUND, sizeof(SK_DATA_BOUND), 0,
-	       &name_bound, sizeof(name_bound));
+	       (struct sockaddr *) &name_bound, sizeof(name_bound));
 	read(sk_dgram_bound_server, &buf, sizeof(buf));
 	if (strcmp(buf, SK_DATA_BOUND)) {
 		fail("data corrupted\n");