[v3,10/15] bus/dpaa: use warn(3) instead of error(3) to improve portability
diff mbox series

Message ID 20190313170657.16688-11-ncopa@alpinelinux.org
State Superseded, archived
Delegated to: Thomas Monjalon
Headers show
Series
  • Build fixes for musl libc
Related show

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Natanael Copa March 13, 2019, 5:06 p.m. UTC
Fix build with musl libc by using warn(3) instead of error(3).

This also fixes error message for kzmalloc failures which previously
would have given "Unknown error -1".

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
---
 drivers/bus/dpaa/base/fman/netcfg_layer.c |  4 ++--
 drivers/bus/dpaa/base/qbman/bman_driver.c |  6 +++---
 drivers/bus/dpaa/base/qbman/qman_driver.c | 12 ++++++------
 drivers/bus/dpaa/include/compat.h         |  2 +-
 4 files changed, 12 insertions(+), 12 deletions(-)

Comments

Thomas Monjalon March 30, 2019, 10:33 p.m. UTC | #1
13/03/2019 18:06, Natanael Copa:
> Fix build with musl libc by using warn(3) instead of error(3).
> 
> This also fixes error message for kzmalloc failures which previously
> would have given "Unknown error -1".

I think this patch requires more explanations about what was the error,
why using warn, and how it is related to kzmalloc failure log.
Thanks
Hemant Agrawal July 10, 2020, 5:13 a.m. UTC | #2
NAK
error is different from warning - the return value is also not carried. 

-----Original Message-----
From: dev <dev-bounces@dpdk.org> On Behalf Of Natanael Copa
Sent: Wednesday, March 13, 2019 10:37 PM
To: dev@dpdk.org
Cc: Natanael Copa <ncopa@alpinelinux.org>
Subject: [dpdk-dev] [PATCH v3 10/15] bus/dpaa: use warn(3) instead of error(3) to improve portability

Fix build with musl libc by using warn(3) instead of error(3).

This also fixes error message for kzmalloc failures which previously would have given "Unknown error -1".

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
---
 drivers/bus/dpaa/base/fman/netcfg_layer.c |  4 ++--  drivers/bus/dpaa/base/qbman/bman_driver.c |  6 +++---  drivers/bus/dpaa/base/qbman/qman_driver.c | 12 ++++++------
 drivers/bus/dpaa/include/compat.h         |  2 +-
 4 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/drivers/bus/dpaa/base/fman/netcfg_layer.c b/drivers/bus/dpaa/base/fman/netcfg_layer.c
index 6b5224203..0c3a1bfa3 100644
--- a/drivers/bus/dpaa/base/fman/netcfg_layer.c
+++ b/drivers/bus/dpaa/base/fman/netcfg_layer.c
@@ -8,7 +8,7 @@
 #include <of.h>
 #include <net/if.h>
 #include <sys/ioctl.h>
-#include <error.h>
+#include <err.h>
 #include <net/if_arp.h>
 #include <assert.h>
 #include <unistd.h>
@@ -89,7 +89,7 @@ netcfg_acquire(void)
 	 */
 	skfd = socket(AF_PACKET, SOCK_RAW, 0);
 	if (unlikely(skfd < 0)) {
-		error(0, errno, "%s(): open(SOCK_RAW)", __func__);
+		warn("%s(): open(SOCK_RAW)", __func__);
 		return NULL;
 	}
 
diff --git a/drivers/bus/dpaa/base/qbman/bman_driver.c b/drivers/bus/dpaa/base/qbman/bman_driver.c
index 750b756b9..dbe00d1c9 100644
--- a/drivers/bus/dpaa/base/qbman/bman_driver.c
+++ b/drivers/bus/dpaa/base/qbman/bman_driver.c
@@ -40,7 +40,7 @@ static int fsl_bman_portal_init(uint32_t idx, int is_shared)
 	ret = pthread_getaffinity_np(pthread_self(), sizeof(cpu_set_t),
 				     &cpuset);
 	if (ret) {
-		error(0, ret, "pthread_getaffinity_np()");
+		warn("pthread_getaffinity_np()");
 		return ret;
 	}
 	pcfg.cpu = -1;
@@ -60,7 +60,7 @@ static int fsl_bman_portal_init(uint32_t idx, int is_shared)
 	map.index = idx;
 	ret = process_portal_map(&map);
 	if (ret) {
-		error(0, ret, "process_portal_map()");
+		warn("process_portal_map()");
 		return ret;
 	}
 	/* Make the portal's cache-[enabled|inhibited] regions */ @@ -105,7 +105,7 @@ static int fsl_bman_portal_finish(void)
 	DPAA_BUG_ON(cfg != &pcfg);
 	ret = process_portal_unmap(&map.addr);
 	if (ret)
