Merge pull request #17157 from maribu/sys/net/gnrc

sys/net/gnrc: fix compilation with -Wcast-align
This commit is contained in:
Martine Lenders 2021-12-01 09:49:21 +01:00 committed by GitHub
commit 2cf0fca4e2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 6 deletions

View File

@ -22,7 +22,9 @@
#include <stdint.h>
#include <stdbool.h>
#include <stdalign.h>
#include "architecture.h"
#include "net/gnrc/netif/hdr.h"
#include "net/gnrc/pkt.h"
#ifdef MODULE_GNRC_SIXLOWPAN_FRAG_SFR
@ -99,13 +101,14 @@ typedef struct {
* @brief The reassembled packet in the packet buffer
*/
gnrc_pktsnip_t *pkt;
#if IS_USED(MODULE_GNRC_SIXLOWPAN_FRAG_SFR)
#if IS_USED(MODULE_GNRC_SIXLOWPAN_FRAG_SFR) || defined(DOXYGEN)
/**
* @brief Bitmap for received fragments
*
* @note Only available with module `gnrc_sixlowpan_frag_sfr` compiled
* in.
*/
alignas(gnrc_sixlowpan_frag_sfr_bitmap_t)
BITFIELD(received, SIXLOWPAN_SFR_ACK_BITMAP_SIZE);
int8_t offset_diff; /**< offset change due to
* recompression */

View File

@ -13,6 +13,8 @@
* @author Martine Lenders <m.lenders@fu-berlin.de>
*/
#include <stddef.h>
#include "irq.h"
#include "kernel_defines.h"
#ifdef MODULE_GNRC_IPV6_NIB
@ -106,7 +108,7 @@ static gnrc_sixlowpan_frag_sfr_stats_t _stats;
*
* @return A gnrc_sixlowpan_frag_sfr_bitmap_t.
*/
static inline gnrc_sixlowpan_frag_sfr_bitmap_t *_to_bitmap(uint8_t *bitmap);
static inline gnrc_sixlowpan_frag_sfr_bitmap_t *_get_bitmap(gnrc_sixlowpan_frag_rb_t *frag_rb);
/**
* @brief Checks if fragment represented by a fragment descriptor requested an
@ -927,7 +929,7 @@ static void _try_reassembly(gnrc_netif_hdr_t *netif_hdr,
entry->entry.rb->received[3],
entry->entry.base->current_size,
entry->entry.base->datagram_size);
bitmap = _to_bitmap(entry->entry.rb->received);
bitmap = _get_bitmap(entry->entry.rb);
if (IS_USED(MODULE_GNRC_SIXLOWPAN_FRAG_SFR_STATS)) {
_stats.acks.partly++;
}
@ -1209,9 +1211,14 @@ static void _check_failed_frags(sixlowpan_sfr_ack_t *ack,
/* ====== INTERNAL FUNCTIONS USED BY PUBLIC FUNCTIONS ======
* ====== AND TO MANIPULATE INTERNAL DATA STRUCTURES ====== */
static inline gnrc_sixlowpan_frag_sfr_bitmap_t *_to_bitmap(uint8_t *bitmap)
static inline gnrc_sixlowpan_frag_sfr_bitmap_t *_get_bitmap(gnrc_sixlowpan_frag_rb_t *frag_rb)
{
return (gnrc_sixlowpan_frag_sfr_bitmap_t *)bitmap;
DECLARE_CONSTANT(is_aligned,
HAS_ALIGNMENT_OF(offsetof(gnrc_sixlowpan_frag_rb_t, received),
alignof(gnrc_sixlowpan_frag_sfr_bitmap_t)))
static_assert(is_aligned,
"gnrc_sixlowpan_frag_rb_t::received must be suitably aligned");
return (gnrc_sixlowpan_frag_sfr_bitmap_t *)(uintptr_t)frag_rb->received;
}
static inline bool _frag_ack_req(_frag_desc_t *frag)
@ -1394,7 +1401,7 @@ static int _resend_frag(clist_node_t *node, void *fbuf_ptr)
cur_frag_size = _find_offset_and_copy_rest(data, &pkt, frag_size,
frag_desc->offset);
/* copy remaining packet snips */
cur_frag_size = _copy_pkt_to_frag(data, pkt, frag_size, cur_frag_size);
_copy_pkt_to_frag(data, pkt, frag_size, cur_frag_size);
DEBUG("6lo sfr: resending fragment (retry: %u, tag: %u, X: %i, seq: %u, "
"frag_size: %u, %s: %u)\n", frag_desc->retries,
hdr->base.tag, sixlowpan_sfr_rfrag_ack_req(hdr),