From: Jakub Jelinek <jakub@redhat.com>
To: Ulrich Drepper <drepper@redhat.com>
Cc: Glibc hackers <libc-hacker@sources.redhat.com>
Subject: [PATCH] Fix BZ#5070
Date: Wed, 03 Oct 2007 07:49:00 -0000 [thread overview]
Message-ID: <20071003075130.GB2896@sunsite.mff.cuni.cz> (raw)
Hi!
This patch should IMHO cure the weirdo struct layout problem on arm
while not pessimizing code on sane architectures (on x86_64-linux
the routine with this patch has minor differences in insn scheduling,
but it is the same size and same instructions, just reordered and it is
unclear what is more efficient if not equivalent).
On arm at least with cross compiler distilled testcase also passes
compile time assertion made from the assert and the memset looks good as
well.
2007-10-03 Jakub Jelinek <jakub@redhat.com>
[BZ #5070]
* sysdeps/unix/sysv/linux/check_pf.c (make_request): Remove
pad array from req, instead use offsetof and sizeof to clear
padding.
--- libc/sysdeps/unix/sysv/linux/check_pf.c.jj 2007-09-02 19:09:33.000000000 +0200
+++ libc/sysdeps/unix/sysv/linux/check_pf.c 2007-10-03 09:26:18.000000000 +0200
@@ -54,10 +54,6 @@ make_request (int fd, pid_t pid, bool *s
{
struct nlmsghdr nlh;
struct rtgenmsg g;
- /* struct rtgenmsg consists of a single byte. This means there
- are three bytes of padding included in the REQ definition.
- We make them explicit here. */
- char pad[3];
} req;
struct sockaddr_nl nladdr;
@@ -68,8 +64,11 @@ make_request (int fd, pid_t pid, bool *s
req.nlh.nlmsg_seq = time (NULL);
req.g.rtgen_family = AF_UNSPEC;
- assert (sizeof (req) - offsetof (struct req, pad) == 3);
- memset (req.pad, '\0', sizeof (req.pad));
+ assert (sizeof (req) - offsetof (struct req, g)
+ - sizeof (req.g.rtgen_family) == 3);
+ memset (&req.g.rtgen_family + 1, '\0',
+ sizeof (req) - offsetof (struct req, g)
+ - sizeof (req.g.rtgen_family));
memset (&nladdr, '\0', sizeof (nladdr));
nladdr.nl_family = AF_NETLINK;
Jakub
reply other threads:[~2007-10-03 7:49 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20071003075130.GB2896@sunsite.mff.cuni.cz \
--to=jakub@redhat.com \
--cc=drepper@redhat.com \
--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).