Skip to contentSkip to conversation

minor cleanups

PATCH In review Stephen Hemminger 3 participants 7 messages Dec 8, 2016 – Jan 9, 2017

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover minor cleanups

Saw this while reviewing other changes

Stephen Hemminger (2):
eth: get rid of goto's in rte_eth_dev_detach sched/malloc: remove unnecesary return statements

 drivers/net/bonding/rte_eth_bond_pmd.c |  2 +-
 lib/librte_eal/common/rte_malloc.c     |  1 -
 lib/librte_ether/rte_ethdev.c          | 21 +++++++--------------
 lib/librte_sched/rte_bitmap.h          |  2 --
 4 files changed, 8 insertions(+), 18 deletions(-)
Signature · 1 line
2.10.2
#1 lore raw

PATCH 1/2 eth: get rid of goto's in rte_eth_dev_detach

Extra goto's to just a return are unnecessary.

---
 lib/librte_ether/rte_ethdev.c | 21 +++++++--------------
 1 file changed, 7 insertions(+), 14 deletions(-)
lib/librte_ether/rte_ethdev.c +7 -14
index 4209ad0..40c7cc6 100644
@@ -466,27 +466,20 @@ rte_eth_dev_attach(const char *devargs, uint8_t *port_id)
 int
 rte_eth_dev_detach(uint8_t port_id, char *name)
 {
-	int ret = -1;
+	int ret;
 
-	if (name == NULL) {
-		ret = -EINVAL;
-		goto err;
-	}
+	if (name == NULL)
+		return -EINVAL;
 
 	/* FIXME: move this to eal, once device flags are relocated there */
-	if (rte_eth_dev_is_detachable(port_id))
-		goto err;
+	ret = rte_eth_dev_is_detachable(port_id);
+	if (ret < 0)
+		return  ret;
 
 	snprintf(name, sizeof(rte_eth_devices[port_id].data->name),
 		 "%s", rte_eth_devices[port_id].data->name);
-	ret = rte_eal_dev_detach(name);
-	if (ret < 0)
-		goto err;
 
-	return 0;
-
-err:
-	return ret;
+	return rte_eal_dev_detach(name);
 }
 
 static int
Signature · 1 line
2.10.2
#2 lore raw

Re: [PATCH 1/2] eth: get rid of goto's in rte_eth_dev_detach

Quoted 20 lines · Stephen Hemminger

Extra goto's to just a return are unnecessary.

---
 lib/librte_ether/rte_ethdev.c | 21 +++++++--------------
 1 file changed, 7 insertions(+), 14 deletions(-)
lib/librte_ether/rte_ethdev.c +1 -3
index 4209ad0..40c7cc6 100644
@@ -466,27 +466,20 @@ rte_eth_dev_attach(const char *devargs, uint8_t *port_id)
 int
 rte_eth_dev_detach(uint8_t port_id, char *name)
 {
-	int ret = -1;
+	int ret;
 
-	if (name == NULL) {
-		ret = -EINVAL;

lib/librte_ether/rte_ethdev.c rte_eth_dev_attach(const char *devargs, uint8_t *port_id) · line 476

Quoted 10 lines
lib/librte_ether/rte_ethdev.c +4 -4
-		goto err;
-	}
+	if (name == NULL)
+		return -EINVAL;
 
 	/* FIXME: move this to eal, once device flags are relocated there */
-	if (rte_eth_dev_is_detachable(port_id))
-		goto err;
+	ret = rte_eth_dev_is_detachable(port_id);
+	if (ret < 0)

rte_eth_dev_is_detachable() can return 1 to indicate device is not detachable.

Quoted 17 lines
lib/librte_ether/rte_ethdev.c +2 -7
+		return  ret;
 
 	snprintf(name, sizeof(rte_eth_devices[port_id].data->name),
 		 "%s", rte_eth_devices[port_id].data->name);
-	ret = rte_eal_dev_detach(name);
-	if (ret < 0)
-		goto err;
 
-	return 0;
-
-err:
-	return ret;
+	return rte_eal_dev_detach(name);
 }
 
 static int
