Commit 47c94655c3d8086d92825760e1f1d9b12a5976e4

Authored by Antonio Quartulli
1 parent 7c1fd91da5

batman-adv: refactor code to simplify long lines

Signed-off-by: Antonio Quartulli <ordex@autistici.org>

Showing 1 changed file with 30 additions and 32 deletions Side-by-side Diff

net/batman-adv/translation-table.c
... ... @@ -242,86 +242,84 @@
242 242 int ifindex)
243 243 {
244 244 struct batadv_priv *bat_priv = netdev_priv(soft_iface);
245   - struct batadv_tt_local_entry *tt_local_entry = NULL;
246   - struct batadv_tt_global_entry *tt_global_entry = NULL;
  245 + struct batadv_tt_local_entry *tt_local = NULL;
  246 + struct batadv_tt_global_entry *tt_global = NULL;
247 247 struct hlist_head *head;
248 248 struct hlist_node *node;
249 249 struct batadv_tt_orig_list_entry *orig_entry;
250 250 int hash_added;
251 251  
252   - tt_local_entry = batadv_tt_local_hash_find(bat_priv, addr);
  252 + tt_local = batadv_tt_local_hash_find(bat_priv, addr);
253 253  
254   - if (tt_local_entry) {
255   - tt_local_entry->last_seen = jiffies;
  254 + if (tt_local) {
  255 + tt_local->last_seen = jiffies;
256 256 /* possibly unset the BATADV_TT_CLIENT_PENDING flag */
257   - tt_local_entry->common.flags &= ~BATADV_TT_CLIENT_PENDING;
  257 + tt_local->common.flags &= ~BATADV_TT_CLIENT_PENDING;
258 258 goto out;
259 259 }
260 260  
261   - tt_local_entry = kmalloc(sizeof(*tt_local_entry), GFP_ATOMIC);
262   - if (!tt_local_entry)
  261 + tt_local = kmalloc(sizeof(*tt_local), GFP_ATOMIC);
  262 + if (!tt_local)
263 263 goto out;
264 264  
265 265 batadv_dbg(BATADV_DBG_TT, bat_priv,
266 266 "Creating new local tt entry: %pM (ttvn: %d)\n", addr,
267 267 (uint8_t)atomic_read(&bat_priv->tt.vn));
268 268  
269   - memcpy(tt_local_entry->common.addr, addr, ETH_ALEN);
270   - tt_local_entry->common.flags = BATADV_NO_FLAGS;
  269 + memcpy(tt_local->common.addr, addr, ETH_ALEN);
  270 + tt_local->common.flags = BATADV_NO_FLAGS;
271 271 if (batadv_is_wifi_iface(ifindex))
272   - tt_local_entry->common.flags |= BATADV_TT_CLIENT_WIFI;
273   - atomic_set(&tt_local_entry->common.refcount, 2);
274   - tt_local_entry->last_seen = jiffies;
275   - tt_local_entry->common.added_at = tt_local_entry->last_seen;
  272 + tt_local->common.flags |= BATADV_TT_CLIENT_WIFI;
  273 + atomic_set(&tt_local->common.refcount, 2);
  274 + tt_local->last_seen = jiffies;
  275 + tt_local->common.added_at = tt_local->last_seen;
276 276  
277 277 /* the batman interface mac address should never be purged */
278 278 if (batadv_compare_eth(addr, soft_iface->dev_addr))
279   - tt_local_entry->common.flags |= BATADV_TT_CLIENT_NOPURGE;
  279 + tt_local->common.flags |= BATADV_TT_CLIENT_NOPURGE;
280 280  
281 281 /* The local entry has to be marked as NEW to avoid to send it in
282 282 * a full table response going out before the next ttvn increment
283 283 * (consistency check)
284 284 */
285   - tt_local_entry->common.flags |= BATADV_TT_CLIENT_NEW;
  285 + tt_local->common.flags |= BATADV_TT_CLIENT_NEW;
286 286  
287 287 hash_added = batadv_hash_add(bat_priv->tt.local_hash, batadv_compare_tt,
288   - batadv_choose_orig,
289   - &tt_local_entry->common,
290   - &tt_local_entry->common.hash_entry);
  288 + batadv_choose_orig, &tt_local->common,
  289 + &tt_local->common.hash_entry);
291 290  
292 291 if (unlikely(hash_added != 0)) {
293 292 /* remove the reference for the hash */
294   - batadv_tt_local_entry_free_ref(tt_local_entry);
  293 + batadv_tt_local_entry_free_ref(tt_local);
295 294 goto out;
296 295 }
297 296  
298   - batadv_tt_local_event(bat_priv, addr, tt_local_entry->common.flags);
  297 + batadv_tt_local_event(bat_priv, addr, tt_local->common.flags);
299 298  
300 299 /* remove address from global hash if present */
301   - tt_global_entry = batadv_tt_global_hash_find(bat_priv, addr);
  300 + tt_global = batadv_tt_global_hash_find(bat_priv, addr);
302 301  
303 302 /* Check whether it is a roaming! */
304   - if (tt_global_entry) {
  303 + if (tt_global) {
305 304 /* These node are probably going to update their tt table */
306   - head = &tt_global_entry->orig_list;
  305 + head = &tt_global->orig_list;
307 306 rcu_read_lock();
308 307 hlist_for_each_entry_rcu(orig_entry, node, head, list) {
309   - batadv_send_roam_adv(bat_priv,
310   - tt_global_entry->common.addr,
  308 + batadv_send_roam_adv(bat_priv, tt_global->common.addr,
311 309 orig_entry->orig_node);
312 310 }
313 311 rcu_read_unlock();
314 312 /* The global entry has to be marked as ROAMING and
315 313 * has to be kept for consistency purpose
316 314 */
317   - tt_global_entry->common.flags |= BATADV_TT_CLIENT_ROAM;
318   - tt_global_entry->roam_at = jiffies;
  315 + tt_global->common.flags |= BATADV_TT_CLIENT_ROAM;
  316 + tt_global->roam_at = jiffies;
319 317 }
320 318 out:
321   - if (tt_local_entry)
322   - batadv_tt_local_entry_free_ref(tt_local_entry);
323   - if (tt_global_entry)
324   - batadv_tt_global_entry_free_ref(tt_global_entry);
  319 + if (tt_local)
  320 + batadv_tt_local_entry_free_ref(tt_local);
  321 + if (tt_global)
  322 + batadv_tt_global_entry_free_ref(tt_global);
325 323 }
326 324  
327 325 static void batadv_tt_realloc_packet_buff(unsigned char **packet_buff,