batman-adv: Use "__attribute__" shortcut macros
PATCH 1/1 batman-adv: Use "__attribute__" shortcut macros
Linux 2.6.21 defines different macros for __attribute__ which are also used inside batman-adv. The next version of checkpatch.pl warns about the usage of __attribute__((packed))).
Linux 2.6.33 defines an extra macro __always_unused which is used to assist source code analyzers and can be used to removed the last existing __attribute__ inside the source code.
--- batman-adv/compat.h | 6 ++++++ batman-adv/main.h | 6 +++--- batman-adv/packet.h | 14 +++++++------- batman-adv/types.h | 4 ++-- 4 files changed, 18 insertions(+), 12 deletions(-)
batman-adv/compat.h +6 -0
@@ -264,4 +264,10 @@ int bat_seq_printf(struct seq_file *m, const char *f, ...);#endif /* < KERNEL_VERSION(2, 6, 29) */ +#if LINUX_VERSION_CODE <KERNEL_VERSION (2 ,6 ,33 ) + +#define __always_unused __attribute__((unused)) + +#endif /* < KERNEL_VERSION(2, 6, 33) */ +#endif /* _NET_BATMAN_ADV_COMPAT_H_ */
batman-adv/main.h +3 -3
@@ -153,9 +153,9 @@ int debug_log(struct bat_priv *bat_priv, char *fmt, ...); } \ while (0)#else /* !CONFIG_BATMAN_ADV_DEBUG */ -static inline void bat_dbg (char type __attribute__((unused)), -struct bat_priv *bat_priv __attribute__((unused)), -char *fmt __attribute__((unused)), ...) +static inline void bat_dbg (char type__always_unused , +struct bat_priv *bat_priv__always_unused , +char *fmt__always_unused , ...) { }#endif
batman-adv/packet.h +7 -7
@@ -63,7 +63,7 @@ struct batman_packet {uint8_t num_hna;uint8_t gw_flags;/* flags related to gateway class */ uint8_t align; -} __attribute__((packed)); +} __packed;#define BAT_PACKET_LEN sizeof(struct batman_packet)
@@ -76,7 +76,7 @@ struct icmp_packet {uint8_t orig[6 ];uint16_t seqno;uint8_t uid; -} __attribute__((packed)); +} __packed;#define BAT_RR_LEN 16
@@ -93,14 +93,14 @@ struct icmp_packet_rr {uint8_t uid;uint8_t rr_cur;uint8_t rr[BAT_RR_LEN ][ETH_ALEN ]; -} __attribute__((packed)); +} __packed;struct unicast_packet {uint8_t packet_type;uint8_t version;/* batman version field */ uint8_t dest[6 ];uint8_t ttl; -} __attribute__((packed)); +} __packed;struct unicast_frag_packet {uint8_t packet_type;
@@ -110,7 +110,7 @@ struct unicast_frag_packet {uint8_t flags;uint8_t orig[6 ];uint16_t seqno; -} __attribute__((packed)); +} __packed;struct bcast_packet {uint8_t packet_type;
@@ -118,7 +118,7 @@ struct bcast_packet {uint8_t orig[6 ];uint8_t ttl;uint32_t seqno; -} __attribute__((packed)); +} __packed;struct vis_packet {uint8_t packet_type;
@@ -131,6 +131,6 @@ struct vis_packet {* neighbors */ uint8_t target_orig[6 ];/* who should receive this packet */ uint8_t sender_orig[6]; /* who sent or rebroadcasted this packet */ -} __attribute__((packed)); +} __packed;#endif /* _NET_BATMAN_ADV_PACKET_H_ */
batman-adv/types.h +2 -2
@@ -249,13 +249,13 @@ struct vis_info {/* this packet might be part of the vis send queue. */ struct sk_buff *skb_packet;/* vis_info may follow here*/ -} __attribute__((packed)); +} __packed;struct vis_info_entry {uint8_t src[ETH_ALEN ];uint8_t dest[ETH_ALEN ];uint8_t quality;/* quality = 0 means HNA */ -} __attribute__((packed)); +} __packed;struct recvlist_node {struct list_head list;
Signature · 1 line
1.7.2.3
Marek Lindner
AppliedQuoted 7 lines · On Saturday 15 January 2011 10:56:24 Sven Eckelmann wrote:
Linux 2.6.21 defines different macros for
__attribute__which are also used inside batman-adv. The next version of checkpatch.pl warns about the usage of __attribute__((packed))).Linux 2.6.33 defines an extra macro
__always_unusedwhich is used to assist source code analyzers and can be used to removed the last existing__attribute__inside the source code.
Applied in revision 1901.
Thanks,
Marek