[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 03/31] slirp: Don't mark struct ipq or struct ipasfra
From: |
Samuel Thibault |
Subject: |
[Qemu-devel] [PULL 03/31] slirp: Don't mark struct ipq or struct ipasfrag as packed |
Date: |
Sun, 27 Jan 2019 13:04:58 +0100 |
From: Peter Maydell <address@hidden>
There is no reason to mark the struct ipq and struct ipasfrag as
packed: they are naturally aligned anyway, and are not representing
any on-the-wire packet format. Indeed they vary in size depending on
the size of pointers on the host system, because the 'struct qlink'
members include 'void *' fields.
Dropping the 'packed' annotation fixes clang -Waddress-of-packed-member
warnings and probably lets the compiler generate better code too.
The only thing we do care about in the layout of the struct is
that the frag_link matches up with the ipf_link of the struct
ipasfrag, as documented in the comment on that struct; assert
at build time that this is the case.
Signed-off-by: Peter Maydell <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
Signed-off-by: Samuel Thibault <address@hidden>
---
slirp/ip.h | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/slirp/ip.h b/slirp/ip.h
index 243b6c8b24..20614f3b53 100644
--- a/slirp/ip.h
+++ b/slirp/ip.h
@@ -217,7 +217,7 @@ struct ipq {
uint8_t ipq_p; /* protocol of this fragment */
uint16_t ipq_id; /* sequence id for reassembly */
struct in_addr ipq_src,ipq_dst;
-} QEMU_PACKED;
+};
/*
* Ip header, when holding a fragment.
@@ -227,7 +227,10 @@ struct ipq {
struct ipasfrag {
struct qlink ipf_link;
struct ip ipf_ip;
-} QEMU_PACKED;
+};
+
+QEMU_BUILD_BUG_ON(offsetof(struct ipq, frag_link) !=
+ offsetof(struct ipasfrag, ipf_link));
#define ipf_off ipf_ip.ip_off
#define ipf_tos ipf_ip.ip_tos
--
2.20.1
- [Qemu-devel] [PULL 01/31] slirp: Avoid unaligned 16bit memory access, (continued)
- [Qemu-devel] [PULL 01/31] slirp: Avoid unaligned 16bit memory access, Samuel Thibault, 2019/01/27
- [Qemu-devel] [PULL 06/31] net/slirp: free forwarding rules on cleanup, Samuel Thibault, 2019/01/27
- [Qemu-devel] [PULL 02/31] slirp: Avoid marking naturally packed structs as QEMU_PACKED, Samuel Thibault, 2019/01/27
- [Qemu-devel] [PULL 07/31] net/slirp: fix leaks on forwarding rule registration error, Samuel Thibault, 2019/01/27
- [Qemu-devel] [PULL 04/31] slirp: generalize guestfwd with a callback based approach, Samuel Thibault, 2019/01/27
- [Qemu-devel] [PULL 19/31] slirp: remove qemu timer.h dependency, Samuel Thibault, 2019/01/27
- [Qemu-devel] [PULL 08/31] slirp: add callbacks for timer, Samuel Thibault, 2019/01/27
- [Qemu-devel] [PULL 14/31] slirp: replace qemu_notify_event() with a callback, Samuel Thibault, 2019/01/27
- [Qemu-devel] [PULL 23/31] slirp: replace QEMU_BUILD_BUG_ON with G_STATIC_ASSERT, Samuel Thibault, 2019/01/27
- [Qemu-devel] [PULL 09/31] slirp: replace trace functions with DEBUG calls, Samuel Thibault, 2019/01/27
- [Qemu-devel] [PULL 03/31] slirp: Don't mark struct ipq or struct ipasfrag as packed,
Samuel Thibault <=
- [Qemu-devel] [PULL 16/31] slirp: do not include qemu headers in libslirp.h public API header, Samuel Thibault, 2019/01/27
- [Qemu-devel] [PULL 13/31] slirp: add unregister_poll_fd() callback, Samuel Thibault, 2019/01/27
- [Qemu-devel] [PULL 28/31] slirp: remove slirp_instances list, Samuel Thibault, 2019/01/27
- [Qemu-devel] [PULL 10/31] slirp: replace QEMU_PACKED with SLIRP_PACKED, Samuel Thibault, 2019/01/27
- [Qemu-devel] [PULL 12/31] slirp: replace qemu_set_nonblock(), Samuel Thibault, 2019/01/27
- [Qemu-devel] [PULL 17/31] slirp: improve windows headers inclusion, Samuel Thibault, 2019/01/27
- [Qemu-devel] [PULL 15/31] slirp: move QEMU state saving to a separate unit, Samuel Thibault, 2019/01/27
- [Qemu-devel] [PULL 18/31] slirp: add slirp own version of pstrcpy, Samuel Thibault, 2019/01/27
- [Qemu-devel] [PULL 21/31] slirp: replace net/eth.h inclusion with own defines, Samuel Thibault, 2019/01/27
- [Qemu-devel] [PULL 11/31] slirp: replace most qemu socket utilities with slirp own version, Samuel Thibault, 2019/01/27