From 7c80f67c0c16620e8b0425a129b3dfe72a72aaed Mon Sep 17 00:00:00 2001 From: Jozsef Kadlecsik Date: Thu, 23 Dec 2010 14:44:44 +0100 Subject: Use cast to void * instead of memcpy as Sparc workaround at sockaddr_XXX. Direct cast results "cast increases required alignment of target type" on Sparc: use indirect cast to void * instead of memcpy, as Jan Engelhardt suggested. --- lib/parse.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'lib/parse.c') diff --git a/lib/parse.c b/lib/parse.c index 169d2e0..c4d9c75 100644 --- a/lib/parse.c +++ b/lib/parse.c @@ -634,15 +634,13 @@ get_addrinfo(struct ipset_session *session, continue; if (found == 0) { if (family == AF_INET) { - /* Workaround: cast increases required alignment on Sparc */ - struct sockaddr_in saddr; - memcpy(&saddr, i->ai_addr, sizeof(saddr)); - err = ipset_session_data_set(session, opt, &saddr.sin_addr); + /* Workaround: direct cast increases required alignment on Sparc */ + const struct sockaddr_in *saddr = (void *)i->ai_addr; + err = ipset_session_data_set(session, opt, &saddr->sin_addr); } else { - /* Workaround: cast increases required alignment on Sparc */ - struct sockaddr_in6 saddr; - memcpy(&saddr, i->ai_addr, sizeof(saddr)); - err = ipset_session_data_set(session, opt, &saddr.sin6_addr); + /* Workaround: direct cast increases required alignment on Sparc */ + const struct sockaddr_in6 *saddr = (void *)i->ai_addr; + err = ipset_session_data_set(session, opt, &saddr->sin6_addr); } } else if (found == 1) { ipset_warn(session, -- cgit v1.2.1