-		error(0, ret, "process_portal_unmap()");
+		warn("process_portal_unmap()");
 	return ret;
 }
 
diff --git a/drivers/bus/dpaa/base/qbman/qman_driver.c b/drivers/bus/dpaa/base/qbman/qman_driver.c
index ba153396d..163a66b30 100644
--- a/drivers/bus/dpaa/base/qbman/qman_driver.c
+++ b/drivers/bus/dpaa/base/qbman/qman_driver.c
@@ -41,7 +41,7 @@ static int fsl_qman_portal_init(uint32_t index, int is_shared)
 	ret = pthread_getaffinity_np(pthread_self(), sizeof(cpu_set_t),
 				     &cpuset);
 	if (ret) {
-		error(0, ret, "pthread_getaffinity_np()");
+		warn("pthread_getaffinity_np()");
 		return ret;
 	}
 	qpcfg.cpu = -1;
@@ -62,7 +62,7 @@ static int fsl_qman_portal_init(uint32_t index, int is_shared)
 	map.index = index;
 	ret = process_portal_map(&map);
 	if (ret) {
-		error(0, ret, "process_portal_map()");
+		warn("process_portal_map()");
 		return ret;
 	}
 	qpcfg.channel = map.channel;
@@ -109,7 +109,7 @@ static int fsl_qman_portal_finish(void)
 	DPAA_BUG_ON(cfg != &qpcfg);
 	ret = process_portal_unmap(&map.addr);
 	if (ret)
-		error(0, ret, "process_portal_unmap()");
+		warn("process_portal_unmap()");
 	return ret;
 }
 
@@ -156,7 +156,7 @@ struct qman_portal *fsl_qman_portal_create(void)
 
 	q_pcfg = kzalloc((sizeof(struct qm_portal_config)), 0);
 	if (!q_pcfg) {
-		error(0, -1, "q_pcfg kzalloc failed");
+		warn("q_pcfg kzalloc failed");
 		return NULL;
 	}
 
@@ -164,7 +164,7 @@ struct qman_portal *fsl_qman_portal_create(void)
 	ret = pthread_getaffinity_np(pthread_self(), sizeof(cpu_set_t),
 				     &cpuset);
 	if (ret) {
-		error(0, ret, "pthread_getaffinity_np()");
+		warn("pthread_getaffinity_np()");
 		kfree(q_pcfg);
 		return NULL;
 	}
@@ -190,7 +190,7 @@ struct qman_portal *fsl_qman_portal_create(void)
 	q_map.index = QBMAN_ANY_PORTAL_IDX;
 	ret = process_portal_map(&q_map);
 	if (ret) {
-		error(0, ret, "process_portal_map()");
+		warn("process_portal_map()");
 		kfree(q_pcfg);
 		return NULL;
 	}
diff --git a/drivers/bus/dpaa/include/compat.h b/drivers/bus/dpaa/include/compat.h
index 412265779..0c01c5514 100644
--- a/drivers/bus/dpaa/include/compat.h
+++ b/drivers/bus/dpaa/include/compat.h
@@ -33,7 +33,7 @@
 #include <assert.h>
 #include <dirent.h>
 #include <inttypes.h>
-#include <error.h>
+#include <err.h>
 #include <rte_byteorder.h>
 #include <rte_atomic.h>
 #include <rte_spinlock.h>
--
2.21.0

Patch
diff mbox series

diff --git a/drivers/bus/dpaa/base/fman/netcfg_layer.c b/drivers/bus/dpaa/base/fman/netcfg_layer.c
index 6b5224203..0c3a1bfa3 100644
--- a/drivers/bus/dpaa/base/fman/netcfg_layer.c
+++ b/drivers/bus/dpaa/base/fman/netcfg_layer.c
@@ -8,7 +8,7 @@ 
 #include <of.h>
 #include <net/if.h>
 #include <sys/ioctl.h>
-#include <error.h>
+#include <err.h>
 #include <net/if_arp.h>
 #include <assert.h>
 #include <unistd.h>
@@ -89,7 +89,7 @@  netcfg_acquire(void)
 	 */
 	skfd = socket(AF_PACKET, SOCK_RAW, 0);
 	if (unlikely(skfd < 0)) {
-		error(0, errno, "%s(): open(SOCK_RAW)", __func__);
+		warn("%s(): open(SOCK_RAW)", __func__);
 		return NULL;
 	}
 
