* FYI: GCC warnings about strict-aliasing violation in glibc
@ 2002-11-10 1:10 Andreas Jaeger
2002-11-10 2:18 ` Andreas Jaeger
0 siblings, 1 reply; 4+ messages in thread
From: Andreas Jaeger @ 2002-11-10 1:10 UTC (permalink / raw)
To: GNU libc hacker
I got the appended warnings (just a quick grep) about violation of
strict-aliasing rules with a GCC 3.3 CVS compiler. The majority comes
from the NSS code. I suggest to get these fixed and will work on some
of them myself,
Andreas
wctob.c:65: warning: dereferencing type-punned pointer will break strict-aliasing rules
wcsrtombs.c:85: warning: dereferencing type-punned pointer will break strict-aliasing rules
wcsnrtombs.c:88: warning: dereferencing type-punned pointer will break strict-aliasing rules
wctob.c:65: warning: dereferencing type-punned pointer will break strict-aliasing rules
wcsrtombs.c:85: warning: dereferencing type-punned pointer will break strict-aliasing rules
wcsnrtombs.c:88: warning: dereferencing type-punned pointer will break strict-aliasing rules
../nss/getXXent.c:82: warning: dereferencing type-punned pointer will break strict-aliasing rules
../nss/getXXbyYY_r.c:178: warning: dereferencing type-punned pointer will break strict-aliasing rules
../nss/getXXbyYY_r.c:230: warning: dereferencing type-punned pointer will break strict-aliasing rules
../nss/getXXbyYY_r.c:178: warning: dereferencing type-punned pointer will break strict-aliasing rules
../nss/getXXbyYY_r.c:230: warning: dereferencing type-punned pointer will break strict-aliasing rules
../nss/getXXent.c:82: warning: dereferencing type-punned pointer will break strict-aliasing rules
../nss/getXXbyYY_r.c:178: warning: dereferencing type-punned pointer will break strict-aliasing rules
../nss/getXXbyYY_r.c:230: warning: dereferencing type-punned pointer will break strict-aliasing rules
../nss/getXXbyYY_r.c:178: warning: dereferencing type-punned pointer will break strict-aliasing rules
../nss/getXXbyYY_r.c:230: warning: dereferencing type-punned pointer will break strict-aliasing rules
../nss/getXXent.c:82: warning: dereferencing type-punned pointer will break strict-aliasing rules
../nss/getXXbyYY_r.c:178: warning: dereferencing type-punned pointer will break strict-aliasing rules
../nss/getXXbyYY_r.c:230: warning: dereferencing type-punned pointer will break strict-aliasing rules
../nss/getXXbyYY_r.c:178: warning: dereferencing type-punned pointer will break strict-aliasing rules
../nss/getXXbyYY_r.c:230: warning: dereferencing type-punned pointer will break strict-aliasing rules
../nss/getXXent.c:82: warning: dereferencing type-punned pointer will break strict-aliasing rules
../nss/getXXbyYY_r.c:178: warning: dereferencing type-punned pointer will break strict-aliasing rules
../nss/getXXbyYY_r.c:230: warning: dereferencing type-punned pointer will break strict-aliasing rules
../nss/getXXbyYY_r.c:178: warning: dereferencing type-punned pointer will break strict-aliasing rules
../nss/getXXbyYY_r.c:230: warning: dereferencing type-punned pointer will break strict-aliasing rules
../sysdeps/unix/sysv/linux/getsysstats.c:88: warning: dereferencing type-punned pointer will break strict-aliasing rules
../sysdeps/unix/sysv/linux/getsysstats.c:88: warning: dereferencing type-punned pointer will break strict-aliasing rules
../nss/getXXent.c:82: warning: dereferencing type-punned pointer will break strict-aliasing rules
../nss/getXXbyYY_r.c:178: warning: dereferencing type-punned pointer will break strict-aliasing rules
../nss/getXXbyYY_r.c:230: warning: dereferencing type-punned pointer will break strict-aliasing rules
../nss/getXXent.c:82: warning: dereferencing type-punned pointer will break strict-aliasing rules
../nss/getXXbyYY_r.c:178: warning: dereferencing type-punned pointer will break strict-aliasing rules
../nss/getXXbyYY_r.c:230: warning: dereferencing type-punned pointer will break strict-aliasing rules
getnssent_r.c:68: warning: dereferencing type-punned pointer will break strict-aliasing rules
getnssent_r.c:80: warning: dereferencing type-punned pointer will break strict-aliasing rules
getnssent_r.c:107: warning: dereferencing type-punned pointer will break strict-aliasing rules
getnssent_r.c:117: warning: dereferencing type-punned pointer will break strict-aliasing rules
getnssent_r.c:150: warning: dereferencing type-punned pointer will break strict-aliasing rules
getnssent_r.c:171: warning: dereferencing type-punned pointer will break strict-aliasing rules
getnssent_r.c:183: warning: dereferencing type-punned pointer will break strict-aliasing rules
getnssent_r.c:68: warning: dereferencing type-punned pointer will break strict-aliasing rules
getnssent_r.c:80: warning: dereferencing type-punned pointer will break strict-aliasing rules
getnssent_r.c:107: warning: dereferencing type-punned pointer will break strict-aliasing rules
getnssent_r.c:117: warning: dereferencing type-punned pointer will break strict-aliasing rules
getnssent_r.c:150: warning: dereferencing type-punned pointer will break strict-aliasing rules
getnssent_r.c:171: warning: dereferencing type-punned pointer will break strict-aliasing rules
getnssent_r.c:183: warning: dereferencing type-punned pointer will break strict-aliasing rules
../nss/getXXbyYY_r.c:178: warning: dereferencing type-punned pointer will break strict-aliasing rules
../nss/getXXbyYY_r.c:230: warning: dereferencing type-punned pointer will break strict-aliasing rules
../nss/getXXbyYY_r.c:178: warning: dereferencing type-punned pointer will break strict-aliasing rules
../nss/getXXbyYY_r.c:230: warning: dereferencing type-punned pointer will break strict-aliasing rules
../nss/getXXbyYY_r.c:178: warning: dereferencing type-punned pointer will break strict-aliasing rules
../nss/getXXbyYY_r.c:230: warning: dereferencing type-punned pointer will break strict-aliasing rules
../nss/getXXent.c:82: warning: dereferencing type-punned pointer will break strict-aliasing rules
../nss/getXXbyYY_r.c:178: warning: dereferencing type-punned pointer will break strict-aliasing rules
../nss/getXXbyYY_r.c:230: warning: dereferencing type-punned pointer will break strict-aliasing rules
../nss/getXXent.c:82: warning: dereferencing type-punned pointer will break strict-aliasing rules
../nss/getXXbyYY_r.c:178: warning: dereferencing type-punned pointer will break strict-aliasing rules
../nss/getXXbyYY_r.c:230: warning: dereferencing type-punned pointer will break strict-aliasing rules
../nss/getXXbyYY_r.c:178: warning: dereferencing type-punned pointer will break strict-aliasing rules
../nss/getXXbyYY_r.c:230: warning: dereferencing type-punned pointer will break strict-aliasing rules
../nss/getXXent.c:82: warning: dereferencing type-punned pointer will break strict-aliasing rules
../nss/getXXbyYY_r.c:178: warning: dereferencing type-punned pointer will break strict-aliasing rules
../nss/getXXbyYY_r.c:230: warning: dereferencing type-punned pointer will break strict-aliasing rules
../nss/getXXbyYY_r.c:178: warning: dereferencing type-punned pointer will break strict-aliasing rules
../nss/getXXbyYY_r.c:230: warning: dereferencing type-punned pointer will break strict-aliasing rules
../nss/getXXbyYY_r.c:178: warning: dereferencing type-punned pointer will break strict-aliasing rules
../nss/getXXbyYY_r.c:230: warning: dereferencing type-punned pointer will break strict-aliasing rules
../nss/getXXent.c:82: warning: dereferencing type-punned pointer will break strict-aliasing rules
../nss/getXXent.c:82: warning: dereferencing type-punned pointer will break strict-aliasing rules
../nss/getXXbyYY_r.c:178: warning: dereferencing type-punned pointer will break strict-aliasing rules
../nss/getXXbyYY_r.c:230: warning: dereferencing type-punned pointer will break strict-aliasing rules
../nss/getXXbyYY_r.c:178: warning: dereferencing type-punned pointer will break strict-aliasing rules
../nss/getXXbyYY_r.c:230: warning: dereferencing type-punned pointer will break strict-aliasing rules
ether_hton.c:49: warning: dereferencing type-punned pointer will break strict-aliasing rules
ether_hton.c:70: warning: dereferencing type-punned pointer will break strict-aliasing rules
ether_ntoh.c:50: warning: dereferencing type-punned pointer will break strict-aliasing rules
ether_ntoh.c:71: warning: dereferencing type-punned pointer will break strict-aliasing rules
getnetgrent_r.c:105: warning: dereferencing type-punned pointer will break strict-aliasing rules
getnetgrent_r.c:111: warning: dereferencing type-punned pointer will break strict-aliasing rules
getnetgrent_r.c:168: warning: dereferencing type-punned pointer will break strict-aliasing rules
getnetgrent_r.c:175: warning: dereferencing type-punned pointer will break strict-aliasing rules
getnetgrent_r.c:209: warning: dereferencing type-punned pointer will break strict-aliasing rules
getnetgrent_r.c:265: warning: dereferencing type-punned pointer will break strict-aliasing rules
getnetgrent_r.c:318: warning: dereferencing type-punned pointer will break strict-aliasing rules
getnetgrent_r.c:330: warning: dereferencing type-punned pointer will break strict-aliasing rules
getnetgrent_r.c:392: warning: dereferencing type-punned pointer will break strict-aliasing rules
getnetgrent_r.c:397: warning: dereferencing type-punned pointer will break strict-aliasing rules
../nss/getXXent.c:82: warning: dereferencing type-punned pointer will break strict-aliasing rules
../nss/getXXbyYY_r.c:178: warning: dereferencing type-punned pointer will break strict-aliasing rules
../nss/getXXbyYY_r.c:230: warning: dereferencing type-punned pointer will break strict-aliasing rules
../nss/getXXbyYY_r.c:178: warning: dereferencing type-punned pointer will break strict-aliasing rules
../nss/getXXbyYY_r.c:230: warning: dereferencing type-punned pointer will break strict-aliasing rules
../nss/getXXbyYY_r.c:178: warning: dereferencing type-punned pointer will break strict-aliasing rules
../nss/getXXbyYY_r.c:230: warning: dereferencing type-punned pointer will break strict-aliasing rules
../nss/getXXbyYY_r.c:178: warning: dereferencing type-punned pointer will break strict-aliasing rules
../nss/getXXbyYY_r.c:230: warning: dereferencing type-punned pointer will break strict-aliasing rules
../nss/getXXent.c:82: warning: dereferencing type-punned pointer will break strict-aliasing rules
../nss/getXXbyYY_r.c:178: warning: dereferencing type-punned pointer will break strict-aliasing rules
../nss/getXXbyYY_r.c:230: warning: dereferencing type-punned pointer will break strict-aliasing rules
../nss/getXXent.c:82: warning: dereferencing type-punned pointer will break strict-aliasing rules
../nss/getXXbyYY_r.c:178: warning: dereferencing type-punned pointer will break strict-aliasing rules
../nss/getXXbyYY_r.c:230: warning: dereferencing type-punned pointer will break strict-aliasing rules
../nss/getXXbyYY_r.c:178: warning: dereferencing type-punned pointer will break strict-aliasing rules
../nss/getXXbyYY_r.c:230: warning: dereferencing type-punned pointer will break strict-aliasing rules
../nss/getXXent.c:82: warning: dereferencing type-punned pointer will break strict-aliasing rules
../nss/getXXbyYY_r.c:178: warning: dereferencing type-punned pointer will break strict-aliasing rules
../nss/getXXbyYY_r.c:230: warning: dereferencing type-punned pointer will break strict-aliasing rules
../nss/getXXbyYY_r.c:178: warning: dereferencing type-punned pointer will break strict-aliasing rules
../nss/getXXbyYY_r.c:230: warning: dereferencing type-punned pointer will break strict-aliasing rules
../nss/getXXbyYY_r.c:178: warning: dereferencing type-punned pointer will break strict-aliasing rules
../nss/getXXbyYY_r.c:230: warning: dereferencing type-punned pointer will break strict-aliasing rules
../nss/getXXent.c:82: warning: dereferencing type-punned pointer will break strict-aliasing rules
../nss/getXXent.c:82: warning: dereferencing type-punned pointer will break strict-aliasing rules
../nss/getXXbyYY_r.c:178: warning: dereferencing type-punned pointer will break strict-aliasing rules
../nss/getXXbyYY_r.c:230: warning: dereferencing type-punned pointer will break strict-aliasing rules
../nss/getXXbyYY_r.c:178: warning: dereferencing type-punned pointer will break strict-aliasing rules
../nss/getXXbyYY_r.c:230: warning: dereferencing type-punned pointer will break strict-aliasing rules
ether_hton.c:49: warning: dereferencing type-punned pointer will break strict-aliasing rules
ether_hton.c:70: warning: dereferencing type-punned pointer will break strict-aliasing rules
ether_ntoh.c:50: warning: dereferencing type-punned pointer will break strict-aliasing rules
ether_ntoh.c:71: warning: dereferencing type-punned pointer will break strict-aliasing rules
getnetgrent_r.c:105: warning: dereferencing type-punned pointer will break strict-aliasing rules
getnetgrent_r.c:111: warning: dereferencing type-punned pointer will break strict-aliasing rules
getnetgrent_r.c:168: warning: dereferencing type-punned pointer will break strict-aliasing rules
getnetgrent_r.c:175: warning: dereferencing type-punned pointer will break strict-aliasing rules
getnetgrent_r.c:209: warning: dereferencing type-punned pointer will break strict-aliasing rules
getnetgrent_r.c:265: warning: dereferencing type-punned pointer will break strict-aliasing rules
getnetgrent_r.c:318: warning: dereferencing type-punned pointer will break strict-aliasing rules
getnetgrent_r.c:330: warning: dereferencing type-punned pointer will break strict-aliasing rules
getnetgrent_r.c:392: warning: dereferencing type-punned pointer will break strict-aliasing rules
getnetgrent_r.c:397: warning: dereferencing type-punned pointer will break strict-aliasing rules
../nss/getXXent.c:82: warning: dereferencing type-punned pointer will break strict-aliasing rules
../nss/getXXbyYY_r.c:178: warning: dereferencing type-punned pointer will break strict-aliasing rules
../nss/getXXbyYY_r.c:230: warning: dereferencing type-punned pointer will break strict-aliasing rules
publickey.c:51: warning: dereferencing type-punned pointer will break strict-aliasing rules
publickey.c:70: warning: dereferencing type-punned pointer will break strict-aliasing rules
publickey.c:90: warning: dereferencing type-punned pointer will break strict-aliasing rules
publickey.c:109: warning: dereferencing type-punned pointer will break strict-aliasing rules
netname.c:156: warning: dereferencing type-punned pointer will break strict-aliasing rules
netname.c:175: warning: dereferencing type-punned pointer will break strict-aliasing rules
publickey.c:51: warning: dereferencing type-punned pointer will break strict-aliasing rules
publickey.c:70: warning: dereferencing type-punned pointer will break strict-aliasing rules
publickey.c:90: warning: dereferencing type-punned pointer will break strict-aliasing rules
publickey.c:109: warning: dereferencing type-punned pointer will break strict-aliasing rules
netname.c:156: warning: dereferencing type-punned pointer will break strict-aliasing rules
netname.c:175: warning: dereferencing type-punned pointer will break strict-aliasing rules
programs/ld-collate.c:612: warning: dereferencing type-punned pointer will break strict-aliasing rules
programs/ld-collate.c:629: warning: dereferencing type-punned pointer will break strict-aliasing rules
programs/ld-collate.c:948: warning: dereferencing type-punned pointer will break strict-aliasing rules
programs/ld-collate.c:984: warning: dereferencing type-punned pointer will break strict-aliasing rules
programs/ld-collate.c:1173: warning: dereferencing type-punned pointer will break strict-aliasing rules
programs/ld-collate.c:1328: warning: dereferencing type-punned pointer will break strict-aliasing rules
programs/ld-collate.c:3048: warning: dereferencing type-punned pointer will break strict-aliasing rules
programs/ld-collate.c:3311: warning: dereferencing type-punned pointer will break strict-aliasing rules
programs/ld-collate.c:3320: warning: dereferencing type-punned pointer will break strict-aliasing rules
programs/ld-collate.c:3337: warning: dereferencing type-punned pointer will break strict-aliasing rules
programs/ld-collate.c:3522: warning: dereferencing type-punned pointer will break strict-aliasing rules
programs/ld-collate.c:3576: warning: dereferencing type-punned pointer will break strict-aliasing rules
programs/ld-collate.c:3584: warning: dereferencing type-punned pointer will break strict-aliasing rules
gethnamaddr.c:622: warning: dereferencing type-punned pointer will break strict-aliasing rules
gethnamaddr.c:712: warning: dereferencing type-punned pointer will break strict-aliasing rules
gethnamaddr.c:717: warning: dereferencing type-punned pointer will break strict-aliasing rules
res_send.c:565: warning: dereferencing type-punned pointer will break strict-aliasing rules
gethnamaddr.c:622: warning: dereferencing type-punned pointer will break strict-aliasing rules
gethnamaddr.c:712: warning: dereferencing type-punned pointer will break strict-aliasing rules
gethnamaddr.c:717: warning: dereferencing type-punned pointer will break strict-aliasing rules
res_send.c:565: warning: dereferencing type-punned pointer will break strict-aliasing rules
nss_dns/dns-host.c:176: warning: dereferencing type-punned pointer will break strict-aliasing rules
nss_dns/dns-host.c:193: warning: dereferencing type-punned pointer will break strict-aliasing rules
nss_dns/dns-host.c:311: warning: dereferencing type-punned pointer will break strict-aliasing rules
nss_dns/dns-host.c:317: warning: dereferencing type-punned pointer will break strict-aliasing rules
nss_dns/dns-network.c:126: warning: dereferencing type-punned pointer will break strict-aliasing rules
nss_dns/dns-network.c:196: warning: dereferencing type-punned pointer will break strict-aliasing rules
../nss/getXXbyYY_r.c:178: warning: dereferencing type-punned pointer will break strict-aliasing rules
../nss/getXXbyYY_r.c:230: warning: dereferencing type-punned pointer will break strict-aliasing rules
../nss/getXXbyYY_r.c:178: warning: dereferencing type-punned pointer will break strict-aliasing rules
../nss/getXXbyYY_r.c:230: warning: dereferencing type-punned pointer will break strict-aliasing rules
../nss/getXXbyYY_r.c:178: warning: dereferencing type-punned pointer will break strict-aliasing rules
../nss/getXXbyYY_r.c:230: warning: dereferencing type-punned pointer will break strict-aliasing rules
../nss/getXXbyYY_r.c:178: warning: dereferencing type-punned pointer will break strict-aliasing rules
../nss/getXXbyYY_r.c:230: warning: dereferencing type-punned pointer will break strict-aliasing rules
../nss/getXXbyYY_r.c:178: warning: dereferencing type-punned pointer will break strict-aliasing rules
../nss/getXXbyYY_r.c:230: warning: dereferencing type-punned pointer will break strict-aliasing rules
../nss/getXXbyYY_r.c:178: warning: dereferencing type-punned pointer will break strict-aliasing rules
../nss/getXXbyYY_r.c:230: warning: dereferencing type-punned pointer will break strict-aliasing rules
--
Andreas Jaeger
SuSE Labs aj@suse.de
private aj@arthur.inka.de
http://www.suse.de/~aj
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: FYI: GCC warnings about strict-aliasing violation in glibc
2002-11-10 1:10 FYI: GCC warnings about strict-aliasing violation in glibc Andreas Jaeger
@ 2002-11-10 2:18 ` Andreas Jaeger
2002-11-10 2:23 ` Ulrich Drepper
0 siblings, 1 reply; 4+ messages in thread
From: Andreas Jaeger @ 2002-11-10 2:18 UTC (permalink / raw)
To: GNU libc hacker
Here's a fix to get rid of a number of these warnings. Ok to commit?
Andreas
2002-11-10 Andreas Jaeger <aj@suse.de>
* nss/getXXent.c (GETFUNC_NAME): Use union type to avoid strict
aliasing problem.
* nss/getXXbyYY_r.c (INTERNAL): Likewise.
* nss/getnssent_r.c (__nss_getent_r): Likewise.
(__nss_setent): Likewise.
(__nss_getent_r): Likewise.
============================================================
Index: nss/getXXent.c
--- nss/getXXent.c 1 Nov 2002 20:43:39 -0000 1.14
+++ nss/getXXent.c 10 Nov 2002 09:50:49 -0000
@@ -70,7 +70,12 @@ LOOKUP_TYPE *
GETFUNC_NAME (void)
{
static size_t buffer_size;
- static LOOKUP_TYPE resbuf;
+ static union
+ {
+ LOOKUP_TYPE l;
+ void *ptr;
+ } resbuf;
+
LOOKUP_TYPE *result;
int save;
@@ -79,7 +84,7 @@ GETFUNC_NAME (void)
result = (LOOKUP_TYPE *)
__nss_getent ((getent_r_function) INTERNAL (REENTRANT_GETNAME),
- (void **) &resbuf, &buffer, BUFLEN, &buffer_size,
+ &resbuf.ptr, &buffer, BUFLEN, &buffer_size,
H_ERRNO_VAR);
save = errno;
============================================================
Index: nss/getXXbyYY_r.c
--- nss/getXXbyYY_r.c 12 Sep 2002 05:14:59 -0000 1.47
+++ nss/getXXbyYY_r.c 10 Nov 2002 09:50:49 -0000
@@ -130,7 +130,12 @@ INTERNAL (REENTRANT_NAME) (ADD_PARAMS, L
static service_user *startp;
static lookup_function start_fct;
service_user *nip;
- lookup_function fct;
+ union
+ {
+ lookup_function l;
+ void *ptr;
+ } fct;
+
int no_more;
enum nss_status status = NSS_STATUS_UNAVAIL;
#ifdef USE_NSCD
@@ -175,13 +180,13 @@ INTERNAL (REENTRANT_NAME) (ADD_PARAMS, L
if (startp == NULL)
{
- no_more = DB_LOOKUP_FCT (&nip, REENTRANT_NAME_STRING, (void **) &fct);
+ no_more = DB_LOOKUP_FCT (&nip, REENTRANT_NAME_STRING, &fct.ptr);
if (no_more)
startp = (service_user *) -1l;
else
{
startp = nip;
- start_fct = fct;
+ start_fct = fct.l;
#ifdef NEED__RES
/* The resolver code will really be used so we have to
@@ -201,7 +206,7 @@ INTERNAL (REENTRANT_NAME) (ADD_PARAMS, L
}
else
{
- fct = start_fct;
+ fct.l = start_fct;
no_more = (nip = startp) == (service_user *) -1l;
}
@@ -211,7 +216,7 @@ INTERNAL (REENTRANT_NAME) (ADD_PARAMS, L
any_service = true;
#endif
- status = DL_CALL_FCT (fct, (ADD_VARIABLES, resbuf, buffer, buflen,
+ status = DL_CALL_FCT (fct.l, (ADD_VARIABLES, resbuf, buffer, buflen,
&errno H_ERRNO_VAR));
/* The status is NSS_STATUS_TRYAGAIN and errno is ERANGE the
@@ -227,7 +232,7 @@ INTERNAL (REENTRANT_NAME) (ADD_PARAMS, L
break;
no_more = __nss_next (&nip, REENTRANT_NAME_STRING,
- (void **) &fct, status, 0);
+ &fct.ptr, status, 0);
}
#ifdef HANDLE_DIGITS_DOTS
============================================================
Index: nss/getnssent_r.c
--- nss/getnssent_r.c 12 Sep 2002 02:58:21 -0000 1.4
+++ nss/getnssent_r.c 10 Nov 2002 09:50:49 -0000
@@ -53,7 +53,11 @@ __nss_setent (const char *func_name, db_
service_user **last_nip, int stayopen, int *stayopen_tmp,
int res)
{
- setent_function fct;
+ union
+ {
+ setent_function f;
+ void *ptr;
+ } fct;
int no_more;
if (res && (_res.options & RES_INIT) == 0
@@ -65,7 +69,7 @@ __nss_setent (const char *func_name, db_
/* Cycle through the services and run their `setXXent' functions until
we find an available service. */
- no_more = setup (func_name, lookup_fct, (void **) &fct, nip,
+ no_more = setup (func_name, lookup_fct, &fct.ptr, nip,
startp, 1);
while (! no_more)
{
@@ -73,11 +77,11 @@ __nss_setent (const char *func_name, db_
enum nss_status status;
if (stayopen_tmp)
- status = DL_CALL_FCT (fct, (*stayopen_tmp));
+ status = DL_CALL_FCT (fct.f, (*stayopen_tmp));
else
- status = DL_CALL_FCT (fct, (0));
+ status = DL_CALL_FCT (fct.f, (0));
- no_more = __nss_next (nip, func_name, (void **) &fct,
+ no_more = __nss_next (nip, func_name, &fct.ptr,
status, 0);
if (is_last_nip)
*last_nip = *nip;
@@ -93,7 +97,11 @@ __nss_endent (const char *func_name, db_
service_user **nip, service_user **startp,
service_user **last_nip, int res)
{
- endent_function fct;
+ union
+ {
+ endent_function f;
+ void *ptr;
+ } fct;
int no_more;
if (res && (_res.options & RES_INIT) == 0
@@ -104,17 +112,17 @@ __nss_endent (const char *func_name, db_
}
/* Cycle through all the services and run their endXXent functions. */
- no_more = setup (func_name, lookup_fct, (void **) &fct, nip, startp, 1);
+ no_more = setup (func_name, lookup_fct, &fct.ptr, nip, startp, 1);
while (! no_more)
{
/* Ignore status, we force check in __NSS_NEXT. */
- DL_CALL_FCT (fct, ());
+ DL_CALL_FCT (fct.f, ());
if (*nip == *last_nip)
/* We have processed all services which were used. */
break;
- no_more = __nss_next (nip, func_name, (void **) &fct, 0, 1);
+ no_more = __nss_next (nip, func_name, &fct.ptr, 0, 1);
}
*last_nip = *nip = NULL;
}
@@ -129,7 +137,11 @@ __nss_getent_r (const char *getent_func_
void *resbuf, char *buffer, size_t buflen,
void **result, int *h_errnop)
{
- getent_function fct;
+ union
+ {
+ getent_function f;
+ void *ptr;
+ } fct;
int no_more;
enum nss_status status;
@@ -147,13 +159,13 @@ __nss_getent_r (const char *getent_func_
/* Run through available functions, starting with the same function last
run. We will repeat each function as long as it succeeds, and then go
on to the next service action. */
- no_more = setup (getent_func_name, lookup_fct, (void **) &fct, nip,
+ no_more = setup (getent_func_name, lookup_fct, &fct.ptr, nip,
startp, 0);
while (! no_more)
{
int is_last_nip = *nip == *last_nip;
- status = DL_CALL_FCT (fct,
+ status = DL_CALL_FCT (fct.f,
(resbuf, buffer, buflen, &errno, &h_errno));
/* The the status is NSS_STATUS_TRYAGAIN and errno is ERANGE the
@@ -168,7 +180,7 @@ __nss_getent_r (const char *getent_func_
do
{
- no_more = __nss_next (nip, getent_func_name, (void **) &fct,
+ no_more = __nss_next (nip, getent_func_name, &fct.ptr,
status, 0);
if (is_last_nip)
@@ -177,17 +189,21 @@ __nss_getent_r (const char *getent_func_
if (! no_more)
{
/* Call the `setXXent' function. This wasn't done before. */
- setent_function sfct;
+ union
+ {
+ setent_function f;
+ void *ptr;
+ } sfct;
no_more = __nss_lookup (nip, setent_func_name,
- (void **) &sfct);
+ &sfct.ptr);
if (! no_more)
{
if (stayopen_tmp)
- status = DL_CALL_FCT (sfct, (*stayopen_tmp));
+ status = DL_CALL_FCT (sfct.f, (*stayopen_tmp));
else
- status = DL_CALL_FCT (sfct, (0));
+ status = DL_CALL_FCT (sfct.f, (0));
}
else
status = NSS_STATUS_NOTFOUND;
--
Andreas Jaeger
SuSE Labs aj@suse.de
private aj@arthur.inka.de
http://www.suse.de/~aj
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: FYI: GCC warnings about strict-aliasing violation in glibc
2002-11-10 2:18 ` Andreas Jaeger
@ 2002-11-10 2:23 ` Ulrich Drepper
2002-11-10 3:05 ` Andreas Jaeger
0 siblings, 1 reply; 4+ messages in thread
From: Ulrich Drepper @ 2002-11-10 2:23 UTC (permalink / raw)
To: Andreas Jaeger; +Cc: GNU libc hacker
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
./tex/latex/fancyvrb/Andreas Jaeger wrote:
> Here's a fix to get rid of a number of these warnings. Ok to commit?
Yes, but fix the indentation:
> @@ -211,7 +216,7 @@ INTERNAL (REENTRANT_NAME) (ADD_PARAMS, L
> any_service = true;
> #endif
>
> - status = DL_CALL_FCT (fct, (ADD_VARIABLES, resbuf, buffer, buflen,
> + status = DL_CALL_FCT (fct.l, (ADD_VARIABLES, resbuf, buffer, buflen,
> &errno H_ERRNO_VAR));
(last line).
- --
- --------------. ,-. 444 Castro Street
Ulrich Drepper \ ,-----------------' \ Mountain View, CA 94041 USA
Red Hat `--' drepper at redhat.com `---------------------------
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (GNU/Linux)
iD8DBQE9zjOO2ijCOnn/RHQRAhOEAKCdUmtLyOgmRtRRwwHknP3n1e/boACfTxvq
W3peZ6AgnxsTOwA7Wh2EB3Y=
=LaKj
-----END PGP SIGNATURE-----
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: FYI: GCC warnings about strict-aliasing violation in glibc
2002-11-10 2:23 ` Ulrich Drepper
@ 2002-11-10 3:05 ` Andreas Jaeger
0 siblings, 0 replies; 4+ messages in thread
From: Andreas Jaeger @ 2002-11-10 3:05 UTC (permalink / raw)
To: Ulrich Drepper; +Cc: GNU libc hacker
Ulrich Drepper <drepper@redhat.com> writes:
> ./tex/latex/fancyvrb/Andreas Jaeger wrote:
>> Here's a fix to get rid of a number of these warnings. Ok to commit?
>
> Yes, but fix the indentation:
Ok, done. I've also committed some more files that I fixed in the
meantime in the same way, so that the network code is ok now.
This leaves these warnings:
wctob.c:65: warning: dereferencing type-punned pointer will break strict-aliasing rules
wcsrtombs.c:85: warning: dereferencing type-punned pointer will break strict-aliasing rules
wcsnrtombs.c:88: warning: dereferencing type-punned pointer will break strict-aliasing rules
wctob.c:65: warning: dereferencing type-punned pointer will break strict-aliasing rules
wcsrtombs.c:85: warning: dereferencing type-punned pointer will break strict-aliasing rules
wcsnrtombs.c:88: warning: dereferencing type-punned pointer will break strict-aliasing rules
../sysdeps/unix/sysv/linux/getsysstats.c:88: warning: dereferencing type-punned pointer will break strict-aliasing rules
../sysdeps/unix/sysv/linux/getsysstats.c:88: warning: dereferencing type-punned pointer will break strict-aliasing rules
programs/ld-collate.c:612: warning: dereferencing type-punned pointer will break strict-aliasing rules
programs/ld-collate.c:629: warning: dereferencing type-punned pointer will break strict-aliasing rules
programs/ld-collate.c:948: warning: dereferencing type-punned pointer will break strict-aliasing rules
programs/ld-collate.c:984: warning: dereferencing type-punned pointer will break strict-aliasing rules
programs/ld-collate.c:1173: warning: dereferencing type-punned pointer will break strict-aliasing rules
programs/ld-collate.c:1328: warning: dereferencing type-punned pointer will break strict-aliasing rules
programs/ld-collate.c:3048: warning: dereferencing type-punned pointer will break strict-aliasing rules
programs/ld-collate.c:3311: warning: dereferencing type-punned pointer will break strict-aliasing rules
programs/ld-collate.c:3320: warning: dereferencing type-punned pointer will break strict-aliasing rules
programs/ld-collate.c:3337: warning: dereferencing type-punned pointer will break strict-aliasing rules
programs/ld-collate.c:3522: warning: dereferencing type-punned pointer will break strict-aliasing rules
programs/ld-collate.c:3576: warning: dereferencing type-punned pointer will break strict-aliasing rules
programs/ld-collate.c:3584: warning: dereferencing type-punned pointer will break strict-aliasing rules
I'll leave this for another time or for somebody else to look at,
Andreas
2002-11-10 Andreas Jaeger <aj@suse.de>
* nss/getXXent.c (GETFUNC_NAME): Use union type to avoid strict
aliasing problem.
* nss/getXXbyYY_r.c (INTERNAL): Likewise.
* nss/getnssent_r.c (__nss_getent_r): Likewise.
(__nss_setent): Likewise.
(__nss_getent_r): Likewise.
* inet/getnetgrent_r.c (innetgr): Likewise.
(__internal_setnetgrent_reuse): Likewise.
(internal_getnetgrent_r): Likewise.
* inet/ether_hton.c (ether_hostton): Likewise.
* inet/ether_ntoh.c (ether_ntohost): Likewise.
* sunrpc/netname.c (netname2user): Likewise.
* sunrpc/publickey.c (getpublickey): Likewise.
(getsecretkey): Likewise.
============================================================
Index: inet/ether_hton.c
--- inet/ether_hton.c 3 Apr 2002 00:31:31 -0000 1.10
+++ inet/ether_hton.c 10 Nov 2002 11:05:03 -0000
@@ -39,25 +39,29 @@ ether_hostton (const char *hostname, str
static service_user *startp;
static lookup_function start_fct;
service_user *nip;
- lookup_function fct;
+ union
+ {
+ lookup_function f;
+ void *ptr;
+ } fct;
int no_more;
enum nss_status status = NSS_STATUS_UNAVAIL;
struct etherent etherent;
if (startp == NULL)
{
- no_more = __nss_ethers_lookup (&nip, "gethostton_r", (void **) &fct);
+ no_more = __nss_ethers_lookup (&nip, "gethostton_r", &fct.ptr);
if (no_more)
startp = (service_user *) -1;
else
{
startp = nip;
- start_fct = fct;
+ start_fct = fct.f;
}
}
else
{
- fct = start_fct;
+ fct.f = start_fct;
no_more = (nip = startp) == (service_user *) -1;
}
@@ -65,9 +69,9 @@ ether_hostton (const char *hostname, str
{
char buffer[1024];
- status = (*fct) (hostname, ðerent, buffer, sizeof buffer, &errno);
+ status = (*fct.f) (hostname, ðerent, buffer, sizeof buffer, &errno);
- no_more = __nss_next (&nip, "gethostton_r", (void **) &fct, status, 0);
+ no_more = __nss_next (&nip, "gethostton_r", &fct.ptr, status, 0);
}
if (status == NSS_STATUS_SUCCESS)
============================================================
Index: inet/ether_ntoh.c
--- inet/ether_ntoh.c 3 Apr 2002 00:31:14 -0000 1.10
+++ inet/ether_ntoh.c 10 Nov 2002 11:05:03 -0000
@@ -40,25 +40,29 @@ ether_ntohost (char *hostname, const str
static service_user *startp;
static lookup_function start_fct;
service_user *nip;
- lookup_function fct;
+ union
+ {
+ lookup_function f;
+ void *ptr;
+ } fct;
int no_more;
enum nss_status status = NSS_STATUS_UNAVAIL;
struct etherent etherent;
if (startp == NULL)
{
- no_more = __nss_ethers_lookup (&nip, "getntohost_r", (void **) &fct);
+ no_more = __nss_ethers_lookup (&nip, "getntohost_r", &fct.ptr);
if (no_more)
startp = (service_user *) -1;
else
{
startp = nip;
- start_fct = fct;
+ start_fct = fct.f;
}
}
else
{
- fct = start_fct;
+ fct.f = start_fct;
no_more = (nip = startp) == (service_user *) -1;
}
@@ -66,9 +70,9 @@ ether_ntohost (char *hostname, const str
{
char buffer[1024];
- status = (*fct) (addr, ðerent, buffer, sizeof buffer, &errno);
+ status = (*fct.f) (addr, ðerent, buffer, sizeof buffer, &errno);
- no_more = __nss_next (&nip, "getntohost_r", (void **) &fct, status, 0);
+ no_more = __nss_next (&nip, "getntohost_r", &fct.ptr, status, 0);
}
if (status == NSS_STATUS_SUCCESS)
============================================================
Index: inet/getnetgrent_r.c
--- inet/getnetgrent_r.c 8 Aug 2002 01:32:48 -0000 1.23
+++ inet/getnetgrent_r.c 10 Nov 2002 11:05:04 -0000
@@ -96,19 +96,23 @@ internal_function
__internal_setnetgrent_reuse (const char *group, struct __netgrent *datap,
int *errnop)
{
- enum nss_status (*fct) (const char *, struct __netgrent *);
+ union
+ {
+ enum nss_status (*f) (const char *, struct __netgrent *);
+ void *ptr;
+ } fct;
enum nss_status status = NSS_STATUS_UNAVAIL;
struct name_list *new_elem;
int no_more;
/* Cycle through all the services and run their setnetgrent functions. */
- no_more = setup ((void **) &fct, "setnetgrent", 1);
+ no_more = setup (&fct.ptr, "setnetgrent", 1);
while (! no_more)
{
/* Ignore status, we force check in `__nss_next'. */
- status = (*fct) (group, datap);
+ status = (*fct.f) (group, datap);
- no_more = __nss_next (&nip, "setnetgrent", (void **) &fct, status, 0);
+ no_more = __nss_next (&nip, "setnetgrent", &fct.ptr, status, 0);
}
/* Add the current group to the list of known groups. */
@@ -158,21 +162,25 @@ static void
internal_endnetgrent (struct __netgrent *datap)
{
service_user *old_nip;
- enum nss_status (*fct) (struct __netgrent *);
+ union
+ {
+ enum nss_status (*f) (struct __netgrent *);
+ void *ptr;
+ } fct;
int no_more;
/* Remember which was the last used service. */
old_nip = nip;
/* Cycle through all the services and run their endnetgrent functions. */
- no_more = setup ((void **) &fct, "endnetgrent", 1);
+ no_more = setup (&fct.ptr, "endnetgrent", 1);
while (! no_more)
{
/* Ignore status, we force check in `__nss_next'. */
- (void) (*fct) (datap);
+ (void) (*fct.f) (datap);
no_more = (nip == old_nip
- || __nss_next (&nip, "endnetgrent", (void **) &fct, 0, 1));
+ || __nss_next (&nip, "endnetgrent", &fct.ptr, 0, 1));
}
/* Now free list of all netgroup names from last run. */
@@ -197,7 +205,11 @@ internal_getnetgrent_r (char **hostp, ch
struct __netgrent *datap,
char *buffer, size_t buflen, int *errnop)
{
- enum nss_status (*fct) (struct __netgrent *, char *, size_t, int *);
+ union
+ {
+ enum nss_status (*f) (struct __netgrent *, char *, size_t, int *);
+ void *ptr;
+ } fct;
int no_more;
/* Initialize status to return if no more functions are found. */
@@ -206,10 +218,10 @@ internal_getnetgrent_r (char **hostp, ch
/* Run through available functions, starting with the same function last
run. We will repeat each function as long as it succeeds, and then go
on to the next service action. */
- no_more = setup ((void **) &fct, "getnetgrent_r", 0);
+ no_more = setup (&fct.ptr, "getnetgrent_r", 0);
while (! no_more)
{
- status = (*fct) (datap, buffer, buflen, &errno);
+ status = (*fct.f) (datap, buffer, buflen, &errno);
if (status == NSS_STATUS_RETURN)
{
@@ -262,7 +274,7 @@ internal_getnetgrent_r (char **hostp, ch
}
}
- no_more = __nss_next (&nip, "getnetgrent_r", (void **) &fct, status, 0);
+ no_more = __nss_next (&nip, "getnetgrent_r", &fct.ptr, status, 0);
}
if (status == NSS_STATUS_SUCCESS)
@@ -299,9 +311,21 @@ int
innetgr (const char *netgroup, const char *host, const char *user,
const char *domain)
{
- int (*setfct) (const char *, struct __netgrent *);
- void (*endfct) (struct __netgrent *);
- int (*getfct) (struct __netgrent *, char *, size_t, int *);
+ union
+ {
+ int (*f) (const char *, struct __netgrent *);
+ void *ptr;
+ } setfct;
+ union
+ {
+ void (*f) (struct __netgrent *);
+ void *ptr;
+ } endfct;
+ union
+ {
+ int (*f) (struct __netgrent *, char *, size_t, int *);
+ void *ptr;
+ } getfct;
struct name_list *known = NULL;
struct name_list *needed = NULL;
int result = 0;
@@ -315,7 +339,7 @@ innetgr (const char *netgroup, const cha
the work during one walk through the service list. */
while (1)
{
- no_more = setup ((void **) &setfct, "setnetgrent", 1);
+ no_more = setup (&setfct.ptr, "setnetgrent", 1);
while (! no_more)
{
enum nss_status status;
@@ -325,13 +349,13 @@ innetgr (const char *netgroup, const cha
__bzero (&entry, sizeof (entry));
/* Open netgroup. */
- status = (*setfct) (current_group, &entry);
+ status = (*setfct.f) (current_group, &entry);
if (status == NSS_STATUS_SUCCESS
- && __nss_lookup (&nip, "getnetgrent_r", (void **) &getfct) == 0)
+ && __nss_lookup (&nip, "getnetgrent_r", &getfct.ptr) == 0)
{
char buffer[1024];
- while ((*getfct) (&entry, buffer, sizeof buffer, &errno)
+ while ((*getfct.f) (&entry, buffer, sizeof buffer, &errno)
== NSS_STATUS_SUCCESS)
{
if (entry.type == group_val)
@@ -389,12 +413,12 @@ innetgr (const char *netgroup, const cha
}
/* Free all resources of the service. */
- if (__nss_lookup (&nip, "endnetgrent", (void **) &endfct) == 0)
- (*endfct) (&entry);
+ if (__nss_lookup (&nip, "endnetgrent", &endfct.ptr) == 0)
+ (*endfct.f) (&entry);
/* Look for the next service. */
no_more = __nss_next (&nip, "setnetgrent",
- (void **) &setfct, status, 0);
+ &setfct.ptr, status, 0);
}
if (result == 0 && needed != NULL)
============================================================
Index: sunrpc/netname.c
--- sunrpc/netname.c 6 Aug 2002 05:10:28 -0000 1.8
+++ sunrpc/netname.c 10 Nov 2002 11:05:04 -0000
@@ -147,32 +147,36 @@ netname2user (const char netname[MAXNETN
static service_user *startp;
static netname2user_function start_fct;
service_user *nip;
- netname2user_function fct;
+ union
+ {
+ netname2user_function f;
+ void *ptr;
+ } fct;
enum nss_status status = NSS_STATUS_UNAVAIL;
int no_more;
if (startp == NULL)
{
- no_more = __nss_publickey_lookup (&nip, "netname2user", (void **) &fct);
+ no_more = __nss_publickey_lookup (&nip, "netname2user", &fct.ptr);
if (no_more)
startp = (service_user *) - 1;
else
{
startp = nip;
- start_fct = fct;
+ start_fct = fct.f;
}
}
else
{
- fct = start_fct;
+ fct.f = start_fct;
no_more = (nip = startp) == (service_user *) - 1;
}
while (!no_more)
{
- status = (*fct) (netname, uidp, gidp, gidlenp, gidlist);
+ status = (*fct.f) (netname, uidp, gidp, gidlenp, gidlist);
- no_more = __nss_next (&nip, "netname2user", (void **) &fct, status, 0);
+ no_more = __nss_next (&nip, "netname2user", &fct.ptr, status, 0);
}
return status == NSS_STATUS_SUCCESS;
============================================================
Index: sunrpc/publickey.c
--- sunrpc/publickey.c 6 Aug 2002 01:23:20 -0000 1.9
+++ sunrpc/publickey.c 10 Nov 2002 11:05:04 -0000
@@ -42,32 +42,36 @@ getpublickey (const char *name, char *ke
static service_user *startp;
static public_function start_fct;
service_user *nip;
- public_function fct;
+ union
+ {
+ public_function f;
+ void *ptr;
+ } fct;
enum nss_status status = NSS_STATUS_UNAVAIL;
int no_more;
if (startp == NULL)
{
- no_more = __nss_publickey_lookup (&nip, "getpublickey", (void **) &fct);
+ no_more = __nss_publickey_lookup (&nip, "getpublickey", &fct.ptr);
if (no_more)
startp = (service_user *) -1;
else
{
startp = nip;
- start_fct = fct;
+ start_fct = fct.f;
}
}
else
{
- fct = start_fct;
+ fct.f = start_fct;
no_more = (nip = startp) == (service_user *) -1;
}
while (! no_more)
{
- status = (*fct) (name, key, &errno);
+ status = (*fct.f) (name, key, &errno);
- no_more = __nss_next (&nip, "getpublickey", (void **) &fct, status, 0);
+ no_more = __nss_next (&nip, "getpublickey", &fct.ptr, status, 0);
}
return status == NSS_STATUS_SUCCESS;
@@ -81,32 +85,36 @@ getsecretkey (const char *name, char *ke
static service_user *startp;
static secret_function start_fct;
service_user *nip;
- secret_function fct;
+ union
+ {
+ secret_function f;
+ void *ptr;
+ } fct;
enum nss_status status = NSS_STATUS_UNAVAIL;
int no_more;
if (startp == NULL)
{
- no_more = __nss_publickey_lookup (&nip, "getsecretkey", (void **) &fct);
+ no_more = __nss_publickey_lookup (&nip, "getsecretkey", &fct.ptr);
if (no_more)
startp = (service_user *) -1;
else
{
startp = nip;
- start_fct = fct;
+ start_fct = fct.f;
}
}
else
{
- fct = start_fct;
+ fct.f = start_fct;
no_more = (nip = startp) == (service_user *) -1;
}
while (! no_more)
{
- status = (*fct) (name, key, passwd, &errno);
+ status = (*fct.f) (name, key, passwd, &errno);
- no_more = __nss_next (&nip, "getsecretkey", (void **) &fct, status, 0);
+ no_more = __nss_next (&nip, "getsecretkey", &fct.ptr, status, 0);
}
return status == NSS_STATUS_SUCCESS;
--
Andreas Jaeger
SuSE Labs aj@suse.de
private aj@arthur.inka.de
http://www.suse.de/~aj
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2002-11-10 11:05 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-11-10 1:10 FYI: GCC warnings about strict-aliasing violation in glibc Andreas Jaeger
2002-11-10 2:18 ` Andreas Jaeger
2002-11-10 2:23 ` Ulrich Drepper
2002-11-10 3:05 ` Andreas Jaeger
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 read-only IMAP folder(s) and NNTP newsgroup(s).