From: Natanael Copa <ncopa@alpinelinux.org>
To: dev@dpdk.org, Hemant Agrawal <hemant.agrawal@nxp.com>,
Sachin Saxena <sachin.saxena@oss.nxp.com>
Cc: Natanael Copa <ncopa@alpinelinux.org>, stable@dpdk.org
Subject: [dpdk-stable] [PATCH v4 4/8] bus/dpaa: use warn instead of error to improve portability
Date: Thu, 5 Nov 2020 22:17:12 +0100 [thread overview]
Message-ID: <20201105211716.25181-5-ncopa@alpinelinux.org> (raw)
In-Reply-To: <20201105211716.25181-1-ncopa@alpinelinux.org>
Fix build with musl libc by using warn(3) instead of using the GNU
specific error(3).
`error(0, errno, ...)` is identical to `warn(...)` so replace:
error(0, ret, ...);
with the identical:
errno = ret;
warn(...);
We could have used the identical `warnx("...: %s", strerror(ret))` but
strerror(3) is not thread-safe and the strerror_r variant has two
incompatible versions, one GNU specific and one XSI-compliant. Avoid the
mess by letting `warn` use the thread-local errno.
This also fixes error message for kzmalloc failures which previously
would always have given "Unknown error -1", since that is what
strerror(-1) returns. Let 'warn' use the proper error message from errno
which is set by kzalloc.
Fixes: 9d32ef0f5d61 ("bus/dpaa: support creating dynamic HW portal")
Fixes: f09ede6c8fd1 ("bus/dpaa: add BMAN driver core")
Fixes: 5b22cf744689 ("bus/dpaa: introducing FMan configurations")
Cc: stable@dpdk.org
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 | 12 ++++++++----
drivers/bus/dpaa/base/qbman/qman_driver.c | 15 ++++++++++-----
3 files changed, 20 insertions(+), 11 deletions(-)
diff --git a/drivers/bus/dpaa/base/fman/netcfg_layer.c b/drivers/bus/dpaa/base/fman/netcfg_layer.c
index b7009f229..bcedbaf68 100644
--- a/drivers/bus/dpaa/base/fman/netcfg_layer.c
+++ b/drivers/bus/dpaa/base/fman/netcfg_layer.c
@@ -8,7 +8,7 @@
#include <dpaa_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>
@@ -90,7 +90,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..8c9a98c48 100644
--- a/drivers/bus/dpaa/base/qbman/bman_driver.c
+++ b/drivers/bus/dpaa/base/qbman/bman_driver.c
@@ -40,7 +40,8 @@ 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()");
+ errno = ret;
+ warn("pthread_getaffinity_np()");
return ret;
}
pcfg.cpu = -1;
@@ -60,7 +61,8 @@ 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()");
+ errno = ret;
+ warn("process_portal_map()");
return ret;
}
/* Make the portal's cache-[enabled|inhibited] regions */
@@ -104,8 +106,10 @@ static int fsl_bman_portal_finish(void)
cfg = bman_destroy_affine_portal();
DPAA_BUG_ON(cfg != &pcfg);
ret = process_portal_unmap(&map.addr);
- if (ret)
- error(0, ret, "process_portal_unmap()");
+ if (ret) {
+ errno = ret;
+ 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 6d9aaff16..4cff2c161 100644
--- a/drivers/bus/dpaa/base/qbman/qman_driver.c
+++ b/drivers/bus/dpaa/base/qbman/qman_driver.c
@@ -50,7 +50,8 @@ 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()");
+ errno = ret;
+ warn("process_portal_map()");
return ret;
}
qpcfg.channel = map.channel;
@@ -96,8 +97,10 @@ static int fsl_qman_portal_finish(void)
cfg = qman_destroy_affine_portal(NULL);
DPAA_BUG_ON(cfg != &qpcfg);
ret = process_portal_unmap(&map.addr);
- if (ret)
- error(0, ret, "process_portal_unmap()");
+ if (ret) {
+ errno = ret;
+ warn("process_portal_unmap()");
+ }
return ret;
}
@@ -146,7 +149,8 @@ struct qman_portal *fsl_qman_fq_portal_create(int *fd)
q_pcfg = kzalloc((sizeof(struct qm_portal_config)), 0);
if (!q_pcfg) {
- error(0, -1, "q_pcfg kzalloc failed");
+ /* kzalloc sets errno */
+ warn("q_pcfg kzalloc failed");
return NULL;
}
@@ -155,7 +159,8 @@ struct qman_portal *fsl_qman_fq_portal_create(int *fd)
q_map.index = QBMAN_ANY_PORTAL_IDX;
ret = process_portal_map(&q_map);
if (ret) {
- error(0, ret, "process_portal_map()");
+ errno = ret;
+ warn("process_portal_map()");
kfree(q_pcfg);
return NULL;
}
--
2.29.2
next prev parent reply other threads:[~2020-11-05 21:17 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <18966392.1bK43UoomU@xps>
[not found] ` <20201105211716.25181-1-ncopa@alpinelinux.org>
2020-11-05 21:17 ` [dpdk-stable] [PATCH v4 1/8] app/testpmd: fix uint build error with musl libc Natanael Copa
2020-11-06 9:22 ` [dpdk-stable] [dpdk-dev] [PATCH v4 1/8] app/testpmd: fix uint build error withmusl libc Morten Brørup
2020-11-05 21:17 ` [dpdk-stable] [PATCH v4 2/8] net/cxgbe: fix uint build error with musl libc Natanael Copa
2020-11-06 9:24 ` [dpdk-stable] [dpdk-dev] [PATCH v4 2/8] net/cxgbe: fix uint build error with musllibc Morten Brørup
2020-11-05 21:17 ` [dpdk-stable] [PATCH v4 3/8] bus/pci: add fallback for out* for non GNU libc Natanael Copa
2020-11-05 21:17 ` Natanael Copa [this message]
2020-11-05 21:17 ` [dpdk-stable] [PATCH v4 5/8] bus/dpaa: fix detection of 64 bit arch Natanael Copa
2020-11-05 21:17 ` [dpdk-stable] [PATCH v4 6/8] common/dpaax: build fix for musl libc Natanael Copa
2020-11-05 21:17 ` [dpdk-stable] [PATCH v4 8/8] eal: add missing include to fix build with " Natanael Copa
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20201105211716.25181-5-ncopa@alpinelinux.org \
--to=ncopa@alpinelinux.org \
--cc=dev@dpdk.org \
--cc=hemant.agrawal@nxp.com \
--cc=sachin.saxena@oss.nxp.com \
--cc=stable@dpdk.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).