From patchwork Fri Jun 3 10:12:33 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Uvarov X-Patchwork-Id: 69239 Delivered-To: patch@linaro.org Received: by 10.140.106.246 with SMTP id e109csp184742qgf; Fri, 3 Jun 2016 03:16:09 -0700 (PDT) X-Received: by 10.107.180.11 with SMTP id d11mr3556506iof.151.1464948969561; Fri, 03 Jun 2016 03:16:09 -0700 (PDT) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id z3si6030173ioe.144.2016.06.03.03.16.09; Fri, 03 Jun 2016 03:16:09 -0700 (PDT) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) client-ip=54.225.227.206; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=pass (p=NONE dis=NONE) header.from=linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 17400616CC; Fri, 3 Jun 2016 10:16:09 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252 X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from [127.0.0.1] (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id 2532C617DF; Fri, 3 Jun 2016 10:14:19 +0000 (UTC) X-Original-To: lng-odp@lists.linaro.org Delivered-To: lng-odp@lists.linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 19564617DB; Fri, 3 Jun 2016 10:14:14 +0000 (UTC) Received: from mail-lf0-f49.google.com (mail-lf0-f49.google.com [209.85.215.49]) by lists.linaro.org (Postfix) with ESMTPS id 54944617B9 for ; Fri, 3 Jun 2016 10:12:44 +0000 (UTC) Received: by mail-lf0-f49.google.com with SMTP id k98so51426075lfi.1 for ; Fri, 03 Jun 2016 03:12:44 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=q2Opan0sQehgsbKKMZY4JHk4VVqLAEm8zyC7iM2HWhA=; b=K9AL3EL2H7nSNX3daeqn07GVzCd7xIpXY71hiAmOrlNQMcgsMlGE1sX6hyk7IV+Tmz 1i65+ernbyh4kiBc3bFl2PekzUJ6bCzDnh3BdR27SSEZaNFAvstLtIMMaIfzhWT4592o bd4JeS6q4NlfZTYix8X9kumSHfaieRSkEg/FzR10xGERH/rXXJwQFDFy6MItMR3KDd0f ZM63U53ulYRqgUSEk9nBws09YNrCcgBdNNChMPhi683UTgD9LRRXd/Ot32Xgfqu7Qbex qfQEhPu4lG0hEH7AHof8FkZpwkK9t1QKm+UeElBpMF4ciC/n5LLlQ34NIM90rku5mqkK Y/1A== X-Gm-Message-State: ALyK8tJxeKDO7u4hVCIpX6rsTaEfdFvIa787XKVyet8PoumgsNu10Wrp92c7468B97TDfsXoIp4= X-Received: by 10.46.32.165 with SMTP id g37mr708712lji.31.1464948763153; Fri, 03 Jun 2016 03:12:43 -0700 (PDT) Received: from maxim-Aspire-VN7-791.d-systems.local ([185.75.190.112]) by smtp.gmail.com with ESMTPSA id 1sm327712ljf.5.2016.06.03.03.12.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 03 Jun 2016 03:12:42 -0700 (PDT) From: Maxim Uvarov To: lng-odp@lists.linaro.org Date: Fri, 3 Jun 2016 13:12:33 +0300 Message-Id: <1464948753-942-5-git-send-email-maxim.uvarov@linaro.org> X-Mailer: git-send-email 2.7.1.250.gff4ea60 In-Reply-To: <1464948753-942-1-git-send-email-maxim.uvarov@linaro.org> References: <1464948753-942-1-git-send-email-maxim.uvarov@linaro.org> X-Topics: patch Subject: [lng-odp] [PATCH 4/4] linux-generic: tm: clean up if return else lines X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: "The OpenDataPlane \(ODP\) List" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" Clean up if (){return;} else {...} lines with removing not needed else due to there is not other code path. This also allows should code left to one position and make more room for code. No functional change. Signed-off-by: Maxim Uvarov --- platform/linux-generic/odp_name_table.c | 70 +++++++++++++++++---------------- 1 file changed, 36 insertions(+), 34 deletions(-) diff --git a/platform/linux-generic/odp_name_table.c b/platform/linux-generic/odp_name_table.c index 4d7fba2..f190ba9 100644 --- a/platform/linux-generic/odp_name_table.c +++ b/platform/linux-generic/odp_name_table.c @@ -735,12 +735,14 @@ static int name_hash_tbl_delete(name_tbl_entry_t *entry_to_delete, hash_entry_ptr = &name_hash_tbl.hash_entries[primary_hash_idx]; hash_tbl_entry = *hash_entry_ptr; entry_cnt = hash_tbl_entry & 0x3F; - if (hash_tbl_entry == 0) { - /* This primary hash table entry points to an empty bucket, so - * we have failed to find the matching entry. - */ + + /* This primary hash table entry points to an empty bucket, so + * we have failed to find the matching entry. + */ + if (!hash_tbl_entry) return -1; - } else if (entry_cnt != 0) { + + if (entry_cnt != 0) { /* This primary hash table entry points to a name_tbl_entry_t * linked list, so remove entry from this linked list. */ @@ -768,12 +770,14 @@ static int name_hash_tbl_delete(name_tbl_entry_t *entry_to_delete, hash_entry_ptr = &secondary_hash->hash_entries[hash_idx]; hash_tbl_entry = *hash_entry_ptr; entry_cnt = hash_tbl_entry & 0x3F; - if (hash_tbl_entry == 0) { - /* This secondary hash table entry points to an empty bucket, - * so we have failed to find the matching entry. - */ + + /* This secondary hash table entry points to an empty bucket, + * so we have failed to find the matching entry. + */ + if (!hash_tbl_entry) return -1; - } else if (entry_cnt != 0) { + + if (entry_cnt != 0) { /* This secondary hash table entry points to a * name_tbl_entry_t linked list, so try to remove * entry_to_delete from this linked list. @@ -817,34 +821,32 @@ static int name_hash_tbl_delete(name_tbl_entry_t *entry_to_delete, hash_entry_ptr = &secondary_hash->hash_entries[hash_idx]; hash_tbl_entry = *hash_entry_ptr; entry_cnt = hash_tbl_entry & 0x3F; - if (hash_tbl_entry == 0) { - /* This secondary hash table entry points to an empty bucket, - * so we have failed to find the matching entry. - */ + + /* This secondary hash table entry points to an empty bucket, + * so we have failed to find the matching entry. + */ + if (!hash_tbl_entry || !entry_cnt) return -1; - } else if (entry_cnt != 0) { - /* This secondary hash table entry points to a - * name_tbl_entry_t linked list, so try to remove - * entry_to_delete from this linked list. - */ - name_tbl_entry = - (name_tbl_entry_t *)(uintptr_t)(hash_tbl_entry & ~0x3F); - rc = name_tbl_entry_list_remove(hash_entry_ptr, name_tbl_entry, - entry_to_delete, entry_cnt); - tbn = (*hash_entry_ptr) & ~0x3F; - if (tbn == 0xFFFFFFFFFFFFFFC0) - ODP_ABORT("tbn overflow\n"); - check_secondary_hash(secondary_hash); - if (rc < 0) - return rc; + /* This secondary hash table entry points to a + * name_tbl_entry_t linked list, so try to remove + * entry_to_delete from this linked list. + */ + name_tbl_entry = + (name_tbl_entry_t *)(uintptr_t)(hash_tbl_entry & ~0x3F); + rc = name_tbl_entry_list_remove(hash_entry_ptr, name_tbl_entry, + entry_to_delete, entry_cnt); + tbn = (*hash_entry_ptr) & ~0x3F; + if (tbn == 0xFFFFFFFFFFFFFFC0) + ODP_ABORT("tbn overflow\n"); - name_hash_tbl.hash_collisions[primary_hash_idx]--; - check_secondary_hash(secondary_hash); - return 0; - } + check_secondary_hash(secondary_hash); + if (rc < 0) + return rc; - return -1; + name_hash_tbl.hash_collisions[primary_hash_idx]--; + check_secondary_hash(secondary_hash); + return 0; } _odp_int_name_t _odp_int_name_tbl_add(const char *name,