linux-nfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Steve Dickson <steved@redhat.com>
To: Linux NFS Mailing list <linux-nfs@vger.kernel.org>
Subject: [PATCH] rpcbind: Remove a strict-aliasing warning
Date: Tue, 15 Jul 2014 11:53:15 -0400	[thread overview]
Message-ID: <1405439595-5544-1-git-send-email-steved@redhat.com> (raw)

src/util.c: In function ‘in6_fillscopeid’:
src/util.c:106:3: warning: dereferencing type-punned pointer will break
strict-aliasing rules [-Wstrict-aliasing]
   ifindex = ntohs(*(u_int16_t *)&sin6->sin6_addr.s6_addr[2]);
   ^

src/util.c:109:4: warning: dereferencing type-punned pointer will break
strict-aliasing rules [-Wstrict-aliasing]
    *(u_int16_t *)&sin6->sin6_addr.s6_addr[2] = 0;

Signed-off-by: Steve Dickson <steved@redhat.com>
---
 src/util.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/util.c b/src/util.c
index 9a5fb69..7d56479 100644
--- a/src/util.c
+++ b/src/util.c
@@ -101,12 +101,14 @@ static void
 in6_fillscopeid(struct sockaddr_in6 *sin6)
 {
 	u_int16_t ifindex;
+	u_int16_t *addr;
 
         if (IN6_IS_ADDR_LINKLOCAL(&sin6->sin6_addr)) {
-		ifindex = ntohs(*(u_int16_t *)&sin6->sin6_addr.s6_addr[2]);
+		addr = (u_int16_t *)&sin6->sin6_addr.s6_addr[2];
+		ifindex = ntohs(*addr);
 		if (sin6->sin6_scope_id == 0 && ifindex != 0) {
 			sin6->sin6_scope_id = ifindex;
-			*(u_int16_t *)&sin6->sin6_addr.s6_addr[2] = 0;
+			*addr = 0;
 		}
 	}
 }
-- 
1.9.3


             reply	other threads:[~2014-07-15 15:53 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-15 15:53 Steve Dickson [this message]
2014-08-18 15:03 ` [PATCH] rpcbind: Remove a strict-aliasing warning 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=1405439595-5544-1-git-send-email-steved@redhat.com \
    --to=steved@redhat.com \
    --cc=linux-nfs@vger.kernel.org \
    /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).