public inbox for b.a.t.m.a.n@lists.open-mesh.org
 help / color / mirror / Atom feed
From: Marek Lindner <lindner_marek@yahoo.de>
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] batman-adv: handle hash_add() return value in the TT code
Date: Wed, 3 Aug 2011 07:31:52 +0200	[thread overview]
Message-ID: <201108030731.52934.lindner_marek@yahoo.de> (raw)
In-Reply-To: <20110731215318.GA25702@ritirata.org.org>

On Sunday, July 31, 2011 23:53:19 Antonio Quartulli wrote:
> > > +	hash_added = hash_add(bat_priv->tt_local_hash, compare_ltt,
> > > +			      choose_orig, tt_local_entry,
> > > +			      &tt_local_entry->hash_entry);
> > > +	if (hash_added != 0)
> > > +		tt_local_entry_free_ref(tt_local_entry);
> > > +
> > > +	if (hash_added < 0)
> > > +		goto out;
> > 
> > No matter whether we add a new element to the tt hash or not we always
> > generate a log message and throw a tt_local_event(). Is that what we want
> > ?
> 
> What about going to 'out' in case of hash_added != 0? In both cases (<0 or
> >0) we cannot go ahead with the function as the entry has already been
> added or it is not possible to add it.

If I am not mistaken we should keep the additional "tt_local_entry_free_ref()" 
because we initialize the newly allocated struct with 2.
Still, the original problem remains: We generate a log message claiming to 
have added a new entry even though it might fail later. You have to move the 
log message to the end of the function.


> > > +		hash_added = hash_add(bat_priv->tt_global_hash, compare_gtt,
> > > +				      choose_orig, tt_global_entry,
> > > +				      &tt_global_entry->hash_entry);
> > > +		if (hash_added != 0)
> > > +			tt_global_entry_free_ref(tt_global_entry);
> > > +
> > > +		if (hash_added < 0)
> > > +			goto out;
> > > +
> > > +		if (!hash_added)
> > > +			atomic_inc(&orig_node->tt_size);
> > 
> > Here we only generate a log message when the element has been added or
> > already exists. Do we want that too ?
> 
> The same as before.

Yeah, same problem as above.  :-)

Cheers,
Marek

      reply	other threads:[~2011-08-03  5:31 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-09 23:50 [B.A.T.M.A.N.] [PATCH] batman-adv: handle hash_add() return value in the TT code Antonio Quartulli
2011-07-23 21:17 ` Marek Lindner
2011-07-31 21:53   ` Antonio Quartulli
2011-08-03  5:31     ` Marek Lindner [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=201108030731.52934.lindner_marek@yahoo.de \
    --to=lindner_marek@yahoo.de \
    --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