提交 8bbb7cb2 编写于 作者: M Markus Elfring 提交者: Antonio Quartulli

batman-adv: Less checks in batadv_tvlv_unicast_send()

* Let us return directly if a call of the batadv_orig_hash_find() function
  returned a null pointer.

* Omit the initialisation for the variable "skb" at the beginning.

* Replace an assignment by a call of the kfree_skb() function
  and delete the affected variable "ret" then.
Signed-off-by: NMarkus Elfring <elfring@users.sourceforge.net>
Signed-off-by: NMarek Lindner <mareklindner@neomailbox.ch>
Signed-off-by: NAntonio Quartulli <a@unstable.cc>
上级 c799443e
...@@ -1143,15 +1143,14 @@ void batadv_tvlv_unicast_send(struct batadv_priv *bat_priv, u8 *src, ...@@ -1143,15 +1143,14 @@ void batadv_tvlv_unicast_send(struct batadv_priv *bat_priv, u8 *src,
struct batadv_unicast_tvlv_packet *unicast_tvlv_packet; struct batadv_unicast_tvlv_packet *unicast_tvlv_packet;
struct batadv_tvlv_hdr *tvlv_hdr; struct batadv_tvlv_hdr *tvlv_hdr;
struct batadv_orig_node *orig_node; struct batadv_orig_node *orig_node;
struct sk_buff *skb = NULL; struct sk_buff *skb;
unsigned char *tvlv_buff; unsigned char *tvlv_buff;
unsigned int tvlv_len; unsigned int tvlv_len;
ssize_t hdr_len = sizeof(*unicast_tvlv_packet); ssize_t hdr_len = sizeof(*unicast_tvlv_packet);
bool ret = false;
orig_node = batadv_orig_hash_find(bat_priv, dst); orig_node = batadv_orig_hash_find(bat_priv, dst);
if (!orig_node) if (!orig_node)
goto out; return;
tvlv_len = sizeof(*tvlv_hdr) + tvlv_value_len; tvlv_len = sizeof(*tvlv_hdr) + tvlv_value_len;
...@@ -1180,14 +1179,10 @@ void batadv_tvlv_unicast_send(struct batadv_priv *bat_priv, u8 *src, ...@@ -1180,14 +1179,10 @@ void batadv_tvlv_unicast_send(struct batadv_priv *bat_priv, u8 *src,
tvlv_buff += sizeof(*tvlv_hdr); tvlv_buff += sizeof(*tvlv_hdr);
memcpy(tvlv_buff, tvlv_value, tvlv_value_len); memcpy(tvlv_buff, tvlv_value, tvlv_value_len);
if (batadv_send_skb_to_orig(skb, orig_node, NULL) != NET_XMIT_DROP) if (batadv_send_skb_to_orig(skb, orig_node, NULL) == NET_XMIT_DROP)
ret = true;
out:
if (!ret)
kfree_skb(skb); kfree_skb(skb);
if (orig_node) out:
batadv_orig_node_free_ref(orig_node); batadv_orig_node_free_ref(orig_node);
} }
/** /**
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册