linux-nfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Chuck Lever <chuck.lever@oracle.com>
To: steved@redhat.com
Cc: linux-nfs@vger.kernel.org
Subject: [PATCH 01/10] nfs-utils: Eliminate dereferencing type punned pointers
Date: Mon, 22 Oct 2012 12:05:46 -0400	[thread overview]
Message-ID: <20121022160546.4552.81486.stgit@lebasque.1015granger.net> (raw)
In-Reply-To: <20121022160140.4552.34477.stgit@lebasque.1015granger.net>

Clean up compiler warnings:

../../support/include/sockaddr.h: In function ‘compare_sockaddr6’:
../../support/include/sockaddr.h:197:2: warning: dereferencing
  type-punned pointer might break strict-aliasing rules
  [-Wstrict-aliasing]
../../support/include/sockaddr.h:198:7: warning: dereferencing
  type-punned pointer might break strict-aliasing rules
  [-Wstrict-aliasing]
../../support/include/sockaddr.h:199:6: warning: dereferencing
  type-punned pointer might break strict-aliasing rules
  [-Wstrict-aliasing]
../../support/include/sockaddr.h:200:7: warning: dereferencing
  type-punned pointer might break strict-aliasing rules
  [-Wstrict-aliasing]
../../support/include/sockaddr.h:204:2: warning: dereferencing
  type-punned pointer might break strict-aliasing rules
  [-Wstrict-aliasing]
../../support/include/sockaddr.h:204:2: warning: dereferencing
  type-punned pointer might break strict-aliasing rules
  [-Wstrict-aliasing]
../../support/include/sockaddr.h:204:2: warning: dereferencing
  type-punned pointer might break strict-aliasing rules
  [-Wstrict-aliasing]
../../support/include/sockaddr.h:204:2: warning: dereferencing
  type-punned pointer might break strict-aliasing rules
  [-Wstrict-aliasing]
../../support/include/sockaddr.h:204:2: warning: dereferencing
  type-punned pointer might break strict-aliasing rules
  [-Wstrict-aliasing]
../../support/include/sockaddr.h:204:2: warning: dereferencing
  type-punned pointer might break strict-aliasing rules
  [-Wstrict-aliasing]
../../support/include/sockaddr.h:204:2: warning: dereferencing
  type-punned pointer might break strict-aliasing rules
  [-Wstrict-aliasing]
../../support/include/sockaddr.h:204:2: warning: dereferencing
  type-punned pointer might break strict-aliasing rules
  [-Wstrict-aliasing]

Seen with gcc version 4.6.3 20120306 (Red Hat 4.6.3-2) (GCC)

Note also that site-local IPv6 addresses are deprecated, and thus
are no longer encountered.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
---

 support/include/sockaddr.h |   10 ++++------
 1 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/support/include/sockaddr.h b/support/include/sockaddr.h
index 9af2543..72766db 100644
--- a/support/include/sockaddr.h
+++ b/support/include/sockaddr.h
@@ -193,16 +193,14 @@ compare_sockaddr6(const struct sockaddr *sa1, const struct sockaddr *sa2)
 {
 	const struct sockaddr_in6 *sin1 = (const struct sockaddr_in6 *)sa1;
 	const struct sockaddr_in6 *sin2 = (const struct sockaddr_in6 *)sa2;
+	const struct in6_addr *saddr1 = &sin1->sin6_addr;
+	const struct in6_addr *saddr2 = &sin2->sin6_addr;
 
-	if ((IN6_IS_ADDR_LINKLOCAL((char *)&sin1->sin6_addr) &&
-	     IN6_IS_ADDR_LINKLOCAL((char *)&sin2->sin6_addr)) ||
-	    (IN6_IS_ADDR_SITELOCAL((char *)&sin1->sin6_addr) &&
-	     IN6_IS_ADDR_SITELOCAL((char *)&sin2->sin6_addr)))
+	if (IN6_IS_ADDR_LINKLOCAL(saddr1) && IN6_IS_ADDR_LINKLOCAL(saddr2))
 		if (sin1->sin6_scope_id != sin2->sin6_scope_id)
 			return false;
 
-	return IN6_ARE_ADDR_EQUAL((char *)&sin1->sin6_addr,
-					(char *)&sin2->sin6_addr);
+	return IN6_ARE_ADDR_EQUAL(saddr1, saddr2);
 }
 #else	/* !IPV6_SUPPORTED */
 static inline _Bool


  reply	other threads:[~2012-10-22 16:05 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-22 16:05 [PATCH 00/10] nfs-utils compiler warning clean ups Chuck Lever
2012-10-22 16:05 ` Chuck Lever [this message]
2012-10-22 16:05 ` [PATCH 02/10] mountd: Avoid unnecessary type conversions Chuck Lever
2012-10-22 16:06 ` [PATCH 03/10] mountd: Eliminate " Chuck Lever
2012-10-22 16:06 ` [PATCH 04/10] mountd: Make local functions static Chuck Lever
2012-10-22 16:06 ` [PATCH 05/10] mountd: Avoid unnecessary type conversions Chuck Lever
2012-10-22 16:06 ` [PATCH 06/10] " Chuck Lever
2012-10-22 16:06 ` [PATCH 07/10] " Chuck Lever
2012-10-22 16:06 ` [PATCH 08/10] rpc.gssd: Squelch compiler warning Chuck Lever
2012-10-22 16:07 ` [PATCH 09/10] " Chuck Lever
2012-10-22 16:07 ` [PATCH 10/10] rpc.gssd: Squelch compiler error Chuck Lever
2012-10-22 17:27 ` [PATCH 00/10] nfs-utils compiler warning clean ups Steve Dickson
2012-10-22 17:31   ` Chuck Lever
2012-10-30 19:36 ` Steve Dickson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20121022160546.4552.81486.stgit@lebasque.1015granger.net \
    --to=chuck.lever@oracle.com \
    --cc=linux-nfs@vger.kernel.org \
    --cc=steved@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).