batman-adv: use htons when possible
When comparing a network ordered value with a constant, it is better to convert the constant at compile time by means of htons() instead of converting the value at runtime using ntohs(). This refactoring may slightly improve the code performance. Moreover substitute __constant_htons() with htons() since the latter increase readability and it is smart enough to be as efficient as the former Signed-off-by: Antonio Quartulli <ordex@autistici.org> Signed-off-by: Marek Lindner <lindner_marek@yahoo.de> Acked-by: Simon Wunderlich <siwu@hrz.tu-chemnitz.de>
This commit is contained in:

committed by
Antonio Quartulli

parent
ee75ed8887
commit
293e93385e
@@ -145,7 +145,7 @@ static int batadv_interface_tx(struct sk_buff *skb,
|
||||
struct batadv_hard_iface *primary_if = NULL;
|
||||
struct batadv_bcast_packet *bcast_packet;
|
||||
struct vlan_ethhdr *vhdr;
|
||||
__be16 ethertype = __constant_htons(ETH_P_BATMAN);
|
||||
__be16 ethertype = htons(ETH_P_BATMAN);
|
||||
static const uint8_t stp_addr[ETH_ALEN] = {0x01, 0x80, 0xC2, 0x00,
|
||||
0x00, 0x00};
|
||||
static const uint8_t ectp_addr[ETH_ALEN] = {0xCF, 0x00, 0x00, 0x00,
|
||||
@@ -312,7 +312,7 @@ void batadv_interface_rx(struct net_device *soft_iface,
|
||||
struct vlan_ethhdr *vhdr;
|
||||
struct batadv_header *batadv_header = (struct batadv_header *)skb->data;
|
||||
unsigned short vid __maybe_unused = BATADV_NO_FLAGS;
|
||||
__be16 ethertype = __constant_htons(ETH_P_BATMAN);
|
||||
__be16 ethertype = htons(ETH_P_BATMAN);
|
||||
bool is_bcast;
|
||||
|
||||
is_bcast = (batadv_header->packet_type == BATADV_BCAST);
|
||||
|
Reference in New Issue
Block a user