Re: [B.A.T.M.A.N.] [RFC 08/23] batman-adv: OGMv2 - implement originators logic

Andrew Lunn
2014-02-11T17:22:12Z

> +static struct batadv_orig_node *
> +batadv_v_ogm_orig_get(struct batadv_priv *bat_priv, const uint8_t *addr)
> +{
> + struct batadv_orig_node *orig_node;
> + int hash_added;
> +
> + orig_node = batadv_orig_hash_find(bat_priv, addr);
> + if (orig_node)
> + return orig_node;
> +
> + orig_node = batadv_orig_node_new(bat_priv, addr);

Can this fail and return NULL?

> +
> + hash_added = batadv_hash_add(bat_priv->orig_hash, batadv_compare_orig,
> + batadv_choose_orig, orig_node,
> + &orig_node->hash_entry);
> + if (hash_added != 0) {
> + batadv_orig_node_free_ref(orig_node);
> + batadv_orig_node_free_ref(orig_node);

Looks odd. If it is correct, it should have a comment why it is
correct.

Andrew