public inbox for b.a.t.m.a.n@lists.open-mesh.org
 help / color / mirror / Atom feed
From: "Martin Hundebøll" <martin@hundeboll.net>
To: The list for a Better Approach To Mobile Ad-hoc Networking
	<b.a.t.m.a.n@lists.open-mesh.org>
Subject: Re: [B.A.T.M.A.N.] [PATCH 5/5] batman-adv: beautify tt_global_add() argument list
Date: Wed, 18 Apr 2012 10:52:46 +0200	[thread overview]
Message-ID: <4F8E80DE.8040102@hundeboll.net> (raw)
In-Reply-To: <1334701645-25862-6-git-send-email-ordex@autistici.org>

Hi,

On 04/18/2012 12:27 AM, Antonio Quartulli wrote:
> Instead of adding a new bool argument each time it is needed, it is
> better (and simpler) to pass an 8bit flag argument which contains all the
> needed flags
>
> Signed-off-by: Antonio Quartulli<ordex@autistici.org>
> ---
>   routing.c           |    2 +-
>   translation-table.c |   18 ++++++------------
>   translation-table.h |    3 +--
>   3 files changed, 8 insertions(+), 15 deletions(-)
>
> diff --git a/routing.c b/routing.c
> index 2181a91..22d67bb 100644
> --- a/routing.c
> +++ b/routing.c
> @@ -684,7 +684,7 @@ int recv_roam_adv(struct sk_buff *skb, struct hard_iface *recv_if)
>   		roam_adv_packet->src, roam_adv_packet->client);
>
>   	tt_global_add(bat_priv, orig_node, roam_adv_packet->client,
> -		      atomic_read(&orig_node->last_ttvn) + 1, true, false);
> +		      TT_CLIENT_ROAM, atomic_read(&orig_node->last_ttvn) + 1);
>
>   	/* Roaming phase starts: I have new information but the ttvn has not
>   	 * been incremented yet. This flag will make me check all the incoming
> diff --git a/translation-table.c b/translation-table.c
> index ab295ee..00757ea 100644
> --- a/translation-table.c
> +++ b/translation-table.c
> @@ -589,8 +589,7 @@ static void tt_global_add_orig_entry(struct tt_global_entry *tt_global_entry,
>
>   /* caller must hold orig_node refcount */
>   int tt_global_add(struct bat_priv *bat_priv, struct orig_node *orig_node,
> -		  const unsigned char *tt_addr, uint8_t ttvn, bool roaming,
> -		  bool wifi)
> +		  const unsigned char *tt_addr, uint8_t flags, uint8_t ttvn)
>   {
>   	struct tt_global_entry *tt_global_entry = NULL;
>   	struct tt_orig_list_entry *orig_entry;
> @@ -600,14 +599,12 @@ int tt_global_add(struct bat_priv *bat_priv, struct orig_node *orig_node,
>   	tt_global_entry = tt_global_hash_find(bat_priv, tt_addr);
>
>   	if (!tt_global_entry) {
> -		tt_global_entry = kzalloc(sizeof(*tt_global_entry),
> -					  GFP_ATOMIC);
> +		tt_global_entry = kzalloc(sizeof(*tt_global_entry), GFP_ATOMIC);

This trivial style-fix doesn't really belong in this patch, does it? (Not that I mind...)

>   		if (!tt_global_entry)
>   			goto out;
>
>   		memcpy(tt_global_entry->common.addr, tt_addr, ETH_ALEN);
> -
> -		tt_global_entry->common.flags = NO_FLAGS;
> +		tt_global_entry->common.flags = flags;
>   		tt_global_entry->roam_at = 0;
>   		atomic_set(&tt_global_entry->common.refcount, 2);
>
> @@ -654,9 +651,6 @@ int tt_global_add(struct bat_priv *bat_priv, struct orig_node *orig_node,
>   			orig_entry->ttvn = ttvn;
>   	}
>
> -	if (wifi)
> -		tt_global_entry->common.flags |= TT_CLIENT_WIFI;
> -
>   	bat_dbg(DBG_TT, bat_priv,
>   		"Creating new global tt entry: %pM (via %pM)\n",
>   		tt_global_entry->common.addr, orig_node->orig);
> @@ -664,7 +658,7 @@ int tt_global_add(struct bat_priv *bat_priv, struct orig_node *orig_node,
>   out_remove:
>   	/* remove address from local hash if present */
>   	tt_local_remove(bat_priv, tt_global_entry->common.addr,
> -			"global tt received", roaming);
> +			"global tt received", flags&  TT_CLIENT_ROAM);
>   	ret = 1;
>   out:
>   	if (tt_global_entry)
> @@ -1678,9 +1672,9 @@ static void _tt_update_changes(struct bat_priv *bat_priv,
>   				      (tt_change + i)->flags&  TT_CLIENT_ROAM);
>   		else
>   			if (!tt_global_add(bat_priv, orig_node,
> -					   (tt_change + i)->addr, ttvn, false,
> +					   (tt_change + i)->addr,
>   					   (tt_change + i)->flags&
> -							TT_CLIENT_WIFI))
> +							TT_CLIENT_WIFI, ttvn))

If you use a temporary variable for "tt_change + i", you can avoid the last indentation and make the code easier to read...

-- 
Kind Regards
Martin Hundebøll
Frederiks Allé 99A, 1.th
8000 Aarhus C
Denmark
+45 61 65 54 61
martin@hundeboll.net

      reply	other threads:[~2012-04-18  8:52 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-17 22:27 [B.A.T.M.A.N.] [PATCH 0/5] Preparation for SPEEDY_JOIN/ROAM Antonio Quartulli
2012-04-17 22:27 ` [B.A.T.M.A.N.] [PATCH 1/5] batman-adv: don't delay OGM information announcement Antonio Quartulli
2012-04-18  8:12   ` Martin Hundebøll
2012-04-18  8:31     ` Antonio Quartulli
2012-04-18  8:35       ` Martin Hundebøll
2012-04-18  8:37         ` Antonio Quartulli
2012-04-17 22:27 ` [B.A.T.M.A.N.] [PATCH 2/5] batman-adv: clear ADD+DEL (and viceversa) events in the same orig-interval Antonio Quartulli
2012-04-18  8:33   ` Martin Hundebøll
2012-04-18  8:37     ` Antonio Quartulli
2012-04-18  8:40       ` Martin Hundebøll
2012-04-17 22:27 ` [B.A.T.M.A.N.] [PATCH 3/5] batman-adv: let tt_global_entry_has_orig() return the orig_entry or NULL instead of 1 or 0 only Antonio Quartulli
2012-04-18  8:44   ` Martin Hundebøll
2012-04-17 22:27 ` [B.A.T.M.A.N.] [PATCH 4/5] batman-adv: update ttvn in case of client reannouncement Antonio Quartulli
2012-04-18  8:46   ` Martin Hundebøll
2012-04-17 22:27 ` [B.A.T.M.A.N.] [PATCH 5/5] batman-adv: beautify tt_global_add() argument list Antonio Quartulli
2012-04-18  8:52   ` Martin Hundebøll [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4F8E80DE.8040102@hundeboll.net \
    --to=martin@hundeboll.net \
    --cc=b.a.t.m.a.n@lists.open-mesh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox