Skip to contentSkip to conversation

remove check around pthread_mutex_init()

PATCH Superseded Ariel Otilibili 5 participants 38 messages Jan 12, 2025 – Feb 13, 2025 Network drivers

lore
Share & tools
lore
#0 lore raw

cover remove check around pthread_mutex_init()

Hello,

This series addresses Bugzilla ID 1586; the man says

Quoted 2 lines

pthread_mutex_init always returns 0. The other mutex functions return 0 on success and a non-zero error code on error.

Meaning, the check around around pthread_mutex_init() is needless.

Thank you,

Bugzilla ID: 1586

Ariel Otilibili (6):
raw/ifpga: remove check around pthread_mutex_init() net/bnxt: remove check around pthread_mutex_init() common/cnxk: remove check around pthread_mutex_init() net/failsafe: remove check around pthread_mutex_init() net/hinic: remove check around pthread_mutex_init() lib/vhost: remove check around pthread_mutex_init()

 drivers/common/cnxk/roc_bphy_cgx.c            |  5 +--
 drivers/net/bnxt/bnxt_ethdev.c                | 40 ++++---------------
 drivers/net/bnxt/bnxt_txq.c                   |  6 +--
 drivers/net/bnxt/tf_ulp/bnxt_ulp.c            |  8 +---
 drivers/net/bnxt/tf_ulp/bnxt_ulp_tf.c         |  6 +--
 drivers/net/bnxt/tf_ulp/bnxt_ulp_tfc.c        |  6 +--
 drivers/net/bnxt/tf_ulp/ulp_fc_mgr.c          |  6 +--
 drivers/net/bnxt/tf_ulp/ulp_ha_mgr.c          |  6 +--
 drivers/net/failsafe/failsafe.c               |  6 +--
 drivers/net/hinic/base/hinic_compat.h         |  8 +---
 drivers/raw/ifpga/base/opae_intel_max10.c     |  5 +--
 drivers/raw/ifpga/base/opae_spi_transaction.c | 10 +----
 lib/vhost/socket.c                            | 14 +------
 13 files changed, 22 insertions(+), 104 deletions(-)
Signature · 1 line
2.30.2
#1 lore raw

PATCH 1/6 raw/ifpga: remove check around pthread_mutex_init()

Quoted 2 lines

pthread_mutex_init always returns 0. The other mutex functions return 0 on success and a non-zero error code on error.

Bugzilla ID: 1586

---
 drivers/raw/ifpga/base/opae_intel_max10.c     |  5 +----
 drivers/raw/ifpga/base/opae_spi_transaction.c | 10 +---------
 2 files changed, 2 insertions(+), 13 deletions(-)
drivers/raw/ifpga/base/opae_intel_max10.c +1 -4
index d5a9ceb6e355..58c884a8d8e1 100644
@@ -1486,10 +1486,7 @@ intel_max10_device_init(struct intel_max10_device *dev)
 		if (ret)
 			return ret;
 
-		ret = pthread_mutex_init(&dev->bmc_ops.lock, NULL);
-		if (ret)
-			return ret;
-
+		pthread_mutex_init(&dev->bmc_ops.lock, NULL);
 		if (!dev->bmc_ops.mutex)
 			dev->bmc_ops.mutex = &dev->bmc_ops.lock;
 	}
