From patchwork Wed Apr 4 12:42:11 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Antonio Quartulli X-Patchwork-Id: 1658 Return-Path: Received: from latitanza.investici.org (latitanza.investici.org [82.94.249.234]) by open-mesh.org (Postfix) with ESMTPS id 169546007E0 for ; Wed, 4 Apr 2012 14:41:20 +0200 (CEST) Authentication-Results: open-mesh.org; dkim=pass (1024-bit key) header.i=@autistici.org; dkim-adsp=pass Received: from [82.94.249.234] (latitanza [82.94.249.234]) (Authenticated sender: ordex@autistici.org) by localhost (Postfix) with ESMTPSA id 550F798549; Wed, 4 Apr 2012 12:41:19 +0000 (UTC) X-DKIM: Sendmail DKIM Filter v2.8.2 latitanza.investici.org 550F798549 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=autistici.org; s=stigmate; t=1333543279; bh=Hr2oGOkY2IvzZK1IVWX1V8Tzl2IKzvJRRxS6oj17xnY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; b=baqny65UlGGb2fPm+hnQ57mxB8ygsIKkNbhQrtgVx+q6HOsYr9B5dKXs+vdmrjyo+ oUg5ayiTPm0LAapt8rNEijFqK7kZ7FiwOiXfnZxkDYagEjehVPwb1aJs5RqYCwgV8e bbTOAypQSnbyry3NAfIkyW6RsHo71rnwvhVnNfSk= From: Antonio Quartulli To: b.a.t.m.a.n@lists.open-mesh.org Date: Wed, 4 Apr 2012 14:42:11 +0200 Message-Id: <1333543332-26942-4-git-send-email-ordex@autistici.org> X-Mailer: git-send-email 1.7.9.4 In-Reply-To: <1333543332-26942-1-git-send-email-ordex@autistici.org> References: <1333543332-26942-1-git-send-email-ordex@autistici.org> Subject: [B.A.T.M.A.N.] [PATCHv2 3/4] batman-adv: let tt_global_entry_has_orig() return the orig_entry or NULL instead of 1 or 0 only X-BeenThere: b.a.t.m.a.n@lists.open-mesh.org X-Mailman-Version: 2.1.13 Precedence: list Reply-To: The list for a Better Approach To Mobile Ad-hoc Networking List-Id: The list for a Better Approach To Mobile Ad-hoc Networking List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 04 Apr 2012 12:41:20 -0000 Instead of returning only 1 or 0 this function has to return the found orig_entry (if any). In this way, operations that have to to modify the found orig_entry structure will not need to reiterate over the list again to find the wanted node. Signed-off-by: Antonio Quartulli --- translation-table.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/translation-table.c b/translation-table.c index a2c1240..0ce2ed9 100644 --- a/translation-table.c +++ b/translation-table.c @@ -543,25 +543,26 @@ static void tt_changes_list_free(struct bat_priv *bat_priv) } /* find out if an orig_node is already in the list of a tt_global_entry. - * returns 1 if found, 0 otherwise */ -static bool tt_global_entry_has_orig(const struct tt_global_entry *entry, - const struct orig_node *orig_node) + * returns NULL if not found, the pointer to the orig_entry otherwise */ +static struct tt_orig_list_entry *tt_global_entry_has_orig( + const struct tt_global_entry *entry, + const struct orig_node *orig_node) { struct tt_orig_list_entry *tmp_orig_entry; const struct hlist_head *head; struct hlist_node *node; - bool found = false; + struct tt_orig_list_entry *orig_entry = NULL; rcu_read_lock(); head = &entry->orig_list; hlist_for_each_entry_rcu(tmp_orig_entry, node, head, list) { if (tmp_orig_entry->orig_node == orig_node) { - found = true; + orig_entry = tmp_orig_entry; break; } } rcu_read_unlock(); - return found; + return orig_entry; } static void tt_global_add_orig_entry(struct tt_global_entry *tt_global_entry,