From: Ulrich Drepper <drepper@redhat.com>
To: Andreas Jaeger <aj@suse.de>
Cc: GNU libc hacker <libc-hacker@sources.redhat.com>
Subject: Re: Get rid of some type-punning warnings
Date: Sat, 28 Dec 2002 13:06:00 -0000 [thread overview]
Message-ID: <3E0E1233.8080900@redhat.com> (raw)
In-Reply-To: <u8of76jgkd.fsf@gromit.moeb>
Andreas Jaeger wrote:
*buffer, size_t buflen, int *errnop,
> int *h_errnop)
> {
> - querybuf *host_buffer, *orig_host_buffer;
> + union
> + {
> + querybuf *buf;
> + void *ptr;
> + } host_buffer;
> + querybuf *orig_host_buffer;
Why do you use void* for ptr and not u_char*?
> - n = __libc_res_nsearch (&_res, name, C_IN, type, host_buffer->buf,
> - 1024, (u_char **) &host_buffer);
> + n = __libc_res_nsearch (&_res, name, C_IN, type, host_buffer.buf->buf,
> + 1024, (u_char **) &host_buffer.ptr);
In this situation you could simlpy use &host_buffer.ptr.
>
> ============================================================
> Index: resolv/nss_dns/dns-network.c
> --- resolv/nss_dns/dns-network.c 19 Nov 2002 06:40:16 -0000 1.17
> +++ resolv/nss_dns/dns-network.c 28 Dec 2002 15:35:11 -0000
> @@ -110,7 +110,12 @@ _nss_dns_getnetbyname_r (const char *nam
> int *herrnop)
> {
> /* Return entry for network with NAME. */
> - querybuf *net_buffer, *orig_net_buffer;
> + union
> + {
> + querybuf *buf;
> + void *ptr;
> + } net_buffer;
> + querybuf *orig_net_buffer;
> int anslen;
> char *qbuf;
> enum nss_status status;
> @@ -120,25 +125,25 @@ _nss_dns_getnetbyname_r (const char *nam
>
> qbuf = strdupa (name);
>
> - net_buffer = orig_net_buffer = (querybuf *) alloca (1024);
> + net_buffer.buf = orig_net_buffer = (querybuf *) alloca (1024);
>
> - anslen = __libc_res_nsearch (&_res, qbuf, C_IN, T_PTR, net_buffer->buf,
> - 1024, (u_char **) &net_buffer);
> + anslen = __libc_res_nsearch (&_res, qbuf, C_IN, T_PTR, net_buffer.buf->buf,
> + 1024, (u_char **) &net_buffer.buf);
And here you use &net_buffer.buf? I thought this is what you want to avoid?
Please check the patch again. Make sure that if uchar* can be used it
is used and remove all the casts.
--
--------------. ,-. 444 Castro Street
Ulrich Drepper \ ,-----------------' \ Mountain View, CA 94041 USA
Red Hat `--' drepper at redhat.com `---------------------------
next prev parent reply other threads:[~2002-12-28 21:06 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-12-28 7:43 Andreas Jaeger
2002-12-28 13:06 ` Ulrich Drepper [this message]
2002-12-30 5:38 ` Andreas Jaeger
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=3E0E1233.8080900@redhat.com \
--to=drepper@redhat.com \
--cc=aj@suse.de \
--cc=libc-hacker@sources.redhat.com \
/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 read-only IMAP folder(s) and NNTP newsgroup(s).