diff options
author | Andreas Jaeger <aj@suse.de> | 2002-11-10 11:06:36 +0000 |
---|---|---|
committer | Andreas Jaeger <aj@suse.de> | 2002-11-10 11:06:36 +0000 |
commit | fb776f3ef3b2b7eaf7e92305b8b2dc480f31f3ff (patch) | |
tree | b6d3b7b6350601fbb8f6cbf8f820d25c0ab59cdb /inet | |
parent | 55c303acb873e478540042612f1028139454d4a4 (diff) |
* 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.
Diffstat (limited to 'inet')
-rw-r--r-- | inet/ether_hton.c | 16 | ||||
-rw-r--r-- | inet/ether_ntoh.c | 16 | ||||
-rw-r--r-- | inet/getnetgrent_r.c | 68 |
3 files changed, 66 insertions, 34 deletions
diff --git a/inet/ether_hton.c b/inet/ether_hton.c index 70dc2fe071..64f5ab5d36 100644 --- a/inet/ether_hton.c +++ b/inet/ether_hton.c @@ -39,25 +39,29 @@ ether_hostton (const char *hostname, struct ether_addr *addr) 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, struct ether_addr *addr) { 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) diff --git a/inet/ether_ntoh.c b/inet/ether_ntoh.c index ecddc9d8ac..ad4165cb3e 100644 --- a/inet/ether_ntoh.c +++ b/inet/ether_ntoh.c @@ -40,25 +40,29 @@ ether_ntohost (char *hostname, const struct ether_addr *addr) 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 struct ether_addr *addr) { 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) diff --git a/inet/getnetgrent_r.c b/inet/getnetgrent_r.c index a0fb6f42a1..dee90ad389 100644 --- a/inet/getnetgrent_r.c +++ b/inet/getnetgrent_r.c @@ -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, char **userp, char **domainp, 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, char **userp, char **domainp, /* 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, char **userp, char **domainp, } } - 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 char *host, const char *user, 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 char *host, const char *user, __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 char *host, const char *user, } /* 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) |