Skip to contentSkip to conversation

nfs-utils: Fix C aliasing rules violation in nfs_getrpccaller()

PATCH In review Chuck Lever 2 participants 2 messages Jul 6, 2010 – Jul 19, 2010 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 nfs-utils: Fix C aliasing rules violation in nfs_getrpccaller()

Squelch compiler warnings reported with -Wextra:

In file included from statd.c:24:
../../support/include/rpcmisc.h: In function ‘nfs_getrpccaller_in’:
../../support/include/rpcmisc.h:58: warning: dereferencing type-punned pointer might break strict-aliasing rules ../../support/include/rpcmisc.h: In function ‘nfs_getrpccaller’:
../../support/include/rpcmisc.h:63: warning: dereferencing type-punned pointer might break strict-aliasing rules

---
Steve-

This minor clean-up patch has been floating around in my repo for a while. Please consider applying it for the next release of nfs-utils.

 support/include/rpcmisc.h |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
support/include/rpcmisc.h +2 -2
index 1b8f411..c5847fa 100644
@@ -60,12 +60,12 @@ extern int	_rpcsvcdirty;
 
 static inline struct sockaddr_in *nfs_getrpccaller_in(SVCXPRT *xprt)
 {
-	return (struct sockaddr_in *)svc_getcaller(xprt);
+	return (struct sockaddr_in *)(char *)svc_getcaller(xprt);
 }
 
 static inline struct sockaddr *nfs_getrpccaller(SVCXPRT *xprt)
 {
-	return (struct sockaddr *)svc_getcaller(xprt);
+	return (struct sockaddr *)(char *)svc_getcaller(xprt);
 }
 
 #endif /* RPCMISC_H */

A message that is not in the archive (sent off-list or not yet received): 20100706165849.4436.13124.stgit-ewv44WTpT0t9HhUboXbp9zCvJB+x5qRC@public.gmane.org

#2 lore raw
Quoted 4 lines · Chuck Lever

Squelch compiler warnings reported with -Wextra:
=20
In file included from statd.c:24:
../../support/include/rpcmisc.h: In function =E2=80=98nfs_getrpccalle=

r_in=E2=80=99:

Quoted 1 line

../../support/include/rpcmisc.h:58: warning: dereferencing type-punne=

d

Quoted 2 lines

pointer might break strict-aliasing rules ../../support/include/rpcmisc.h: In function =E2=80=98nfs_getrpccalle=

r=E2=80=99:

Quoted 1 line

../../support/include/rpcmisc.h:63: warning: dereferencing type-punne=

d

Quoted 8 lines

pointer might break strict-aliasing rules
=20

---
Steve-
=20
This minor clean-up patch has been floating around in my repo for a while. Please consider applying it for the next release of nfs-utils=

=2E
Committed...=20

steved.

Quoted 25 lines

=20
=20

 support/include/rpcmisc.h |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

=20

support/include/rpcmisc.h +0 -0
index 1b8f411..c5847fa 100644
@@ -60,12 +60,12 @@ extern int	_rpcsvcdirty;

=20
static inline struct sockaddr_in *nfs_getrpccaller_in(SVCXPRT *xprt) {

support/include/rpcmisc.h +1 -1
-	return (struct sockaddr_in *)svc_getcaller(xprt);
+	return (struct sockaddr_in *)(char *)svc_getcaller(xprt);
 }

=20
static inline struct sockaddr *nfs_getrpccaller(SVCXPRT *xprt) {

support/include/rpcmisc.h +1 -1
-	return (struct sockaddr *)svc_getcaller(xprt);
+	return (struct sockaddr *)(char *)svc_getcaller(xprt);
 }

=20
#endif /* RPCMISC_H */
=20