[4/4] linux-generic: tm: clean up if return else lines

Message ID 1464948753-942-5-git-send-email-maxim.uvarov@linaro.org
State New
Headers show

Commit Message

Maxim Uvarov June 3, 2016, 10:12 a.m.
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 <maxim.uvarov@linaro.org>
---
 platform/linux-generic/odp_name_table.c | 70 +++++++++++++++++----------------
 1 file changed, 36 insertions(+), 34 deletions(-)

Patch

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,