The following commit has been merged in the next branch: commit d420904fe4e0fa376409f2c78975c4a2f1c97041 Author: Marek Lindner lindner_marek@yahoo.de Date: Mon Dec 13 00:01:54 2010 +0000
batman-adv: adjust NULL pointer check style
Signed-off-by: Marek Lindner lindner_marek@yahoo.de Signed-off-by: Sven Eckelmann sven@narfation.org
diff --git a/aggregation.c b/aggregation.c index 0c92e3b..3850a3e 100644 --- a/aggregation.c +++ b/aggregation.c @@ -221,7 +221,7 @@ void add_bat_packet_to_list(struct bat_priv *bat_priv,
/* nothing to aggregate with - either aggregation disabled or no * suitable aggregation packet found */ - if (forw_packet_aggr == NULL) { + if (!forw_packet_aggr) { /* the following section can run without the lock */ spin_unlock_bh(&bat_priv->forw_bat_list_lock);
diff --git a/hash.c b/hash.c index fec9bbd..26e623e 100644 --- a/hash.c +++ b/hash.c @@ -45,13 +45,13 @@ struct hashtable_t *hash_new(int size)
hash = kmalloc(sizeof(struct hashtable_t) , GFP_ATOMIC);
- if (hash == NULL) + if (!hash) return NULL;
hash->size = size; hash->table = kmalloc(sizeof(struct element_t *) * size, GFP_ATOMIC);
- if (hash->table == NULL) { + if (!hash->table) { kfree(hash); return NULL; } diff --git a/hash.h b/hash.h index 0801f9c..09216ad 100644 --- a/hash.h +++ b/hash.h @@ -73,7 +73,7 @@ static inline void hash_delete(struct hashtable_t *hash,
hlist_for_each_safe(walk, safe, head) { bucket = hlist_entry(walk, struct element_t, hlist); - if (free_cb != NULL) + if (free_cb) free_cb(bucket->data, arg);
hlist_del(walk); @@ -109,7 +109,7 @@ static inline int hash_add(struct hashtable_t *hash, /* no duplicate found in list, add new element */ bucket = kmalloc(sizeof(struct element_t), GFP_ATOMIC);
- if (bucket == NULL) + if (!bucket) return -1;
bucket->data = data; diff --git a/originator.c b/originator.c index 93ac59b..6b7fb6b 100644 --- a/originator.c +++ b/originator.c @@ -218,7 +218,7 @@ static bool purge_orig_neighbors(struct bat_priv *bat_priv, list_del(list_pos); kfree(neigh_node); } else { - if ((*best_neigh_node == NULL) || + if ((!*best_neigh_node) || (neigh_node->tq_avg > (*best_neigh_node)->tq_avg)) *best_neigh_node = neigh_node; } diff --git a/routing.c b/routing.c index cd2d4d8..8828edd 100644 --- a/routing.c +++ b/routing.c @@ -79,7 +79,7 @@ static void update_HNA(struct bat_priv *bat_priv, struct orig_node *orig_node, hna_global_del_orig(bat_priv, orig_node, "originator changed hna");
- if ((hna_buff_len > 0) && (hna_buff != NULL)) + if ((hna_buff_len > 0) && (hna_buff)) hna_global_add_orig(bat_priv, orig_node, hna_buff, hna_buff_len); } @@ -91,7 +91,7 @@ static void update_route(struct bat_priv *bat_priv, unsigned char *hna_buff, int hna_buff_len) { /* route deleted */ - if ((orig_node->router != NULL) && (neigh_node == NULL)) { + if ((orig_node->router) && (!neigh_node)) {
bat_dbg(DBG_ROUTES, bat_priv, "Deleting route towards: %pM\n", orig_node->orig); @@ -99,7 +99,7 @@ static void update_route(struct bat_priv *bat_priv, "originator timed out");
/* route added */ - } else if ((orig_node->router == NULL) && (neigh_node != NULL)) { + } else if ((!orig_node->router) && (neigh_node)) {
bat_dbg(DBG_ROUTES, bat_priv, "Adding route towards: %pM (via %pM)\n", @@ -125,7 +125,7 @@ void update_routes(struct bat_priv *bat_priv, struct orig_node *orig_node, int hna_buff_len) {
- if (orig_node == NULL) + if (!orig_node) return;
if (orig_node->router != neigh_node) @@ -391,7 +391,7 @@ static char count_real_packets(struct ethhdr *ethhdr, int set_mark;
orig_node = get_orig_node(bat_priv, batman_packet->orig); - if (orig_node == NULL) + if (!orig_node) return 0;
seq_diff = batman_packet->seqno - orig_node->last_real_seqno; @@ -503,7 +503,7 @@ void update_bonding_candidates(struct bat_priv *bat_priv,
/* we only care if the other candidate is even * considered as candidate. */ - if (tmp_neigh_node2->next_bond_candidate == NULL) + if (!tmp_neigh_node2->next_bond_candidate) continue;
@@ -520,7 +520,7 @@ void update_bonding_candidates(struct bat_priv *bat_priv, if (interference_candidate) continue;
- if (first_candidate == NULL) { + if (!first_candidate) { first_candidate = tmp_neigh_node; tmp_neigh_node->next_bond_candidate = first_candidate; } else @@ -670,7 +670,7 @@ void receive_bat_packet(struct ethhdr *ethhdr, }
orig_node = get_orig_node(bat_priv, batman_packet->orig); - if (orig_node == NULL) + if (!orig_node) return;
is_duplicate = count_real_packets(ethhdr, batman_packet, if_incoming); @@ -707,13 +707,12 @@ void receive_bat_packet(struct ethhdr *ethhdr, orig_neigh_node = (is_single_hop_neigh ? orig_node : get_orig_node(bat_priv, ethhdr->h_source)); - if (orig_neigh_node == NULL) + if (!orig_neigh_node) return;
/* drop packet if sender is not a direct neighbor and if we * don't route towards it */ - if (!is_single_hop_neigh && - (orig_neigh_node->router == NULL)) { + if (!is_single_hop_neigh && (!orig_neigh_node->router)) { bat_dbg(DBG_BATMAN, bat_priv, "Drop packet: OGM via unknown neighbor!\n"); return; @@ -836,8 +835,7 @@ static int recv_my_icmp_packet(struct bat_priv *bat_priv, icmp_packet->orig)); ret = NET_RX_DROP;
- if ((orig_node != NULL) && - (orig_node->router != NULL)) { + if ((orig_node) && (orig_node->router)) {
/* don't lock while sending the packets ... we therefore * copy the required data before sending */ @@ -898,8 +896,7 @@ static int recv_icmp_ttl_exceeded(struct bat_priv *bat_priv, icmp_packet->orig)); ret = NET_RX_DROP;
- if ((orig_node != NULL) && - (orig_node->router != NULL)) { + if ((orig_node) && (orig_node->router)) {
/* don't lock while sending the packets ... we therefore * copy the required data before sending */ @@ -991,8 +988,7 @@ int recv_icmp_packet(struct sk_buff *skb, struct batman_if *recv_if) hash_find(bat_priv->orig_hash, compare_orig, choose_orig, icmp_packet->dst));
- if ((orig_node != NULL) && - (orig_node->router != NULL)) { + if ((orig_node) && (orig_node->router)) {
/* don't lock while sending the packets ... we therefore * copy the required data before sending */ @@ -1315,7 +1311,7 @@ int recv_bcast_packet(struct sk_buff *skb, struct batman_if *recv_if) hash_find(bat_priv->orig_hash, compare_orig, choose_orig, bcast_packet->orig));
- if (orig_node == NULL) { + if (!orig_node) { spin_unlock_bh(&bat_priv->orig_hash_lock); return NET_RX_DROP; } diff --git a/vis.c b/vis.c index d7f5b6b..cd4c423 100644 --- a/vis.c +++ b/vis.c @@ -384,7 +384,7 @@ static struct vis_info *add_packet(struct bat_priv *bat_priv, &search_elem); kfree_skb(search_elem.skb_packet);
- if (old_info != NULL) { + if (old_info) { old_packet = (struct vis_packet *)old_info->skb_packet->data; if (!seq_after(ntohl(vis_packet->seqno), ntohl(old_packet->seqno))) {