From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26286 invoked by alias); 10 Nov 2002 11:05:57 -0000 Mailing-List: contact libc-hacker-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-hacker-owner@sources.redhat.com Received: (qmail 26269 invoked from network); 10 Nov 2002 11:05:55 -0000 Received: from unknown (HELO Cantor.suse.de) (213.95.15.193) by sources.redhat.com with SMTP; 10 Nov 2002 11:05:55 -0000 Received: from Hermes.suse.de (Charybdis.suse.de [213.95.15.201]) by Cantor.suse.de (Postfix) with ESMTP id 32FDD14748; Sun, 10 Nov 2002 12:05:55 +0100 (MET) Received: from aj by arthur.inka.de with local (Exim 3.34 #1) id 18ApuW-0006N0-00; Sun, 10 Nov 2002 12:05:48 +0100 Mail-Copies-To: never To: Ulrich Drepper Cc: GNU libc hacker Subject: Re: FYI: GCC warnings about strict-aliasing violation in glibc References: <3DCE338E.50306@redhat.com> From: Andreas Jaeger Date: Sun, 10 Nov 2002 03:05:00 -0000 In-Reply-To: <3DCE338E.50306@redhat.com> (Ulrich Drepper's message of "Sun, 10 Nov 2002 02:23:10 -0800") Message-ID: User-Agent: Gnus/5.090008 (Oort Gnus v0.08) XEmacs/21.4 (Artificial Intelligence, i386-suse-linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-SW-Source: 2002-11/txt/msg00048.txt.bz2 Ulrich Drepper 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 * 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