[2/4] eal: simplify check condition

Message ID 20230519042923.314670-3-ruifeng.wang@arm.com (mailing list archive)
State Accepted, archived
Delegated to: Thomas Monjalon
Headers
Series Heap library and test case changes |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Ruifeng Wang May 19, 2023, 4:29 a.m. UTC
  The alt_elem is initialized to null. Checking only size hint flag is
sufficient to return a proper value.
Removed the redundant check.

Signed-off-by: Ruifeng Wang <ruifeng.wang@arm.com>
Reviewed-by: Feifei Wang <feifei.wang2@arm.com>
---
 lib/eal/common/malloc_heap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

Anatoly Burakov May 19, 2023, 11:06 a.m. UTC | #1
On 5/19/2023 5:29 AM, Ruifeng Wang wrote:
> The alt_elem is initialized to null. Checking only size hint flag is
> sufficient to return a proper value.
> Removed the redundant check.
> 
> Signed-off-by: Ruifeng Wang <ruifeng.wang@arm.com>
> Reviewed-by: Feifei Wang <feifei.wang2@arm.com>
> ---
Acked-by: Anatoly Burakov <anatoly.burakov@intel.com>
  

Patch

diff --git a/lib/eal/common/malloc_heap.c b/lib/eal/common/malloc_heap.c
index d25bdc98f9..fa709ac567 100644
--- a/lib/eal/common/malloc_heap.c
+++ b/lib/eal/common/malloc_heap.c
@@ -168,7 +168,7 @@  find_suitable_element(struct malloc_heap *heap, size_t size,
 		}
 	}
 
-	if ((alt_elem != NULL) && (flags & RTE_MEMZONE_SIZE_HINT_ONLY))
+	if (flags & RTE_MEMZONE_SIZE_HINT_ONLY)
 		return alt_elem;
 
 	return NULL;