drivers/raw/ifpga/base/opae_spi_transaction.c +1 -9
index 21015eb95ef5..95efcbbecb0a 100644
@@ -507,11 +507,7 @@ struct spi_transaction_dev *spi_transaction_init(struct altera_spi_device *dev,
 	if (!spi_tran_dev->buffer)
 		goto err;
 
-	ret = pthread_mutex_init(&spi_tran_dev->lock, NULL);
-	if (ret) {
-		dev_err(spi_tran_dev, "fail to init mutex lock\n");
-		goto err;
-	}
+	pthread_mutex_init(&spi_tran_dev->lock, NULL);
 	if (dev->mutex) {
 		dev_info(NULL, "use multi-process mutex in spi\n");
 		spi_tran_dev->mutex = dev->mutex;
@@ -521,10 +517,6 @@ struct spi_transaction_dev *spi_transaction_init(struct altera_spi_device *dev,
 	}
 
 	return spi_tran_dev;
-
-err:
-	opae_free(spi_tran_dev);
-	return NULL;
 }
 
 void spi_transaction_remove(struct spi_transaction_dev *dev)
Signature · 1 line
2.30.2
#2 lore raw

PATCH 2/6 net/bnxt: remove check around pthread_mutex_init()

In reply to Ariel Otilibili
Quoted 2 lines

pthread_mutex_init always returns 0. The other mutex functions return 0 on success and a non-zero error code on error.

Bugzilla ID: 1586

---
 drivers/net/bnxt/bnxt_ethdev.c         | 40 ++++++--------------------
 drivers/net/bnxt/bnxt_txq.c            |  6 +---
 drivers/net/bnxt/tf_ulp/bnxt_ulp.c     |  8 +-----
 drivers/net/bnxt/tf_ulp/bnxt_ulp_tf.c  |  6 +---
 drivers/net/bnxt/tf_ulp/bnxt_ulp_tfc.c |  6 +---
 drivers/net/bnxt/tf_ulp/ulp_fc_mgr.c   |  6 +---
 drivers/net/bnxt/tf_ulp/ulp_ha_mgr.c   |  6 +---
 7 files changed, 14 insertions(+), 64 deletions(-)
drivers/net/bnxt/bnxt_ethdev.c +8 -32
index ef8a928c9170..3a88cdc94128 100644
@@ -5821,31 +5821,12 @@ static int bnxt_get_config(struct bnxt *bp)
 static int
 bnxt_init_locks(struct bnxt *bp)
 {
-	int err;
+	pthread_mutex_init(&bp->flow_lock, NULL);
+	pthread_mutex_init(&bp->def_cp_lock, NULL);
+	pthread_mutex_init(&bp->health_check_lock, NULL);
+	pthread_mutex_init(&bp->err_recovery_lock, NULL);
 
-	err = pthread_mutex_init(&bp->flow_lock, NULL);
-	if (err) {
-		PMD_DRV_LOG_LINE(ERR, "Unable to initialize flow_lock");
-		return err;
-	}
-
-	err = pthread_mutex_init(&bp->def_cp_lock, NULL);
-	if (err) {
-		PMD_DRV_LOG_LINE(ERR, "Unable to initialize def_cp_lock");
-		return err;
-	}
-
-	err = pthread_mutex_init(&bp->health_check_lock, NULL);
-	if (err) {
-		PMD_DRV_LOG_LINE(ERR, "Unable to initialize health_check_lock");
-		return err;
-	}
-
-	err = pthread_mutex_init(&bp->err_recovery_lock, NULL);
-	if (err)
-		PMD_DRV_LOG_LINE(ERR, "Unable to initialize err_recovery_lock");
-
-	return err;
+	return 0;
 }
 
 /* This should be called after we have queried trusted VF cap */
@@ -6746,7 +6727,7 @@ static void bnxt_free_rep_info(struct bnxt *bp)
 
 static int bnxt_init_rep_info(struct bnxt *bp)
 {
-	int i = 0, rc;
+	int i = 0;
 
 	if (bp->rep_info)
 		return 0;
@@ -6770,14 +6751,9 @@ static int bnxt_init_rep_info(struct bnxt *bp)
 	for (i = 0; i < BNXT_MAX_CFA_CODE; i++)
 		bp->cfa_code_map[i] = BNXT_VF_IDX_INVALID;
 
-	rc = pthread_mutex_init(&bp->rep_info->vfr_start_lock, NULL);
-	if (rc) {
-		PMD_DRV_LOG_LINE(ERR, "Unable to initialize vfr_start_lock");
-		bnxt_free_rep_info(bp);
-		return rc;
-	}
+	pthread_mutex_init(&bp->rep_info->vfr_start_lock, NULL);
 
-	return rc;
+	return 0;
 }
 
 static int bnxt_rep_port_probe(struct rte_pci_device *pci_dev,
drivers/net/bnxt/bnxt_txq.c +1 -5
index c8649359923f..ab561585d771 100644
@@ -198,11 +198,7 @@ int bnxt_tx_queue_setup_op(struct rte_eth_dev *eth_dev,
 		goto err;
 	}
 
-	rc = pthread_mutex_init(&txq->txq_lock, NULL);
-	if (rc != 0) {
-		PMD_DRV_LOG_LINE(ERR, "TxQ mutex init failed!");
-		goto err;
-	}
+	pthread_mutex_init(&txq->txq_lock, NULL);
 	return 0;
 err:
 	bnxt_tx_queue_release_op(eth_dev, queue_idx);
drivers/net/bnxt/tf_ulp/bnxt_ulp.c +1 -7
index 1bfc88cf79ef..0c03ae7a8349 100644
@@ -188,7 +188,6 @@ ulp_session_init(struct bnxt *bp,
 	struct rte_pci_device		*pci_dev;
 	struct rte_pci_addr		*pci_addr;
 	struct bnxt_ulp_session_state	*session;
-	int rc = 0;
 
 	if (!bp)
 		return NULL;
@@ -215,12 +214,7 @@ ulp_session_init(struct bnxt *bp,
 			session->pci_info.domain = pci_addr->domain;
 			session->pci_info.bus = pci_addr->bus;
 			memcpy(session->dsn, bp->dsn, sizeof(session->dsn));
-			rc = pthread_mutex_init(&session->bnxt_ulp_mutex, NULL);
-			if (rc) {
-				BNXT_DRV_DBG(ERR, "mutex create failed\n");
-				pthread_mutex_unlock(&bnxt_ulp_global_mutex);
-				return NULL;
-			}
+			pthread_mutex_init(&session->bnxt_ulp_mutex, NULL);
 			STAILQ_INSERT_TAIL(&bnxt_ulp_session_list,
 					   session, next);
 		}
drivers/net/bnxt/tf_ulp/bnxt_ulp_tf.c +1 -5
index fa7e8fe00077..4a1ccfa2a36d 100644
@@ -1472,11 +1472,7 @@ ulp_tf_init(struct bnxt *bp,
 		goto jump_to_error;
 	}
 
-	rc = pthread_mutex_init(&bp->ulp_ctx->cfg_data->flow_db_lock, NULL);
-	if (rc) {
-		BNXT_DRV_DBG(ERR, "Unable to initialize flow db lock\n");
-		goto jump_to_error;
-	}
+	pthread_mutex_init(&bp->ulp_ctx->cfg_data->flow_db_lock, NULL);
 
 	/* Initialize ulp dparms with values devargs passed */
 	rc = ulp_tf_dparms_init(bp, bp->ulp_ctx);
drivers/net/bnxt/tf_ulp/bnxt_ulp_tfc.c +1 -5
index 6d7ec0ffec79..508c194d0490 100644
@@ -993,11 +993,7 @@ ulp_tfc_init(struct bnxt *bp,
 		goto jump_to_error;
 	}
 
-	rc = pthread_mutex_init(&bp->ulp_ctx->cfg_data->flow_db_lock, NULL);
-	if (rc) {
-		BNXT_DRV_DBG(ERR, "Unable to initialize flow db lock\n");
-		goto jump_to_error;
-	}
+	pthread_mutex_init(&bp->ulp_ctx->cfg_data->flow_db_lock, NULL);
 
 	rc = ulp_tfc_dparms_init(bp, bp->ulp_ctx, ulp_dev_id);
 	if (rc) {
drivers/net/bnxt/tf_ulp/ulp_fc_mgr.c +1 -5
index 67489b76f390..f9d069f4e17e 100644
@@ -129,11 +129,7 @@ ulp_fc_mgr_init(struct bnxt_ulp_context *ctxt)
 	ulp_fc_info->fc_ops = fc_ops;
 	ulp_fc_info->flags = flags;
 
-	rc = pthread_mutex_init(&ulp_fc_info->fc_lock, NULL);
-	if (rc) {
-		BNXT_DRV_DBG(ERR, "Failed to initialize fc mutex\n");
-		goto error;
-	}
+	pthread_mutex_init(&ulp_fc_info->fc_lock, NULL);
 
 	/* Add the FC info tbl to the ulp context. */
 	bnxt_ulp_cntxt_ptr2_fc_info_set(ctxt, ulp_fc_info);
drivers/net/bnxt/tf_ulp/ulp_ha_mgr.c +1 -5
index 3c75a6b43721..7b7c10d3602e 100644
@@ -412,11 +412,7 @@ ulp_ha_mgr_init(struct bnxt_ulp_context *ulp_ctx)
 	/* Add the HA info tbl to the ulp context. */
 	bnxt_ulp_cntxt_ptr2_ha_info_set(ulp_ctx, ha_info);
 
-	rc = pthread_mutex_init(&ha_info->ha_lock, NULL);
-	if (rc) {
-		PMD_DRV_LOG_LINE(ERR, "Failed to initialize ha mutex");
-		goto cleanup;
-	}
+	pthread_mutex_init(&ha_info->ha_lock, NULL);
 	rc = ulp_ha_mgr_timer_start(ulp_ctx->cfg_data);
 	if (rc) {
 		PMD_DRV_LOG_LINE(ERR, "Unable to start timer CB");
Signature · 1 line
2.30.2
#3 lore raw

PATCH 3/6 common/cnxk: remove check around pthread_mutex_init()

In reply to Ariel Otilibili
Quoted 2 lines

pthread_mutex_init always returns 0. The other mutex functions return 0 on success and a non-zero error code on error.

Bugzilla ID: 1586

---
 drivers/common/cnxk/roc_bphy_cgx.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/common/cnxk/roc_bphy_cgx.c +1 -4
index 4f43605e1031..882cf654743b 100644
@@ -189,14 +189,11 @@ int
 roc_bphy_cgx_dev_init(struct roc_bphy_cgx *roc_cgx)
 {
 	uint64_t val;
-	int ret;
 
 	if (!roc_cgx || !roc_cgx->bar0_va || !roc_cgx->bar0_pa)
 		return -EINVAL;
 
-	ret = pthread_mutex_init(&roc_cgx->lock, NULL);
-	if (ret)
-		return ret;
+	pthread_mutex_init(&roc_cgx->lock, NULL);
 
 	val = roc_bphy_cgx_read(roc_cgx, 0, CGX_CMRX_RX_LMACS);
 	val = FIELD_GET(CGX_CMRX_RX_LMACS_LMACS, val);
Signature · 1 line
2.30.2
#4 lore raw

PATCH 4/6 net/failsafe: remove check around pthread_mutex_init()

In reply to Ariel Otilibili
Quoted 2 lines

pthread_mutex_init always returns 0. The other mutex functions return 0 on success and a non-zero error code on error.

Bugzilla ID: 1586

---
 drivers/net/failsafe/failsafe.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)
drivers/net/failsafe/failsafe.c +1 -5
index 32811403b4c8..e1c77cdf4fd1 100644
@@ -147,11 +147,7 @@ fs_mutex_init(struct fs_priv *priv)
 		ERROR("Cannot set mutex type - %s", strerror(ret));
 		return ret;
 	}
-	ret = pthread_mutex_init(&priv->hotplug_mutex, &attr);
-	if (ret) {
-		ERROR("Cannot initiate mutex - %s", strerror(ret));
-		return ret;
-	}
+	pthread_mutex_init(&priv->hotplug_mutex, &attr);
 	return 0;
 }
 
Signature · 1 line
2.30.2
#5 lore raw

PATCH 5/6 net/hinic: remove check around pthread_mutex_init()

In reply to Ariel Otilibili
Quoted 2 lines

pthread_mutex_init always returns 0. The other mutex functions return 0 on success and a non-zero error code on error.

Bugzilla ID: 1586

---
 drivers/net/hinic/base/hinic_compat.h | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)
drivers/net/hinic/base/hinic_compat.h +2 -6
index ab9d1b9a0214..8f5763fbfc9d 100644
@@ -200,13 +200,9 @@ static inline u16 ilog2(u32 n)
 static inline int hinic_mutex_init(pthread_mutex_t *pthreadmutex,
 					const pthread_mutexattr_t *mattr)
 {
-	int err;
-
-	err = pthread_mutex_init(pthreadmutex, mattr);
-	if (unlikely(err))
-		PMD_DRV_LOG(ERR, "Fail to initialize mutex, error: %d", err);
+	pthread_mutex_init(pthreadmutex, mattr);
 
-	return err;
+	return 0;
 }
 
 static inline int hinic_mutex_destroy(pthread_mutex_t *pthreadmutex)
Signature · 1 line
2.30.2
#6 lore raw

PATCH 6/6 lib/vhost: remove check around pthread_mutex_init()

In reply to Ariel Otilibili
Quoted 2 lines

pthread_mutex_init always returns 0. The other mutex functions return 0 on success and a non-zero error code on error.

Bugzilla ID: 1586

---
 lib/vhost/socket.c | 14 ++------------
 1 file changed, 2 insertions(+), 12 deletions(-)
lib/vhost/socket.c +2 -12
index d29d15494c8e..531aa8adc06c 100644
@@ -498,11 +498,7 @@ vhost_user_reconnect_init(void)
 {
 	int ret;
 
-	ret = pthread_mutex_init(&reconn_list.mutex, NULL);
-	if (ret < 0) {
-		VHOST_CONFIG_LOG("thread", ERR, "%s: failed to initialize mutex", __func__);
-		return ret;
-	}
+	pthread_mutex_init(&reconn_list.mutex, NULL);
 	TAILQ_INIT(&reconn_list.head);
 
 	ret = rte_thread_create_internal_control(&reconn_tid, "vhost-reco",
@@ -921,11 +917,7 @@ rte_vhost_driver_register(const char *path, uint64_t flags)
 		goto out;
 	}
 	TAILQ_INIT(&vsocket->conn_list);
-	ret = pthread_mutex_init(&vsocket->conn_mutex, NULL);
-	if (ret) {
-		VHOST_CONFIG_LOG(path, ERR, "failed to init connection mutex");
-		goto out_free;
-	}
+	pthread_mutex_init(&vsocket->conn_mutex, NULL);
 
 	if (!strncmp("/dev/vduse/", path, strlen("/dev/vduse/")))
 		vsocket->is_vduse = true;
@@ -1034,8 +1026,6 @@ rte_vhost_driver_register(const char *path, uint64_t flags)
 	if (pthread_mutex_destroy(&vsocket->conn_mutex)) {
 		VHOST_CONFIG_LOG(path, ERR, "failed to destroy connection mutex");
 	}
-out_free:
-	vhost_user_socket_mem_free(vsocket);
 out:
 	pthread_mutex_unlock(&vhost_user.mutex);
 
Signature · 1 line
2.30.2
#7 lore raw

v2 cover remove check around pthread_mutex_init()

In reply to Ariel Otilibili

Hello,

This series addresses Bugzilla ID 1586; the man says

Quoted 2 lines

pthread_mutex_init always returns 0. The other mutex functions return 0 on success and a non-zero error code on error.

Meaning, the check around around pthread_mutex_init() is needless.

Thank you,

Bugzilla ID: 1586

---
v2
* fix build issues
v1 (https://inbox.dpdk.org/dev/[email protected]/#t)

Ariel Otilibili (6):
raw/ifpga: remove check around pthread_mutex_init() net/bnxt: remove check around pthread_mutex_init() common/cnxk: remove check around pthread_mutex_init() net/failsafe: remove check around pthread_mutex_init() net/hinic: remove check around pthread_mutex_init() lib/vhost: remove check around pthread_mutex_init()

 drivers/common/cnxk/roc_bphy_cgx.c            |  5 +--
 drivers/net/bnxt/bnxt_ethdev.c                | 40 ++++---------------
 drivers/net/bnxt/bnxt_txq.c                   |  6 +--
 drivers/net/bnxt/tf_ulp/bnxt_ulp.c            |  8 +---
 drivers/net/bnxt/tf_ulp/bnxt_ulp_tf.c         |  6 +--
 drivers/net/bnxt/tf_ulp/bnxt_ulp_tfc.c        |  6 +--
 drivers/net/bnxt/tf_ulp/ulp_fc_mgr.c          |  6 +--
 drivers/net/bnxt/tf_ulp/ulp_ha_mgr.c          |  6 +--
 drivers/net/failsafe/failsafe.c               |  6 +--
 drivers/net/hinic/base/hinic_compat.h         |  8 +---
 drivers/raw/ifpga/base/opae_intel_max10.c     |  5 +--
 drivers/raw/ifpga/base/opae_spi_transaction.c | 11 ++---
 lib/vhost/socket.c                            | 14 +------
 13 files changed, 24 insertions(+), 103 deletions(-)
Signature · 1 line
2.30.2
#8 lore raw

PATCH v2 1/6 raw/ifpga: remove check around pthread_mutex_init()

Quoted 2 lines

pthread_mutex_init always returns 0. The other mutex functions return 0 on success and a non-zero error code on error.

Bugzilla ID: 1586

---
 drivers/raw/ifpga/base/opae_intel_max10.c     |  5 +----
 drivers/raw/ifpga/base/opae_spi_transaction.c | 11 +++--------
 2 files changed, 4 insertions(+), 12 deletions(-)
drivers/raw/ifpga/base/opae_intel_max10.c +1 -4
index d5a9ceb6e355..58c884a8d8e1 100644
@@ -1486,10 +1486,7 @@ intel_max10_device_init(struct intel_max10_device *dev)
 		if (ret)
 			return ret;
 
-		ret = pthread_mutex_init(&dev->bmc_ops.lock, NULL);
-		if (ret)
-			return ret;
-
+		pthread_mutex_init(&dev->bmc_ops.lock, NULL);
 		if (!dev->bmc_ops.mutex)
 			dev->bmc_ops.mutex = &dev->bmc_ops.lock;
 	}
drivers/raw/ifpga/base/opae_spi_transaction.c +3 -8
index 21015eb95ef5..49d51c7bc3ab 100644
@@ -494,7 +494,6 @@ struct spi_transaction_dev *spi_transaction_init(struct altera_spi_device *dev,
 		int chipselect)
 {
 	struct spi_transaction_dev *spi_tran_dev;
-	int ret;
 
 	spi_tran_dev = opae_malloc(sizeof(struct spi_transaction_dev));
 	if (!spi_tran_dev)
@@ -507,11 +506,7 @@ struct spi_transaction_dev *spi_transaction_init(struct altera_spi_device *dev,
 	if (!spi_tran_dev->buffer)
 		goto err;
 
-	ret = pthread_mutex_init(&spi_tran_dev->lock, NULL);
-	if (ret) {
-		dev_err(spi_tran_dev, "fail to init mutex lock\n");
-		goto err;
-	}
+	pthread_mutex_init(&spi_tran_dev->lock, NULL);
 	if (dev->mutex) {
 		dev_info(NULL, "use multi-process mutex in spi\n");
 		spi_tran_dev->mutex = dev->mutex;
@@ -523,8 +518,8 @@ struct spi_transaction_dev *spi_transaction_init(struct altera_spi_device *dev,
 	return spi_tran_dev;
 
 err:
-	opae_free(spi_tran_dev);
-	return NULL;
+       opae_free(spi_tran_dev);
+       return NULL;
 }
 
 void spi_transaction_remove(struct spi_transaction_dev *dev)
Signature · 1 line
2.30.2
#9 lore raw

PATCH v2 2/6 net/bnxt: remove check around pthread_mutex_init()

In reply to Ariel Otilibili
Quoted 2 lines

pthread_mutex_init always returns 0. The other mutex functions return 0 on success and a non-zero error code on error.

Bugzilla ID: 1586

---
 drivers/net/bnxt/bnxt_ethdev.c         | 40 ++++++--------------------
 drivers/net/bnxt/bnxt_txq.c            |  6 +---
 drivers/net/bnxt/tf_ulp/bnxt_ulp.c     |  8 +-----
 drivers/net/bnxt/tf_ulp/bnxt_ulp_tf.c  |  6 +---
 drivers/net/bnxt/tf_ulp/bnxt_ulp_tfc.c |  6 +---
 drivers/net/bnxt/tf_ulp/ulp_fc_mgr.c   |  6 +---
 drivers/net/bnxt/tf_ulp/ulp_ha_mgr.c   |  6 +---
 7 files changed, 14 insertions(+), 64 deletions(-)
drivers/net/bnxt/bnxt_ethdev.c +8 -32
index ef8a928c9170..3a88cdc94128 100644
@@ -5821,31 +5821,12 @@ static int bnxt_get_config(struct bnxt *bp)
 static int
 bnxt_init_locks(struct bnxt *bp)
 {
-	int err;
+	pthread_mutex_init(&bp->flow_lock, NULL);
+	pthread_mutex_init(&bp->def_cp_lock, NULL);
+	pthread_mutex_init(&bp->health_check_lock, NULL);
+	pthread_mutex_init(&bp->err_recovery_lock, NULL);
 
-	err = pthread_mutex_init(&bp->flow_lock, NULL);
-	if (err) {
-		PMD_DRV_LOG_LINE(ERR, "Unable to initialize flow_lock");
-		return err;
-	}
-
-	err = pthread_mutex_init(&bp->def_cp_lock, NULL);
-	if (err) {
-		PMD_DRV_LOG_LINE(ERR, "Unable to initialize def_cp_lock");
-		return err;
-	}
-
-	err = pthread_mutex_init(&bp->health_check_lock, NULL);
-	if (err) {
-		PMD_DRV_LOG_LINE(ERR, "Unable to initialize health_check_lock");
-		return err;
-	}
-
-	err = pthread_mutex_init(&bp->err_recovery_lock, NULL);
-	if (err)
-		PMD_DRV_LOG_LINE(ERR, "Unable to initialize err_recovery_lock");
-
-	return err;
+	return 0;
 }
 
 /* This should be called after we have queried trusted VF cap */
@@ -6746,7 +6727,7 @@ static void bnxt_free_rep_info(struct bnxt *bp)
 
 static int bnxt_init_rep_info(struct bnxt *bp)
 {
-	int i = 0, rc;
+	int i = 0;
 
 	if (bp->rep_info)
 		return 0;
@@ -6770,14 +6751,9 @@ static int bnxt_init_rep_info(struct bnxt *bp)
 	for (i = 0; i < BNXT_MAX_CFA_CODE; i++)
 		bp->cfa_code_map[i] = BNXT_VF_IDX_INVALID;
 
-	rc = pthread_mutex_init(&bp->rep_info->vfr_start_lock, NULL);
-	if (rc) {
-		PMD_DRV_LOG_LINE(ERR, "Unable to initialize vfr_start_lock");
-		bnxt_free_rep_info(bp);
-		return rc;
-	}
+	pthread_mutex_init(&bp->rep_info->vfr_start_lock, NULL);
 
-	return rc;
+	return 0;
 }
 
 static int bnxt_rep_port_probe(struct rte_pci_device *pci_dev,
drivers/net/bnxt/bnxt_txq.c +1 -5
index c8649359923f..ab561585d771 100644
@@ -198,11 +198,7 @@ int bnxt_tx_queue_setup_op(struct rte_eth_dev *eth_dev,
 		goto err;
 	}
 
-	rc = pthread_mutex_init(&txq->txq_lock, NULL);
-	if (rc != 0) {
-		PMD_DRV_LOG_LINE(ERR, "TxQ mutex init failed!");
-		goto err;
-	}
+	pthread_mutex_init(&txq->txq_lock, NULL);
 	return 0;
 err:
 	bnxt_tx_queue_release_op(eth_dev, queue_idx);
drivers/net/bnxt/tf_ulp/bnxt_ulp.c +1 -7
index 1bfc88cf79ef..0c03ae7a8349 100644
@@ -188,7 +188,6 @@ ulp_session_init(struct bnxt *bp,
 	struct rte_pci_device		*pci_dev;
 	struct rte_pci_addr		*pci_addr;
 	struct bnxt_ulp_session_state	*session;
-	int rc = 0;
 
 	if (!bp)
 		return NULL;
@@ -215,12 +214,7 @@ ulp_session_init(struct bnxt *bp,
 			session->pci_info.domain = pci_addr->domain;
 			session->pci_info.bus = pci_addr->bus;
 			memcpy(session->dsn, bp->dsn, sizeof(session->dsn));
-			rc = pthread_mutex_init(&session->bnxt_ulp_mutex, NULL);
-			if (rc) {
-				BNXT_DRV_DBG(ERR, "mutex create failed\n");
-				pthread_mutex_unlock(&bnxt_ulp_global_mutex);
-				return NULL;
-			}
+			pthread_mutex_init(&session->bnxt_ulp_mutex, NULL);
 			STAILQ_INSERT_TAIL(&bnxt_ulp_session_list,
 					   session, next);
 		}
drivers/net/bnxt/tf_ulp/bnxt_ulp_tf.c +1 -5
index fa7e8fe00077..4a1ccfa2a36d 100644
@@ -1472,11 +1472,7 @@ ulp_tf_init(struct bnxt *bp,
 		goto jump_to_error;
 	}
 
-	rc = pthread_mutex_init(&bp->ulp_ctx->cfg_data->flow_db_lock, NULL);
-	if (rc) {
-		BNXT_DRV_DBG(ERR, "Unable to initialize flow db lock\n");
-		goto jump_to_error;
-	}
+	pthread_mutex_init(&bp->ulp_ctx->cfg_data->flow_db_lock, NULL);
 
 	/* Initialize ulp dparms with values devargs passed */
 	rc = ulp_tf_dparms_init(bp, bp->ulp_ctx);
drivers/net/bnxt/tf_ulp/bnxt_ulp_tfc.c +1 -5
index 6d7ec0ffec79..508c194d0490 100644
@@ -993,11 +993,7 @@ ulp_tfc_init(struct bnxt *bp,
 		goto jump_to_error;
 	}
 
-	rc = pthread_mutex_init(&bp->ulp_ctx->cfg_data->flow_db_lock, NULL);
-	if (rc) {
-		BNXT_DRV_DBG(ERR, "Unable to initialize flow db lock\n");
-		goto jump_to_error;
-	}
+	pthread_mutex_init(&bp->ulp_ctx->cfg_data->flow_db_lock, NULL);
 
 	rc = ulp_tfc_dparms_init(bp, bp->ulp_ctx, ulp_dev_id);
 	if (rc) {
drivers/net/bnxt/tf_ulp/ulp_fc_mgr.c +1 -5
index 67489b76f390..f9d069f4e17e 100644
@@ -129,11 +129,7 @@ ulp_fc_mgr_init(struct bnxt_ulp_context *ctxt)
 	ulp_fc_info->fc_ops = fc_ops;
 	ulp_fc_info->flags = flags;
 
-	rc = pthread_mutex_init(&ulp_fc_info->fc_lock, NULL);
-	if (rc) {
-		BNXT_DRV_DBG(ERR, "Failed to initialize fc mutex\n");
-		goto error;
-	}
+	pthread_mutex_init(&ulp_fc_info->fc_lock, NULL);
 
 	/* Add the FC info tbl to the ulp context. */
 	bnxt_ulp_cntxt_ptr2_fc_info_set(ctxt, ulp_fc_info);
drivers/net/bnxt/tf_ulp/ulp_ha_mgr.c +1 -5
index 3c75a6b43721..7b7c10d3602e 100644
@@ -412,11 +412,7 @@ ulp_ha_mgr_init(struct bnxt_ulp_context *ulp_ctx)
 	/* Add the HA info tbl to the ulp context. */
 	bnxt_ulp_cntxt_ptr2_ha_info_set(ulp_ctx, ha_info);
 
-	rc = pthread_mutex_init(&ha_info->ha_lock, NULL);
-	if (rc) {
-		PMD_DRV_LOG_LINE(ERR, "Failed to initialize ha mutex");
-		goto cleanup;
-	}
+	pthread_mutex_init(&ha_info->ha_lock, NULL);
 	rc = ulp_ha_mgr_timer_start(ulp_ctx->cfg_data);
 	if (rc) {
 		PMD_DRV_LOG_LINE(ERR, "Unable to start timer CB");
Signature · 1 line
2.30.2
#10 lore raw

PATCH v2 3/6 common/cnxk: remove check around pthread_mutex_init()

In reply to Ariel Otilibili
Quoted 2 lines

pthread_mutex_init always returns 0. The other mutex functions return 0 on success and a non-zero error code on error.

Bugzilla ID: 1586

---
 drivers/common/cnxk/roc_bphy_cgx.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/common/cnxk/roc_bphy_cgx.c +1 -4
index 4f43605e1031..882cf654743b 100644
@@ -189,14 +189,11 @@ int
 roc_bphy_cgx_dev_init(struct roc_bphy_cgx *roc_cgx)
 {
 	uint64_t val;
-	int ret;
 
 	if (!roc_cgx || !roc_cgx->bar0_va || !roc_cgx->bar0_pa)
 		return -EINVAL;
 
-	ret = pthread_mutex_init(&roc_cgx->lock, NULL);
-	if (ret)
-		return ret;
+	pthread_mutex_init(&roc_cgx->lock, NULL);
 
 	val = roc_bphy_cgx_read(roc_cgx, 0, CGX_CMRX_RX_LMACS);
 	val = FIELD_GET(CGX_CMRX_RX_LMACS_LMACS, val);
Signature · 1 line
2.30.2
#11 lore raw

PATCH v2 4/6 net/failsafe: remove check around pthread_mutex_init()

In reply to Ariel Otilibili
Quoted 2 lines

pthread_mutex_init always returns 0. The other mutex functions return 0 on success and a non-zero error code on error.

Bugzilla ID: 1586

---
 drivers/net/failsafe/failsafe.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)
drivers/net/failsafe/failsafe.c +1 -5
index 32811403b4c8..e1c77cdf4fd1 100644
@@ -147,11 +147,7 @@ fs_mutex_init(struct fs_priv *priv)
 		ERROR("Cannot set mutex type - %s", strerror(ret));
 		return ret;
 	}
-	ret = pthread_mutex_init(&priv->hotplug_mutex, &attr);
-	if (ret) {
-		ERROR("Cannot initiate mutex - %s", strerror(ret));
-		return ret;
-	}
+	pthread_mutex_init(&priv->hotplug_mutex, &attr);
 	return 0;
 }
 
Signature · 1 line
2.30.2
#12 lore raw

PATCH v2 5/6 net/hinic: remove check around pthread_mutex_init()

In reply to Ariel Otilibili
Quoted 2 lines

pthread_mutex_init always returns 0. The other mutex functions return 0 on success and a non-zero error code on error.

Bugzilla ID: 1586

---
 drivers/net/hinic/base/hinic_compat.h | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)
drivers/net/hinic/base/hinic_compat.h +2 -6
index ab9d1b9a0214..8f5763fbfc9d 100644
@@ -200,13 +200,9 @@ static inline u16 ilog2(u32 n)
 static inline int hinic_mutex_init(pthread_mutex_t *pthreadmutex,
 					const pthread_mutexattr_t *mattr)
 {
-	int err;
-
-	err = pthread_mutex_init(pthreadmutex, mattr);
-	if (unlikely(err))
-		PMD_DRV_LOG(ERR, "Fail to initialize mutex, error: %d", err);
+	pthread_mutex_init(pthreadmutex, mattr);
 
-	return err;
+	return 0;
 }
 
 static inline int hinic_mutex_destroy(pthread_mutex_t *pthreadmutex)
Signature · 1 line
2.30.2
#13 lore raw

PATCH v2 6/6 lib/vhost: remove check around pthread_mutex_init()

In reply to Ariel Otilibili
Quoted 2 lines

pthread_mutex_init always returns 0. The other mutex functions return 0 on success and a non-zero error code on error.

Bugzilla ID: 1586

---
 lib/vhost/socket.c | 14 ++------------
 1 file changed, 2 insertions(+), 12 deletions(-)
lib/vhost/socket.c +2 -12
index d29d15494c8e..531aa8adc06c 100644
@@ -498,11 +498,7 @@ vhost_user_reconnect_init(void)
 {
 	int ret;
 
-	ret = pthread_mutex_init(&reconn_list.mutex, NULL);
-	if (ret < 0) {
-		VHOST_CONFIG_LOG("thread", ERR, "%s: failed to initialize mutex", __func__);
-		return ret;
-	}
+	pthread_mutex_init(&reconn_list.mutex, NULL);
 	TAILQ_INIT(&reconn_list.head);
 
 	ret = rte_thread_create_internal_control(&reconn_tid, "vhost-reco",
@@ -921,11 +917,7 @@ rte_vhost_driver_register(const char *path, uint64_t flags)
 		goto out;
 	}
 	TAILQ_INIT(&vsocket->conn_list);
-	ret = pthread_mutex_init(&vsocket->conn_mutex, NULL);
-	if (ret) {
-		VHOST_CONFIG_LOG(path, ERR, "failed to init connection mutex");
-		goto out_free;
-	}
+	pthread_mutex_init(&vsocket->conn_mutex, NULL);
 
 	if (!strncmp("/dev/vduse/", path, strlen("/dev/vduse/")))
 		vsocket->is_vduse = true;
@@ -1034,8 +1026,6 @@ rte_vhost_driver_register(const char *path, uint64_t flags)
 	if (pthread_mutex_destroy(&vsocket->conn_mutex)) {
 		VHOST_CONFIG_LOG(path, ERR, "failed to destroy connection mutex");
 	}
-out_free:
-	vhost_user_socket_mem_free(vsocket);
 out:
 	pthread_mutex_unlock(&vhost_user.mutex);
 
Signature · 1 line
2.30.2
#14 lore raw

v3 cover remove check around pthread_mutex_init()

In reply to Ariel Otilibili

Hello,

This series addresses Bugzilla ID 1586; the man says

Quoted 2 lines

pthread_mutex_init always returns 0. The other mutex functions return 0 on success and a non-zero error code on error.

Meaning, the check around around pthread_mutex_init() is needless.

Thank you,

Bugzilla ID: 1586

---
v3
* fix style issues
v2 (https://inbox.dpdk.org/dev/[email protected]/)
* fix build issues
v1 (https://inbox.dpdk.org/dev/[email protected]/#t)

Ariel Otilibili (6):
raw/ifpga: remove check around pthread_mutex_init() net/bnxt: remove check around pthread_mutex_init() common/cnxk: remove check around pthread_mutex_init() net/failsafe: remove check around pthread_mutex_init() net/hinic: remove check around pthread_mutex_init() lib/vhost: remove check around pthread_mutex_init()

 drivers/common/cnxk/roc_bphy_cgx.c            |  5 +--
 drivers/net/bnxt/bnxt_ethdev.c                | 40 ++++---------------
 drivers/net/bnxt/bnxt_txq.c                   |  6 +--
 drivers/net/bnxt/tf_ulp/bnxt_ulp.c            |  8 +---
 drivers/net/bnxt/tf_ulp/bnxt_ulp_tf.c         |  6 +--
 drivers/net/bnxt/tf_ulp/bnxt_ulp_tfc.c        |  6 +--
 drivers/net/bnxt/tf_ulp/ulp_fc_mgr.c          |  6 +--
 drivers/net/bnxt/tf_ulp/ulp_ha_mgr.c          |  6 +--
 drivers/net/failsafe/failsafe.c               |  6 +--
 drivers/net/hinic/base/hinic_compat.h         |  8 +---
 drivers/raw/ifpga/base/opae_intel_max10.c     |  5 +--
 drivers/raw/ifpga/base/opae_spi_transaction.c |  7 +---
 lib/vhost/socket.c                            | 14 +------
 13 files changed, 22 insertions(+), 101 deletions(-)
Signature · 1 line
2.30.2
#15 lore raw

PATCH v3 1/6 raw/ifpga: remove check around pthread_mutex_init()

Quoted 2 lines

pthread_mutex_init always returns 0. The other mutex functions return 0 on success and a non-zero error code on error.

Bugzilla ID: 1586

---
 drivers/raw/ifpga/base/opae_intel_max10.c     | 5 +----
 drivers/raw/ifpga/base/opae_spi_transaction.c | 7 +------
 2 files changed, 2 insertions(+), 10 deletions(-)
drivers/raw/ifpga/base/opae_intel_max10.c +1 -4
index d5a9ceb6e355..58c884a8d8e1 100644
@@ -1486,10 +1486,7 @@ intel_max10_device_init(struct intel_max10_device *dev)
 		if (ret)
 			return ret;
 
-		ret = pthread_mutex_init(&dev->bmc_ops.lock, NULL);
-		if (ret)
-			return ret;
-
+		pthread_mutex_init(&dev->bmc_ops.lock, NULL);
 		if (!dev->bmc_ops.mutex)
 			dev->bmc_ops.mutex = &dev->bmc_ops.lock;
 	}
drivers/raw/ifpga/base/opae_spi_transaction.c +1 -6
index 21015eb95ef5..14ea93cb43df 100644
@@ -494,7 +494,6 @@ struct spi_transaction_dev *spi_transaction_init(struct altera_spi_device *dev,
 		int chipselect)
 {
 	struct spi_transaction_dev *spi_tran_dev;
-	int ret;
 
 	spi_tran_dev = opae_malloc(sizeof(struct spi_transaction_dev));
 	if (!spi_tran_dev)
@@ -507,11 +506,7 @@ struct spi_transaction_dev *spi_transaction_init(struct altera_spi_device *dev,
 	if (!spi_tran_dev->buffer)
 		goto err;
 
-	ret = pthread_mutex_init(&spi_tran_dev->lock, NULL);
-	if (ret) {
-		dev_err(spi_tran_dev, "fail to init mutex lock\n");
-		goto err;
-	}
+	pthread_mutex_init(&spi_tran_dev->lock, NULL);
 	if (dev->mutex) {
 		dev_info(NULL, "use multi-process mutex in spi\n");
 		spi_tran_dev->mutex = dev->mutex;
Signature · 1 line
2.30.2
#16 lore raw

PATCH v3 2/6 net/bnxt: remove check around pthread_mutex_init()

In reply to Ariel Otilibili
Quoted 2 lines

pthread_mutex_init always returns 0. The other mutex functions return 0 on success and a non-zero error code on error.

Bugzilla ID: 1586

---
 drivers/net/bnxt/bnxt_ethdev.c         | 40 ++++++--------------------
 drivers/net/bnxt/bnxt_txq.c            |  6 +---
 drivers/net/bnxt/tf_ulp/bnxt_ulp.c     |  8 +-----
 drivers/net/bnxt/tf_ulp/bnxt_ulp_tf.c  |  6 +---
 drivers/net/bnxt/tf_ulp/bnxt_ulp_tfc.c |  6 +---
 drivers/net/bnxt/tf_ulp/ulp_fc_mgr.c   |  6 +---
 drivers/net/bnxt/tf_ulp/ulp_ha_mgr.c   |  6 +---
 7 files changed, 14 insertions(+), 64 deletions(-)
drivers/net/bnxt/bnxt_ethdev.c +8 -32
index ef8a928c9170..3a88cdc94128 100644
@@ -5821,31 +5821,12 @@ static int bnxt_get_config(struct bnxt *bp)
 static int
 bnxt_init_locks(struct bnxt *bp)
 {
-	int err;
+	pthread_mutex_init(&bp->flow_lock, NULL);
+	pthread_mutex_init(&bp->def_cp_lock, NULL);
+	pthread_mutex_init(&bp->health_check_lock, NULL);
+	pthread_mutex_init(&bp->err_recovery_lock, NULL);
 
-	err = pthread_mutex_init(&bp->flow_lock, NULL);
-	if (err) {
-		PMD_DRV_LOG_LINE(ERR, "Unable to initialize flow_lock");
-		return err;
-	}
-
-	err = pthread_mutex_init(&bp->def_cp_lock, NULL);
-	if (err) {
-		PMD_DRV_LOG_LINE(ERR, "Unable to initialize def_cp_lock");
-		return err;
-	}
-
-	err = pthread_mutex_init(&bp->health_check_lock, NULL);
-	if (err) {
-		PMD_DRV_LOG_LINE(ERR, "Unable to initialize health_check_lock");
-		return err;
-	}
-
-	err = pthread_mutex_init(&bp->err_recovery_lock, NULL);
-	if (err)
-		PMD_DRV_LOG_LINE(ERR, "Unable to initialize err_recovery_lock");
-
-	return err;
+	return 0;
 }
 
 /* This should be called after we have queried trusted VF cap */
@@ -6746,7 +6727,7 @@ static void bnxt_free_rep_info(struct bnxt *bp)
 
 static int bnxt_init_rep_info(struct bnxt *bp)
 {
-	int i = 0, rc;
+	int i = 0;
 
 	if (bp->rep_info)
 		return 0;
@@ -6770,14 +6751,9 @@ static int bnxt_init_rep_info(struct bnxt *bp)
 	for (i = 0; i < BNXT_MAX_CFA_CODE; i++)
 		bp->cfa_code_map[i] = BNXT_VF_IDX_INVALID;
 
-	rc = pthread_mutex_init(&bp->rep_info->vfr_start_lock, NULL);
-	if (rc) {
-		PMD_DRV_LOG_LINE(ERR, "Unable to initialize vfr_start_lock");
-		bnxt_free_rep_info(bp);
-		return rc;
-	}
+	pthread_mutex_init(&bp->rep_info->vfr_start_lock, NULL);
 
-	return rc;
+	return 0;
 }
 
 static int bnxt_rep_port_probe(struct rte_pci_device *pci_dev,
drivers/net/bnxt/bnxt_txq.c +1 -5
index c8649359923f..ab561585d771 100644
@@ -198,11 +198,7 @@ int bnxt_tx_queue_setup_op(struct rte_eth_dev *eth_dev,
 		goto err;
 	}
 
-	rc = pthread_mutex_init(&txq->txq_lock, NULL);
-	if (rc != 0) {
-		PMD_DRV_LOG_LINE(ERR, "TxQ mutex init failed!");
-		goto err;
-	}
+	pthread_mutex_init(&txq->txq_lock, NULL);
 	return 0;
 err:
 	bnxt_tx_queue_release_op(eth_dev, queue_idx);
drivers/net/bnxt/tf_ulp/bnxt_ulp.c +1 -7
index 1bfc88cf79ef..0c03ae7a8349 100644
@@ -188,7 +188,6 @@ ulp_session_init(struct bnxt *bp,
 	struct rte_pci_device		*pci_dev;
 	struct rte_pci_addr		*pci_addr;
 	struct bnxt_ulp_session_state	*session;
-	int rc = 0;
 
 	if (!bp)
 		return NULL;
@@ -215,12 +214,7 @@ ulp_session_init(struct bnxt *bp,
 			session->pci_info.domain = pci_addr->domain;
 			session->pci_info.bus = pci_addr->bus;
 			memcpy(session->dsn, bp->dsn, sizeof(session->dsn));
-			rc = pthread_mutex_init(&session->bnxt_ulp_mutex, NULL);
-			if (rc) {
-				BNXT_DRV_DBG(ERR, "mutex create failed\n");
-				pthread_mutex_unlock(&bnxt_ulp_global_mutex);
-				return NULL;
-			}
+			pthread_mutex_init(&session->bnxt_ulp_mutex, NULL);
 			STAILQ_INSERT_TAIL(&bnxt_ulp_session_list,
 					   session, next);
 		}
drivers/net/bnxt/tf_ulp/bnxt_ulp_tf.c +1 -5
index fa7e8fe00077..4a1ccfa2a36d 100644
@@ -1472,11 +1472,7 @@ ulp_tf_init(struct bnxt *bp,
 		goto jump_to_error;
 	}
 
-	rc = pthread_mutex_init(&bp->ulp_ctx->cfg_data->flow_db_lock, NULL);
-	if (rc) {
-		BNXT_DRV_DBG(ERR, "Unable to initialize flow db lock\n");
-		goto jump_to_error;
-	}
+	pthread_mutex_init(&bp->ulp_ctx->cfg_data->flow_db_lock, NULL);
 
 	/* Initialize ulp dparms with values devargs passed */
 	rc = ulp_tf_dparms_init(bp, bp->ulp_ctx);
drivers/net/bnxt/tf_ulp/bnxt_ulp_tfc.c +1 -5
index 6d7ec0ffec79..508c194d0490 100644
@@ -993,11 +993,7 @@ ulp_tfc_init(struct bnxt *bp,
 		goto jump_to_error;
 	}
 
-	rc = pthread_mutex_init(&bp->ulp_ctx->cfg_data->flow_db_lock, NULL);
-	if (rc) {
-		BNXT_DRV_DBG(ERR, "Unable to initialize flow db lock\n");
-		goto jump_to_error;
-	}
+	pthread_mutex_init(&bp->ulp_ctx->cfg_data->flow_db_lock, NULL);
 
 	rc = ulp_tfc_dparms_init(bp, bp->ulp_ctx, ulp_dev_id);
 	if (rc) {
drivers/net/bnxt/tf_ulp/ulp_fc_mgr.c +1 -5
index 67489b76f390..f9d069f4e17e 100644
@@ -129,11 +129,7 @@ ulp_fc_mgr_init(struct bnxt_ulp_context *ctxt)
 	ulp_fc_info->fc_ops = fc_ops;
 	ulp_fc_info->flags = flags;
 
-	rc = pthread_mutex_init(&ulp_fc_info->fc_lock, NULL);
-	if (rc) {
-		BNXT_DRV_DBG(ERR, "Failed to initialize fc mutex\n");
-		goto error;
-	}
+	pthread_mutex_init(&ulp_fc_info->fc_lock, NULL);
 
 	/* Add the FC info tbl to the ulp context. */
 	bnxt_ulp_cntxt_ptr2_fc_info_set(ctxt, ulp_fc_info);
drivers/net/bnxt/tf_ulp/ulp_ha_mgr.c +1 -5
index 3c75a6b43721..7b7c10d3602e 100644
@@ -412,11 +412,7 @@ ulp_ha_mgr_init(struct bnxt_ulp_context *ulp_ctx)
 	/* Add the HA info tbl to the ulp context. */
 	bnxt_ulp_cntxt_ptr2_ha_info_set(ulp_ctx, ha_info);
 
-	rc = pthread_mutex_init(&ha_info->ha_lock, NULL);
-	if (rc) {
-		PMD_DRV_LOG_LINE(ERR, "Failed to initialize ha mutex");
-		goto cleanup;
-	}
+	pthread_mutex_init(&ha_info->ha_lock, NULL);
 	rc = ulp_ha_mgr_timer_start(ulp_ctx->cfg_data);
 	if (rc) {
 		PMD_DRV_LOG_LINE(ERR, "Unable to start timer CB");
Signature · 1 line
2.30.2
#17 lore raw

PATCH v3 3/6 common/cnxk: remove check around pthread_mutex_init()

In reply to Ariel Otilibili
Quoted 2 lines

pthread_mutex_init always returns 0. The other mutex functions return 0 on success and a non-zero error code on error.

Bugzilla ID: 1586

---
 drivers/common/cnxk/roc_bphy_cgx.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/common/cnxk/roc_bphy_cgx.c +1 -4
index 4f43605e1031..882cf654743b 100644
@@ -189,14 +189,11 @@ int
 roc_bphy_cgx_dev_init(struct roc_bphy_cgx *roc_cgx)
 {
 	uint64_t val;
-	int ret;
 
 	if (!roc_cgx || !roc_cgx->bar0_va || !roc_cgx->bar0_pa)
 		return -EINVAL;
 
-	ret = pthread_mutex_init(&roc_cgx->lock, NULL);
-	if (ret)
-		return ret;
+	pthread_mutex_init(&roc_cgx->lock, NULL);
 
 	val = roc_bphy_cgx_read(roc_cgx, 0, CGX_CMRX_RX_LMACS);
 	val = FIELD_GET(CGX_CMRX_RX_LMACS_LMACS, val);
Signature · 1 line
2.30.2
#18 lore raw

PATCH v3 4/6 net/failsafe: remove check around pthread_mutex_init()

In reply to Ariel Otilibili
Quoted 2 lines

pthread_mutex_init always returns 0. The other mutex functions return 0 on success and a non-zero error code on error.

Bugzilla ID: 1586

---
 drivers/net/failsafe/failsafe.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)
drivers/net/failsafe/failsafe.c +1 -5
index 32811403b4c8..e1c77cdf4fd1 100644
@@ -147,11 +147,7 @@ fs_mutex_init(struct fs_priv *priv)
 		ERROR("Cannot set mutex type - %s", strerror(ret));
 		return ret;
 	}
-	ret = pthread_mutex_init(&priv->hotplug_mutex, &attr);
-	if (ret) {
-		ERROR("Cannot initiate mutex - %s", strerror(ret));
-		return ret;
-	}
+	pthread_mutex_init(&priv->hotplug_mutex, &attr);
 	return 0;
 }
 
Signature · 1 line
2.30.2
#19 lore raw

Re: [PATCH v3 4/6] net/failsafe: remove check around pthread_mutex_init()

Quoted 5 lines · On Sun, 12 Jan 2025 21:20:19 +0100 Ariel Otilibili <[email protected]> wrote:
drivers/net/failsafe/failsafe.c +0 -0
index 32811403b4c8..e1c77cdf4fd1 100644

drivers/net/failsafe/failsafe.c fs_mutex_init(struct fs_priv *priv) · line 151

Quoted 10 lines
drivers/net/failsafe/failsafe.c +1 -5
@@ -147,11 +147,7 @@ fs_mutex_init(struct fs_priv *priv)
 		ERROR("Cannot set mutex type - %s", strerror(ret));
 		return ret;
 	}
-	ret = pthread_mutex_init(&priv->hotplug_mutex, &attr);
-	if (ret) {
-		ERROR("Cannot initiate mutex - %s", strerror(ret));
-		return ret;
-	}
+	pthread_mutex_init(&priv->hotplug_mutex, &attr);
 	return 0;

Could be a tail call here.

	return pthread_mutex_init(&priv->hotplug_mutex, &attr);
#20 lore raw

PATCH v3 5/6 net/hinic: remove check around pthread_mutex_init()

In reply to Ariel Otilibili
Quoted 2 lines

pthread_mutex_init always returns 0. The other mutex functions return 0 on success and a non-zero error code on error.

Bugzilla ID: 1586

---
 drivers/net/hinic/base/hinic_compat.h | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)
drivers/net/hinic/base/hinic_compat.h +2 -6
index ab9d1b9a0214..8f5763fbfc9d 100644
@@ -200,13 +200,9 @@ static inline u16 ilog2(u32 n)
 static inline int hinic_mutex_init(pthread_mutex_t *pthreadmutex,
 					const pthread_mutexattr_t *mattr)
 {
-	int err;
-
-	err = pthread_mutex_init(pthreadmutex, mattr);
-	if (unlikely(err))
-		PMD_DRV_LOG(ERR, "Fail to initialize mutex, error: %d", err);
+	pthread_mutex_init(pthreadmutex, mattr);
 
-	return err;
+	return 0;
 }
 
 static inline int hinic_mutex_destroy(pthread_mutex_t *pthreadmutex)
Signature · 1 line
2.30.2
#21 lore raw

Re: [PATCH v3 5/6] net/hinic: remove check around pthread_mutex_init()

Quoted 8 lines · On Sun, 12 Jan 2025 21:20:20 +0100 Ariel Otilibili <[email protected]> wrote:
drivers/net/hinic/base/hinic_compat.h +0 -0
index ab9d1b9a0214..8f5763fbfc9d 100644
@@ -200,13 +200,9 @@ static inline u16 ilog2(u32 n)
 static inline int hinic_mutex_init(pthread_mutex_t *pthreadmutex,
 					const pthread_mutexattr_t *mattr)
 {

drivers/net/hinic/base/hinic_compat.h static inline u16 ilog2(u32 n) · line 206

Quoted 10 lines
drivers/net/hinic/base/hinic_compat.h +2 -6
-	int err;
-
-	err = pthread_mutex_init(pthreadmutex, mattr);
-	if (unlikely(err))
-		PMD_DRV_LOG(ERR, "Fail to initialize mutex, error: %d", err);
+	pthread_mutex_init(pthreadmutex, mattr);
 
-	return err;
+	return 0;
 }

Could be a tail call here, if you want.

	return pthread_mutex_init(pthradmutex, mattr);
#22 lore raw

PATCH v3 6/6 lib/vhost: remove check around pthread_mutex_init()

In reply to Ariel Otilibili
Quoted 2 lines

pthread_mutex_init always returns 0. The other mutex functions return 0 on success and a non-zero error code on error.

Bugzilla ID: 1586

---
 lib/vhost/socket.c | 14 ++------------
 1 file changed, 2 insertions(+), 12 deletions(-)
lib/vhost/socket.c +2 -12
index d29d15494c8e..531aa8adc06c 100644
@@ -498,11 +498,7 @@ vhost_user_reconnect_init(void)
 {
 	int ret;
 
-	ret = pthread_mutex_init(&reconn_list.mutex, NULL);
-	if (ret < 0) {
-		VHOST_CONFIG_LOG("thread", ERR, "%s: failed to initialize mutex", __func__);
-		return ret;
-	}
+	pthread_mutex_init(&reconn_list.mutex, NULL);
 	TAILQ_INIT(&reconn_list.head);
 
 	ret = rte_thread_create_internal_control(&reconn_tid, "vhost-reco",
@@ -921,11 +917,7 @@ rte_vhost_driver_register(const char *path, uint64_t flags)
 		goto out;
 	}
 	TAILQ_INIT(&vsocket->conn_list);
-	ret = pthread_mutex_init(&vsocket->conn_mutex, NULL);
-	if (ret) {
-		VHOST_CONFIG_LOG(path, ERR, "failed to init connection mutex");
-		goto out_free;
-	}
+	pthread_mutex_init(&vsocket->conn_mutex, NULL);
 
 	if (!strncmp("/dev/vduse/", path, strlen("/dev/vduse/")))
 		vsocket->is_vduse = true;
@@ -1034,8 +1026,6 @@ rte_vhost_driver_register(const char *path, uint64_t flags)
 	if (pthread_mutex_destroy(&vsocket->conn_mutex)) {
 		VHOST_CONFIG_LOG(path, ERR, "failed to destroy connection mutex");
 	}
-out_free:
-	vhost_user_socket_mem_free(vsocket);
 out:
 	pthread_mutex_unlock(&vhost_user.mutex);
 
Signature · 1 line
2.30.2
#23 lore raw
In reply to Ariel Otilibili
Quoted 7 lines · On Sun, 12 Jan 2025 21:20:15 +0100 Ariel Otilibili <[email protected]> wrote:

Hello,

This series addresses Bugzilla ID 1586; the man says

Quoted 2 lines

pthread_mutex_init always returns 0. The other mutex functions return 0 on success and a non-zero error code on error.

Quoted 6 lines

Meaning, the check around around pthread_mutex_init() is needless.

Thank you,

Bugzilla ID: 1586

LGTM

#25 lore raw

cover eal/linux: Remove unused values

In reply to Ariel Otilibili

Hello,

This patch clears out a static analysis warning.

Your feedback is much appreciated,

Ariel Otilibili (1):
eal/linux: Remove unused values

 lib/eal/linux/eal_dev.c | 3 ---
 1 file changed, 3 deletions(-)
Signature · 1 line
2.30.2
#26 lore raw

PATCH 1/1 eal/linux: Remove unused values

Found by static analysis:

In dev_uev_socket_fd_create(), fd is assigned before a return, and not used.

The same for the variables buf and i in dev_uev_parse().

Fixes c2bd9367e18f ("lib: remove direct access to interrupt handle")
Fixes 0d0f478d0483 ("eal/linux: add uevent parse and process")
---
 lib/eal/linux/eal_dev.c | 3 ---
 1 file changed, 3 deletions(-)
lib/eal/linux/eal_dev.c +0 -3
index e63f24d108c7..be97f56424de 100644
@@ -129,7 +129,6 @@ dev_uev_socket_fd_create(void)
 	return 0;
 err:
 	close(fd);
-	fd = -1;
 	return ret;
 }
 
@@ -165,8 +164,6 @@ dev_uev_parse(const char *buf, struct rte_dev_event *event, int length)
 		 * uevent from udev.
 		 */
 		if (!strncmp(buf, "libudev", 7)) {
-			buf += 7;
-			i += 7;
 			return -1;
 		}
 		if (!strncmp(buf, "ACTION=", 7)) {
Signature · 1 line
2.30.2
#27 lore raw

Re: [PATCH 1/1] eal/linux: Remove unused values

13/01/2025 18:19, Ariel Otilibili:

Quoted 11 lines

Found by static analysis:

In dev_uev_socket_fd_create(), fd is assigned before a return, and not used.

The same for the variables buf and i in dev_uev_parse().

Fixes c2bd9367e18f ("lib: remove direct access to interrupt handle")
Fixes 0d0f478d0483 ("eal/linux: add uevent parse and process")

Applied, thanks.

#28 lore raw

Re: [PATCH 1/1] eal/linux: Remove unused values

Hi Thomas,

Quoted 2 lines · Thomas Monjalon

Applied, thanks.

Thanks for the feedback. Have a good day.
Ariel

#29 lore raw

v4 cover remove check around pthread_mutex_init()

In reply to Ariel Otilibili

Hello,

This series addresses Bugzilla ID 1586; the man says

Quoted 2 lines

pthread_mutex_init always returns 0. The other mutex functions return 0 on success and a non-zero error code on error.

Meaning, the check around around pthread_mutex_init() is needless.

```
$ git grep -Pn '=\s?pthread_mutex_init\('
drivers/common/cnxk/roc_bphy_cgx.c:197: ret = pthread_mutex_init(&roc_cgx->lock, NULL);
drivers/net/bnxt/bnxt_ethdev.c:5826:    err = pthread_mutex_init(&bp->flow_lock, NULL);
drivers/net/bnxt/bnxt_ethdev.c:5832:    err = pthread_mutex_init(&bp->def_cp_lock, NULL);
drivers/net/bnxt/bnxt_ethdev.c:5838:    err = pthread_mutex_init(&bp->health_check_lock, NULL);
drivers/net/bnxt/bnxt_ethdev.c:5844:    err = pthread_mutex_init(&bp->err_recovery_lock, NULL);
drivers/net/bnxt/bnxt_ethdev.c:6773:    rc = pthread_mutex_init(&bp->rep_info->vfr_start_lock, NULL);
drivers/net/bnxt/bnxt_txq.c:201:        rc = pthread_mutex_init(&txq->txq_lock, NULL);
drivers/net/bnxt/tf_ulp/bnxt_ulp.c:218:                 rc = pthread_mutex_init(&session->bnxt_ulp_mutex, NULL);
drivers/net/bnxt/tf_ulp/bnxt_ulp_tf.c:1475:     rc = pthread_mutex_init(&bp->ulp_ctx->cfg_data->flow_db_lock, NULL);
drivers/net/bnxt/tf_ulp/bnxt_ulp_tfc.c:996:     rc = pthread_mutex_init(&bp->ulp_ctx->cfg_data->flow_db_lock, NULL);
drivers/net/bnxt/tf_ulp/ulp_fc_mgr.c:132:       rc = pthread_mutex_init(&ulp_fc_info->fc_lock, NULL);
drivers/net/bnxt/tf_ulp/ulp_ha_mgr.c:415:       rc = pthread_mutex_init(&ha_info->ha_lock, NULL);
drivers/net/failsafe/failsafe.c:150:    ret = pthread_mutex_init(&priv->hotplug_mutex, &attr);
drivers/net/hinic/base/hinic_compat.h:205:      err = pthread_mutex_init(pthreadmutex, mattr);
drivers/raw/ifpga/base/opae_intel_max10.c:1489:         ret = pthread_mutex_init(&dev->bmc_ops.lock, NULL);
drivers/raw/ifpga/base/opae_spi_transaction.c:510:      ret = pthread_mutex_init(&spi_tran_dev->lock, NULL);
lib/vhost/socket.c:501: ret = pthread_mutex_init(&reconn_list.mutex, NULL);
lib/vhost/socket.c:924: ret = pthread_mutex_init(&vsocket->conn_mutex, NULL);
```

Thank you,

Bugzilla ID: 1586

---
v4
* addressed feedback, turned returns into tail calls
* reworded the cover letter
v3 (https://inbox.dpdk.org/dev/[email protected]/)
* fix style issues
v2 (https://inbox.dpdk.org/dev/[email protected]/)
* fix build issues
v1 (https://inbox.dpdk.org/dev/[email protected]/#t)

Ariel Otilibili (6):
raw/ifpga: remove check around pthread_mutex_init() net/bnxt: remove check around pthread_mutex_init() common/cnxk: remove check around pthread_mutex_init() net/failsafe: remove check around pthread_mutex_init() net/hinic: remove check around pthread_mutex_init() lib/vhost: remove check around pthread_mutex_init()

 drivers/common/cnxk/roc_bphy_cgx.c            |  5 +--
 drivers/net/bnxt/bnxt_ethdev.c                | 40 ++++---------------
 drivers/net/bnxt/bnxt_txq.c                   |  7 +---
 drivers/net/bnxt/tf_ulp/bnxt_ulp.c            |  8 +---
 drivers/net/bnxt/tf_ulp/bnxt_ulp_tf.c         |  6 +--
 drivers/net/bnxt/tf_ulp/bnxt_ulp_tfc.c        |  6 +--
 drivers/net/bnxt/tf_ulp/ulp_fc_mgr.c          |  6 +--
 drivers/net/bnxt/tf_ulp/ulp_ha_mgr.c          |  6 +--
 drivers/net/failsafe/failsafe.c               |  8 +---
 drivers/net/hinic/base/hinic_compat.h         |  8 +---
 drivers/raw/ifpga/base/opae_intel_max10.c     |  5 +--
 drivers/raw/ifpga/base/opae_spi_transaction.c |  7 +---
 lib/vhost/socket.c                            | 14 +------
 13 files changed, 21 insertions(+), 105 deletions(-)
Signature · 1 line
2.30.2
#30 lore raw

PATCH v4 1/6 raw/ifpga: remove check around pthread_mutex_init()

Quoted 2 lines

pthread_mutex_init always returns 0. The other mutex functions return 0 on success and a non-zero error code on error.

Bugzilla ID: 1586

---
 drivers/raw/ifpga/base/opae_intel_max10.c     | 5 +----
 drivers/raw/ifpga/base/opae_spi_transaction.c | 7 +------
 2 files changed, 2 insertions(+), 10 deletions(-)
drivers/raw/ifpga/base/opae_intel_max10.c +1 -4
index d5a9ceb6e355..58c884a8d8e1 100644
@@ -1486,10 +1486,7 @@ intel_max10_device_init(struct intel_max10_device *dev)
 		if (ret)
 			return ret;
 
-		ret = pthread_mutex_init(&dev->bmc_ops.lock, NULL);
-		if (ret)
-			return ret;
-
+		pthread_mutex_init(&dev->bmc_ops.lock, NULL);
 		if (!dev->bmc_ops.mutex)
 			dev->bmc_ops.mutex = &dev->bmc_ops.lock;
 	}
drivers/raw/ifpga/base/opae_spi_transaction.c +1 -6
index 21015eb95ef5..14ea93cb43df 100644
@@ -494,7 +494,6 @@ struct spi_transaction_dev *spi_transaction_init(struct altera_spi_device *dev,
 		int chipselect)
 {
 	struct spi_transaction_dev *spi_tran_dev;
-	int ret;
 
 	spi_tran_dev = opae_malloc(sizeof(struct spi_transaction_dev));
 	if (!spi_tran_dev)
@@ -507,11 +506,7 @@ struct spi_transaction_dev *spi_transaction_init(struct altera_spi_device *dev,
 	if (!spi_tran_dev->buffer)
 		goto err;
 
-	ret = pthread_mutex_init(&spi_tran_dev->lock, NULL);
-	if (ret) {
-		dev_err(spi_tran_dev, "fail to init mutex lock\n");
-		goto err;
-	}
+	pthread_mutex_init(&spi_tran_dev->lock, NULL);
 	if (dev->mutex) {
 		dev_info(NULL, "use multi-process mutex in spi\n");
 		spi_tran_dev->mutex = dev->mutex;
Signature · 1 line
2.30.2
#31 lore raw

PATCH v4 2/6 net/bnxt: remove check around pthread_mutex_init()

In reply to Ariel Otilibili
Quoted 2 lines

pthread_mutex_init always returns 0. The other mutex functions return 0 on success and a non-zero error code on error.

Bugzilla ID: 1586

---
 drivers/net/bnxt/bnxt_ethdev.c         | 40 +++++---------------------
 drivers/net/bnxt/bnxt_txq.c            |  7 +----
 drivers/net/bnxt/tf_ulp/bnxt_ulp.c     |  8 +-----
 drivers/net/bnxt/tf_ulp/bnxt_ulp_tf.c  |  6 +---
 drivers/net/bnxt/tf_ulp/bnxt_ulp_tfc.c |  6 +---
 drivers/net/bnxt/tf_ulp/ulp_fc_mgr.c   |  6 +---
 drivers/net/bnxt/tf_ulp/ulp_ha_mgr.c   |  6 +---
 7 files changed, 13 insertions(+), 66 deletions(-)
drivers/net/bnxt/bnxt_ethdev.c +7 -33
index ef8a928c9170..21e9aa902c68 100644
@@ -5821,31 +5821,12 @@ static int bnxt_get_config(struct bnxt *bp)
 static int
 bnxt_init_locks(struct bnxt *bp)
 {
-	int err;
+	pthread_mutex_init(&bp->flow_lock, NULL);
+	pthread_mutex_init(&bp->def_cp_lock, NULL);
+	pthread_mutex_init(&bp->health_check_lock, NULL);
+	pthread_mutex_init(&bp->err_recovery_lock, NULL);
 
-	err = pthread_mutex_init(&bp->flow_lock, NULL);
-	if (err) {
-		PMD_DRV_LOG_LINE(ERR, "Unable to initialize flow_lock");
-		return err;
-	}
-
-	err = pthread_mutex_init(&bp->def_cp_lock, NULL);
-	if (err) {
-		PMD_DRV_LOG_LINE(ERR, "Unable to initialize def_cp_lock");
-		return err;
-	}
-
-	err = pthread_mutex_init(&bp->health_check_lock, NULL);
-	if (err) {
-		PMD_DRV_LOG_LINE(ERR, "Unable to initialize health_check_lock");
-		return err;
-	}
-
-	err = pthread_mutex_init(&bp->err_recovery_lock, NULL);
-	if (err)
-		PMD_DRV_LOG_LINE(ERR, "Unable to initialize err_recovery_lock");
-
-	return err;
+	return 0;
 }
 
 /* This should be called after we have queried trusted VF cap */
@@ -6746,7 +6727,7 @@ static void bnxt_free_rep_info(struct bnxt *bp)
 
 static int bnxt_init_rep_info(struct bnxt *bp)
 {
-	int i = 0, rc;
+	int i = 0;
 
 	if (bp->rep_info)
 		return 0;
@@ -6770,14 +6751,7 @@ static int bnxt_init_rep_info(struct bnxt *bp)
 	for (i = 0; i < BNXT_MAX_CFA_CODE; i++)
 		bp->cfa_code_map[i] = BNXT_VF_IDX_INVALID;
 
-	rc = pthread_mutex_init(&bp->rep_info->vfr_start_lock, NULL);
-	if (rc) {
-		PMD_DRV_LOG_LINE(ERR, "Unable to initialize vfr_start_lock");
-		bnxt_free_rep_info(bp);
-		return rc;
-	}
-
-	return rc;
+	return pthread_mutex_init(&bp->rep_info->vfr_start_lock, NULL);
 }
 
 static int bnxt_rep_port_probe(struct rte_pci_device *pci_dev,
drivers/net/bnxt/bnxt_txq.c +1 -6
index c8649359923f..3938ebc7091d 100644
@@ -198,12 +198,7 @@ int bnxt_tx_queue_setup_op(struct rte_eth_dev *eth_dev,
 		goto err;
 	}
 
-	rc = pthread_mutex_init(&txq->txq_lock, NULL);
-	if (rc != 0) {
-		PMD_DRV_LOG_LINE(ERR, "TxQ mutex init failed!");
-		goto err;
-	}
-	return 0;
+	return pthread_mutex_init(&txq->txq_lock, NULL);
 err:
 	bnxt_tx_queue_release_op(eth_dev, queue_idx);
 	return rc;
drivers/net/bnxt/tf_ulp/bnxt_ulp.c +1 -7
index 1bfc88cf79ef..0c03ae7a8349 100644
@@ -188,7 +188,6 @@ ulp_session_init(struct bnxt *bp,
 	struct rte_pci_device		*pci_dev;
 	struct rte_pci_addr		*pci_addr;
 	struct bnxt_ulp_session_state	*session;
-	int rc = 0;
 
 	if (!bp)
 		return NULL;
@@ -215,12 +214,7 @@ ulp_session_init(struct bnxt *bp,
 			session->pci_info.domain = pci_addr->domain;
 			session->pci_info.bus = pci_addr->bus;
 			memcpy(session->dsn, bp->dsn, sizeof(session->dsn));
-			rc = pthread_mutex_init(&session->bnxt_ulp_mutex, NULL);
-			if (rc) {
-				BNXT_DRV_DBG(ERR, "mutex create failed\n");
-				pthread_mutex_unlock(&bnxt_ulp_global_mutex);
-				return NULL;
-			}
+			pthread_mutex_init(&session->bnxt_ulp_mutex, NULL);
 			STAILQ_INSERT_TAIL(&bnxt_ulp_session_list,
 					   session, next);
 		}
drivers/net/bnxt/tf_ulp/bnxt_ulp_tf.c +1 -5
index fa7e8fe00077..4a1ccfa2a36d 100644
@@ -1472,11 +1472,7 @@ ulp_tf_init(struct bnxt *bp,
 		goto jump_to_error;
 	}
 
-	rc = pthread_mutex_init(&bp->ulp_ctx->cfg_data->flow_db_lock, NULL);
-	if (rc) {
-		BNXT_DRV_DBG(ERR, "Unable to initialize flow db lock\n");
-		goto jump_to_error;
-	}
+	pthread_mutex_init(&bp->ulp_ctx->cfg_data->flow_db_lock, NULL);
 
 	/* Initialize ulp dparms with values devargs passed */
 	rc = ulp_tf_dparms_init(bp, bp->ulp_ctx);
drivers/net/bnxt/tf_ulp/bnxt_ulp_tfc.c +1 -5
index 6d7ec0ffec79..508c194d0490 100644
@@ -993,11 +993,7 @@ ulp_tfc_init(struct bnxt *bp,
 		goto jump_to_error;
 	}
 
-	rc = pthread_mutex_init(&bp->ulp_ctx->cfg_data->flow_db_lock, NULL);
-	if (rc) {
-		BNXT_DRV_DBG(ERR, "Unable to initialize flow db lock\n");
-		goto jump_to_error;
-	}
+	pthread_mutex_init(&bp->ulp_ctx->cfg_data->flow_db_lock, NULL);
 
 	rc = ulp_tfc_dparms_init(bp, bp->ulp_ctx, ulp_dev_id);
 	if (rc) {
drivers/net/bnxt/tf_ulp/ulp_fc_mgr.c +1 -5
index 67489b76f390..f9d069f4e17e 100644
@@ -129,11 +129,7 @@ ulp_fc_mgr_init(struct bnxt_ulp_context *ctxt)
 	ulp_fc_info->fc_ops = fc_ops;
 	ulp_fc_info->flags = flags;
 
-	rc = pthread_mutex_init(&ulp_fc_info->fc_lock, NULL);
-	if (rc) {
-		BNXT_DRV_DBG(ERR, "Failed to initialize fc mutex\n");
-		goto error;
-	}
+	pthread_mutex_init(&ulp_fc_info->fc_lock, NULL);
 
 	/* Add the FC info tbl to the ulp context. */
 	bnxt_ulp_cntxt_ptr2_fc_info_set(ctxt, ulp_fc_info);
drivers/net/bnxt/tf_ulp/ulp_ha_mgr.c +1 -5
index 3c75a6b43721..7b7c10d3602e 100644
@@ -412,11 +412,7 @@ ulp_ha_mgr_init(struct bnxt_ulp_context *ulp_ctx)
 	/* Add the HA info tbl to the ulp context. */
 	bnxt_ulp_cntxt_ptr2_ha_info_set(ulp_ctx, ha_info);
 
-	rc = pthread_mutex_init(&ha_info->ha_lock, NULL);
-	if (rc) {
-		PMD_DRV_LOG_LINE(ERR, "Failed to initialize ha mutex");
-		goto cleanup;
-	}
+	pthread_mutex_init(&ha_info->ha_lock, NULL);
 	rc = ulp_ha_mgr_timer_start(ulp_ctx->cfg_data);
 	if (rc) {
 		PMD_DRV_LOG_LINE(ERR, "Unable to start timer CB");
Signature · 1 line
2.30.2
#32 lore raw

PATCH v4 3/6 common/cnxk: remove check around pthread_mutex_init()

In reply to Ariel Otilibili
Quoted 2 lines

pthread_mutex_init always returns 0. The other mutex functions return 0 on success and a non-zero error code on error.

Bugzilla ID: 1586

Cc Nithin Dabilpuram <[email protected]>
Cc Kiran Kumar K <[email protected]>
Cc Sunil Kumar Kori <[email protected]>
Cc Satha Rao <[email protected]>
Cc Harman Kalra <[email protected]>
---
 drivers/common/cnxk/roc_bphy_cgx.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/common/cnxk/roc_bphy_cgx.c +1 -4
index 4f43605e1031..882cf654743b 100644
@@ -189,14 +189,11 @@ int
 roc_bphy_cgx_dev_init(struct roc_bphy_cgx *roc_cgx)
 {
 	uint64_t val;
-	int ret;
 
 	if (!roc_cgx || !roc_cgx->bar0_va || !roc_cgx->bar0_pa)
 		return -EINVAL;
 
-	ret = pthread_mutex_init(&roc_cgx->lock, NULL);
-	if (ret)
-		return ret;
+	pthread_mutex_init(&roc_cgx->lock, NULL);
 
 	val = roc_bphy_cgx_read(roc_cgx, 0, CGX_CMRX_RX_LMACS);
 	val = FIELD_GET(CGX_CMRX_RX_LMACS_LMACS, val);
Signature · 1 line
2.30.2
#33 lore raw

PATCH v4 4/6 net/failsafe: remove check around pthread_mutex_init()

In reply to Ariel Otilibili
Quoted 2 lines

pthread_mutex_init always returns 0. The other mutex functions return 0 on success and a non-zero error code on error.

Bugzilla ID: 1586

---
 drivers/net/failsafe/failsafe.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)
drivers/net/failsafe/failsafe.c +2 -6
index 32811403b4c8..3e590d38f71a 100644
@@ -147,12 +147,8 @@ fs_mutex_init(struct fs_priv *priv)
 		ERROR("Cannot set mutex type - %s", strerror(ret));
 		return ret;
 	}
-	ret = pthread_mutex_init(&priv->hotplug_mutex, &attr);
-	if (ret) {
-		ERROR("Cannot initiate mutex - %s", strerror(ret));
-		return ret;
-	}
-	return 0;
+
+	return pthread_mutex_init(&priv->hotplug_mutex, &attr);
 }
 
 static int
Signature · 1 line
2.30.2
#34 lore raw

PATCH v4 5/6 net/hinic: remove check around pthread_mutex_init()

In reply to Ariel Otilibili
Quoted 2 lines

pthread_mutex_init always returns 0. The other mutex functions return 0 on success and a non-zero error code on error.

Bugzilla ID: 1586

---
 drivers/net/hinic/base/hinic_compat.h | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)
drivers/net/hinic/base/hinic_compat.h +1 -7
index ab9d1b9a0214..d3994c50e939 100644
@@ -200,13 +200,7 @@ static inline u16 ilog2(u32 n)
 static inline int hinic_mutex_init(pthread_mutex_t *pthreadmutex,
 					const pthread_mutexattr_t *mattr)
 {
-	int err;
-
-	err = pthread_mutex_init(pthreadmutex, mattr);
-	if (unlikely(err))
-		PMD_DRV_LOG(ERR, "Fail to initialize mutex, error: %d", err);
-
-	return err;
+	return pthread_mutex_init(pthreadmutex, mattr);
 }
 
 static inline int hinic_mutex_destroy(pthread_mutex_t *pthreadmutex)
Signature · 1 line
2.30.2
#35 lore raw

PATCH v4 6/6 lib/vhost: remove check around pthread_mutex_init()

In reply to Ariel Otilibili
Quoted 2 lines

pthread_mutex_init always returns 0. The other mutex functions return 0 on success and a non-zero error code on error.

Bugzilla ID: 1586

---
 lib/vhost/socket.c | 14 ++------------
 1 file changed, 2 insertions(+), 12 deletions(-)
lib/vhost/socket.c +2 -12
index d29d15494c8e..531aa8adc06c 100644
@@ -498,11 +498,7 @@ vhost_user_reconnect_init(void)
 {
 	int ret;
 
-	ret = pthread_mutex_init(&reconn_list.mutex, NULL);
-	if (ret < 0) {
-		VHOST_CONFIG_LOG("thread", ERR, "%s: failed to initialize mutex", __func__);
-		return ret;
-	}
+	pthread_mutex_init(&reconn_list.mutex, NULL);
 	TAILQ_INIT(&reconn_list.head);
 
 	ret = rte_thread_create_internal_control(&reconn_tid, "vhost-reco",
@@ -921,11 +917,7 @@ rte_vhost_driver_register(const char *path, uint64_t flags)
 		goto out;
 	}
 	TAILQ_INIT(&vsocket->conn_list);
-	ret = pthread_mutex_init(&vsocket->conn_mutex, NULL);
-	if (ret) {
-		VHOST_CONFIG_LOG(path, ERR, "failed to init connection mutex");
-		goto out_free;
-	}
+	pthread_mutex_init(&vsocket->conn_mutex, NULL);
 
 	if (!strncmp("/dev/vduse/", path, strlen("/dev/vduse/")))
 		vsocket->is_vduse = true;
@@ -1034,8 +1026,6 @@ rte_vhost_driver_register(const char *path, uint64_t flags)
 	if (pthread_mutex_destroy(&vsocket->conn_mutex)) {
 		VHOST_CONFIG_LOG(path, ERR, "failed to destroy connection mutex");
 	}
-out_free:
-	vhost_user_socket_mem_free(vsocket);
 out:
 	pthread_mutex_unlock(&vhost_user.mutex);
 
Signature · 1 line
2.30.2
Reviewed-by on v4 6/6
#36 lore raw

Re: [PATCH v4 6/6] lib/vhost: remove check around pthread_mutex_init()

Quoted 44 lines · Ariel Otilibili
Quoted 2 lines

pthread_mutex_init always returns 0. The other mutex functions return 0 on success and a non-zero error code on error.

Bugzilla ID: 1586

---
  lib/vhost/socket.c | 14 ++------------
  1 file changed, 2 insertions(+), 12 deletions(-)
lib/vhost/socket.c +2 -10
index d29d15494c8e..531aa8adc06c 100644
@@ -498,11 +498,7 @@ vhost_user_reconnect_init(void)
  {
  	int ret;
 
-	ret = pthread_mutex_init(&reconn_list.mutex, NULL);
-	if (ret < 0) {
-		VHOST_CONFIG_LOG("thread", ERR, "%s: failed to initialize mutex", __func__);
-		return ret;
-	}
+	pthread_mutex_init(&reconn_list.mutex, NULL);
  	TAILQ_INIT(&reconn_list.head);
 
  	ret = rte_thread_create_internal_control(&reconn_tid, "vhost-reco",
@@ -921,11 +917,7 @@ rte_vhost_driver_register(const char *path, uint64_t flags)
  		goto out;
  	}
  	TAILQ_INIT(&vsocket->conn_list);
-	ret = pthread_mutex_init(&vsocket->conn_mutex, NULL);
-	if (ret) {
-		VHOST_CONFIG_LOG(path, ERR, "failed to init connection mutex");
-		goto out_free;
-	}
+	pthread_mutex_init(&vsocket->conn_mutex, NULL);
 
  	if (!strncmp("/dev/vduse/", path, strlen("/dev/vduse/")))
  		vsocket->is_vduse = true;

lib/vhost/socket.c rte_vhost_driver_register(const char *path, uint64_t flags) · line 1031

Quoted 8 lines
lib/vhost/socket.c +0 -2
@@ -1034,8 +1026,6 @@ rte_vhost_driver_register(const char *path, uint64_t flags)
  	if (pthread_mutex_destroy(&vsocket->conn_mutex)) {
  		VHOST_CONFIG_LOG(path, ERR, "failed to destroy connection mutex");
  	}
-out_free:
-	vhost_user_socket_mem_free(vsocket);
  out:
  	pthread_mutex_unlock(&vhost_user.mutex);
 

Thanks,
Maxime