Remove unused sockaddr size argument, and pass address using specific struct

Signed-off-by: Rafaël Carré <fun...@videolan.org>
---
 udp.c  | 8 +++-----
 udp6.c | 7 +++----
 2 files changed, 6 insertions(+), 9 deletions(-)

diff --git a/udp.c b/udp.c
index 6ebec3e..62b5c72 100644
--- a/udp.c
+++ b/udp.c
@@ -62,12 +62,10 @@ static int mcast_bind(int fd, int index)
        return 0;
 }
 
-static int mcast_join(int fd, int index, const struct sockaddr *grp,
-                     socklen_t grplen)
+static int mcast_join(int fd, int index, const struct sockaddr_in *sa)
 {
        int err, off = 0;
        struct ip_mreqn req;
-       struct sockaddr_in *sa = (struct sockaddr_in *) grp;
 
        memset(&req, 0, sizeof(req));
        memcpy(&req.imr_multiaddr, &sa->sin_addr, sizeof(struct in_addr));
@@ -129,12 +127,12 @@ static int open_socket(const char *name, struct in_addr 
mc_addr[2], short port,
                goto no_option;
        }
        addr.sin_addr = mc_addr[0];
-       if (mcast_join(fd, index, (struct sockaddr *) &addr, sizeof(addr))) {
+       if (mcast_join(fd, index, &addr)) {
                pr_err("mcast_join failed");
                goto no_option;
        }
        addr.sin_addr = mc_addr[1];
-       if (mcast_join(fd, index, (struct sockaddr *) &addr, sizeof(addr))) {
+       if (mcast_join(fd, index, &addr)) {
                pr_err("mcast_join failed");
                goto no_option;
        }
diff --git a/udp6.c b/udp6.c
index 9978844..d3c9c86 100644
--- a/udp6.c
+++ b/udp6.c
@@ -68,11 +68,10 @@ static int mc_bind(int fd, int index)
        return 0;
 }
 
-static int mc_join(int fd, int index, const struct sockaddr *grp, socklen_t 
grplen)
+static int mc_join(int fd, int index, const struct sockaddr_in6 *sa)
 {
        int err, off = 0;
        struct ipv6_mreq req;
-       struct sockaddr_in6 *sa = (struct sockaddr_in6 *) grp;
 
        memset(&req, 0, sizeof(req));
        memcpy(&req.ipv6mr_multiaddr, &sa->sin6_addr, sizeof(struct in6_addr));
@@ -137,12 +136,12 @@ static int open_socket_ipv6(const char *name, struct 
in6_addr mc_addr[2], short
                goto no_option;
        }
        addr.sin6_addr = mc_addr[0];
-       if (mc_join(fd, index, (struct sockaddr *) &addr, sizeof(addr))) {
+       if (mc_join(fd, index, &addr)) {
                pr_err("mcast_join failed");
                goto no_option;
        }
        addr.sin6_addr = mc_addr[1];
-       if (mc_join(fd, index, (struct sockaddr *) &addr, sizeof(addr))) {
+       if (mc_join(fd, index, &addr)) {
                pr_err("mcast_join failed");
                goto no_option;
        }
-- 
2.17.1


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel

Reply via email to