#3 lore raw

Re: [PATCH 1/2] eth: get rid of goto's in rte_eth_dev_detach

2016-12-08 10:25, Ferruh Yigit:

Quoted 26 lines · Stephen Hemminger
Quoted 11 lines
lib/librte_ether/rte_ethdev.c +1 -3
@@ -466,27 +466,20 @@ rte_eth_dev_attach(const char *devargs, uint8_t *port_id)
 int
 rte_eth_dev_detach(uint8_t port_id, char *name)
 {
-	int ret = -1;
+	int ret;
 
-	if (name == NULL) {
-		ret = -EINVAL;

lib/librte_ether/rte_ethdev.c rte_eth_dev_attach(const char *devargs, uint8_t *port_id) · line 476

Quoted 10 lines
lib/librte_ether/rte_ethdev.c +4 -4
-		goto err;
-	}
+	if (name == NULL)
+		return -EINVAL;
 
 	/* FIXME: move this to eal, once device flags are relocated there */
-	if (rte_eth_dev_is_detachable(port_id))
-		goto err;
+	ret = rte_eth_dev_is_detachable(port_id);
+	if (ret < 0)

rte_eth_dev_is_detachable() can return 1 to indicate device is not detachable.

Quoted 1 line

lib/librte_ether/rte_ethdev.c rte_eth_dev_attach(const char *devargs, uint8_t *port_id) · line 477

Quoted 1 line
lib/librte_ether/rte_ethdev.c +1 -0
+		return  ret;

It should be

ret = rte_eth_dev_is_detachable(port_id);
if (ret)

	return -1;
#4 lore raw

PATCH 2/2 sched/malloc: remove unnecesary return statements

In reply to Stephen Hemminger

return statements at end of void functions are unnecessary and unwanted.

---
 drivers/net/bonding/rte_eth_bond_pmd.c | 2 +-
 lib/librte_eal/common/rte_malloc.c     | 1 -
 lib/librte_sched/rte_bitmap.h          | 2 --
 3 files changed, 1 insertion(+), 4 deletions(-)
drivers/net/bonding/rte_eth_bond_pmd.c +1 -1
index a80b6fa..05afcee 100644
@@ -241,8 +241,8 @@ arp_op_name(uint16_t arp_op, char *buf)
 	default:
 		break;
 	}
+
 	snprintf(buf, sizeof("Unknown"), "%s", "Unknown");
-	return;
 }
 #endif
 #define MaxIPv4String	16
lib/librte_eal/common/rte_malloc.c +0 -1
index f4a8835..09970b0 100644
@@ -232,7 +232,6 @@ rte_malloc_dump_stats(FILE *f, __rte_unused const char *type)
 		fprintf(f, "\tAlloc_count:%u,\n",sock_stats.alloc_count);
 		fprintf(f, "\tFree_count:%u,\n", sock_stats.free_count);
 	}
-	return;
 }
 
 /*
lib/librte_sched/rte_bitmap.h +0 -2
index 010d752..d432fdf 100644
@@ -453,8 +453,6 @@ rte_bitmap_clear(struct rte_bitmap *bmp, uint32_t pos)
 	offset1 = (pos >> RTE_BITMAP_CL_BIT_SIZE_LOG2) & RTE_BITMAP_SLAB_BIT_MASK;
 	slab1 = bmp->array1 + index1;
 	*slab1 &= ~(1lu << offset1);
-
-	return;
 }
 
 static inline int
Signature · 1 line
2.10.2
#6 lore raw
In reply to Stephen Hemminger

Hi Stephen,

This series is still pending.
Would you mind to make a v2, please?

2016-12-07 17:47, Stephen Hemminger:

Quoted 5 lines

Saw this while reviewing other changes

Stephen Hemminger (2):
eth: get rid of goto's in rte_eth_dev_detach sched/malloc: remove unnecesary return statements