[4/4] app/procinfo: remove useless assignment

Message ID 20201117171435.2303641-5-ferruh.yigit@intel.com (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers
Series cppcheck |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-intel-Functional fail Functional Testing issues
ci/iol-testing warning Testing issues
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/travis-robot success Travis build: passed

Commit Message

Ferruh Yigit Nov. 17, 2020, 5:14 p.m. UTC
  'flag' initialized to '0' but it is overwritten later, initial
assignment can be removed.

Fixes: 0101a0ec6217 ("app/procinfo: add --show-mempool")
Cc: stable@dpdk.org

Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
---
Cc: vipin.varghese@intel.com
---
 app/proc-info/main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

Varghese, Vipin Nov. 17, 2020, 6:04 p.m. UTC | #1
Hi Ferruh,

Thanks for the update

snipped
> show_mempool(char *name)  {
> -	uint64_t flags = 0;
> +	uint64_t flags;
> 

Checking the current code base it makes more sense to move the code inside `if` condition check. Sample code shared below

```
-	uint64_t flags = 0;

	snprintf(bdr_str, MAX_STRING_LEN, " show - MEMPOOL ");
	STATS_BDR_STR(10, bdr_str);

	if (name != NULL) {
		struct rte_mempool *ptr = rte_mempool_lookup(name);
		if (ptr != NULL) {
			struct rte_mempool_ops *ops;

+			unsigned int flags = ptr->flags;
			ops = rte_mempool_get_ops(ptr->ops_index);
```

But it is ok
  
Ferruh Yigit Nov. 18, 2020, 10:46 a.m. UTC | #2
On 11/17/2020 6:04 PM, Varghese, Vipin wrote:
> Hi Ferruh,
> 
> Thanks for the update
> 
> snipped
>> show_mempool(char *name)  {
>> -uint64_t flags = 0;
>> +uint64_t flags;
>>
> 
> Checking the current code base it makes more sense to move the code inside `if` condition check. Sample code shared below
> 
> ```
> -uint64_t flags = 0;
> 
> snprintf(bdr_str, MAX_STRING_LEN, " show - MEMPOOL ");
> STATS_BDR_STR(10, bdr_str);
> 
> if (name != NULL) {
> struct rte_mempool *ptr = rte_mempool_lookup(name);
> if (ptr != NULL) {
> struct rte_mempool_ops *ops;
> 
> +unsigned int flags = ptr->flags;
> ops = rte_mempool_get_ops(ptr->ops_index);
> ```
> 
> But it is ok
> 

I think both are OK, this is trivial, let me send a quick v2.
  

Patch

diff --git a/app/proc-info/main.c b/app/proc-info/main.c
index dc5cc92209..52975842fa 100644
--- a/app/proc-info/main.c
+++ b/app/proc-info/main.c
@@ -1264,7 +1264,7 @@  show_ring(char *name)
 static void
 show_mempool(char *name)
 {
-	uint64_t flags = 0;
+	uint64_t flags;
 
 	snprintf(bdr_str, MAX_STRING_LEN, " show - MEMPOOL ");
 	STATS_BDR_STR(10, bdr_str);