diff --git a/drivers/bus/dpaa/base/qbman/bman_driver.c b/drivers/bus/dpaa/base/qbman/bman_driver.c
index 750b756b9..dbe00d1c9 100644
--- a/drivers/bus/dpaa/base/qbman/bman_driver.c
+++ b/drivers/bus/dpaa/base/qbman/bman_driver.c
@@ -40,7 +40,7 @@  static int fsl_bman_portal_init(uint32_t idx, int is_shared)
 	ret = pthread_getaffinity_np(pthread_self(), sizeof(cpu_set_t),
 				     &cpuset);
 	if (ret) {
-		error(0, ret, "pthread_getaffinity_np()");
+		warn("pthread_getaffinity_np()");
 		return ret;
 	}
 	pcfg.cpu = -1;
@@ -60,7 +60,7 @@  static int fsl_bman_portal_init(uint32_t idx, int is_shared)
 	map.index = idx;
 	ret = process_portal_map(&map);
 	if (ret) {
-		error(0, ret, "process_portal_map()");
+		warn("process_portal_map()");
 		return ret;
 	}
 	/* Make the portal's cache-[enabled|inhibited] regions */
@@ -105,7 +105,7 @@  static int fsl_bman_portal_finish(void)
 	DPAA_BUG_ON(cfg != &pcfg);
 	ret = process_portal_unmap(&map.addr);
 	if (ret)
-		error(0, ret, "process_portal_unmap()");
+		warn("process_portal_unmap()");
 	return ret;
 }
 
diff --git a/drivers/bus/dpaa/base/qbman/qman_driver.c b/drivers/bus/dpaa/base/qbman/qman_driver.c
index ba153396d..163a66b30 100644
--- a/drivers/bus/dpaa/base/qbman/qman_driver.c
+++ b/drivers/bus/dpaa/base/qbman/qman_driver.c
@@ -41,7 +41,7 @@  static int fsl_qman_portal_init(uint32_t index, int is_shared)
 	ret = pthread_getaffinity_np(pthread_self(), sizeof(cpu_set_t),
 				     &cpuset);
 	if (ret) {
-		error(0, ret, "pthread_getaffinity_np()");
+		warn("pthread_getaffinity_np()");
 		return ret;
 	}
 	qpcfg.cpu = -1;
@@ -62,7 +62,7 @@  static int fsl_qman_portal_init(uint32_t index, int is_shared)
 	map.index = index;
 	ret = process_portal_map(&map);
 	if (ret) {
-		error(0, ret, "process_portal_map()");
+		warn("process_portal_map()");
 		return ret;
 	}
 	qpcfg.channel = map.channel;
@@ -109,7 +109,7 @@  static int fsl_qman_portal_finish(void)
 	DPAA_BUG_ON(cfg != &qpcfg);
 	ret = process_portal_unmap(&map.addr);
 	if (ret)
-		error(0, ret, "process_portal_unmap()");
+		warn("process_portal_unmap()");
 	return ret;
 }
 
@@ -156,7 +156,7 @@  struct qman_portal *fsl_qman_portal_create(void)
 
 	q_pcfg = kzalloc((sizeof(struct qm_portal_config)), 0);
 	if (!q_pcfg) {
-		error(0, -1, "q_pcfg kzalloc failed");
+		warn("q_pcfg kzalloc failed");
 		return NULL;
 	}
 
@@ -164,7 +164,7 @@  struct qman_portal *fsl_qman_portal_create(void)
 	ret = pthread_getaffinity_np(pthread_self(), sizeof(cpu_set_t),
 				     &cpuset);
 	if (ret) {
-		error(0, ret, "pthread_getaffinity_np()");
+		warn("pthread_getaffinity_np()");
 		kfree(q_pcfg);
 		return NULL;
 	}
@@ -190,7 +190,7 @@  struct qman_portal *fsl_qman_portal_create(void)
 	q_map.index = QBMAN_ANY_PORTAL_IDX;
 	ret = process_portal_map(&q_map);
 	if (ret) {
-		error(0, ret, "process_portal_map()");
+		warn("process_portal_map()");
 		kfree(q_pcfg);
 		return NULL;
 	}
diff --git a/drivers/bus/dpaa/include/compat.h b/drivers/bus/dpaa/include/compat.h
index 412265779..0c01c5514 100644
--- a/drivers/bus/dpaa/include/compat.h
+++ b/drivers/bus/dpaa/include/compat.h
@@ -33,7 +33,7 @@ 
 #include <assert.h>
 #include <dirent.h>
 #include <inttypes.h>
-#include <error.h>
+#include <err.h>
 #include <rte_byteorder.h>
 #include <rte_atomic.h>
 #include <rte_spinlock.h>