Skip to content

Commit

Permalink
Remove unnecessary cast to char* in YADECAP_METADATA
Browse files Browse the repository at this point in the history
Apart from it being unnecessary, it could even result in some bad behavior,
as GCC always assumes aligned pointer accesses and cast from `char *`
to `dataplane::metadata *` increases required alignment from 1 to 4
  • Loading branch information
ol-imorozko authored and GeorgyKirichenko committed May 3, 2024
1 parent 1db666c commit 02c73b5
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion dataplane/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
#define YANET_MEMORY_BARRIER_COMPILE __asm__ __volatile__("" :: \
: "memory")

#define YADECAP_METADATA(mbuf) ((dataplane::metadata*)((char*)(mbuf)->buf_addr))
#define YADECAP_METADATA(mbuf) ((dataplane::metadata*)((mbuf)->buf_addr))

#define YADECAP_ETHER_TYPE_MPLS (0x8847)
#define YADECAP_MPLS_HEADER_SIZE 4
Expand Down

0 comments on commit 02c73b5

Please sign in to comment.