From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 293CDA0521; Thu, 5 Nov 2020 22:19:00 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 85FBB2C7A; Thu, 5 Nov 2020 22:17:42 +0100 (CET) Received: from mx1.tetrasec.net (mx1.tetrasec.net [66.245.176.36]) by dpdk.org (Postfix) with ESMTP id DCDE21DBD; Thu, 5 Nov 2020 22:17:37 +0100 (CET) Received: from mx1.tetrasec.net (mail.local [127.0.0.1]) by mx1.tetrasec.net (Postfix) with ESMTP id A183913C5FA; Thu, 5 Nov 2020 21:17:37 +0000 (UTC) Received: from ncopa-desktop.lan (67.63.200.37.customer.cdi.no [37.200.63.67]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: n@tanael.org) by mx1.tetrasec.net (Postfix) with ESMTPSA id 87DFB13C5F7; Thu, 5 Nov 2020 21:17:36 +0000 (UTC) From: Natanael Copa To: dev@dpdk.org, Hemant Agrawal , Sachin Saxena Cc: Natanael Copa , stable@dpdk.org Date: Thu, 5 Nov 2020 22:17:12 +0100 Message-Id: <20201105211716.25181-5-ncopa@alpinelinux.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201105211716.25181-1-ncopa@alpinelinux.org> References: <18966392.1bK43UoomU@xps> <20201105211716.25181-1-ncopa@alpinelinux.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Subject: [dpdk-dev] [PATCH v4 4/8] bus/dpaa: use warn instead of error to improve portability X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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 =3D 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 --- 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 #include #include -#include +#include #include #include #include @@ -90,7 +90,7 @@ netcfg_acquire(void) */ skfd =3D 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; } =20 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_sh= ared) ret =3D pthread_getaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset); if (ret) { - error(0, ret, "pthread_getaffinity_np()"); + errno =3D ret; + warn("pthread_getaffinity_np()"); return ret; } pcfg.cpu =3D -1; @@ -60,7 +61,8 @@ static int fsl_bman_portal_init(uint32_t idx, int is_sh= ared) map.index =3D idx; ret =3D process_portal_map(&map); if (ret) { - error(0, ret, "process_portal_map()"); + errno =3D 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 =3D bman_destroy_affine_portal(); DPAA_BUG_ON(cfg !=3D &pcfg); ret =3D process_portal_unmap(&map.addr); - if (ret) - error(0, ret, "process_portal_unmap()"); + if (ret) { + errno =3D ret; + warn("process_portal_unmap()"); + } return ret; } =20 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 =3D index; ret =3D process_portal_map(&map); if (ret) { - error(0, ret, "process_portal_map()"); + errno =3D ret; + warn("process_portal_map()"); return ret; } qpcfg.channel =3D map.channel; @@ -96,8 +97,10 @@ static int fsl_qman_portal_finish(void) cfg =3D qman_destroy_affine_portal(NULL); DPAA_BUG_ON(cfg !=3D &qpcfg); ret =3D process_portal_unmap(&map.addr); - if (ret) - error(0, ret, "process_portal_unmap()"); + if (ret) { + errno =3D ret; + warn("process_portal_unmap()"); + } return ret; } =20 @@ -146,7 +149,8 @@ struct qman_portal *fsl_qman_fq_portal_create(int *fd= ) =20 q_pcfg =3D 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; } =20 @@ -155,7 +159,8 @@ struct qman_portal *fsl_qman_fq_portal_create(int *fd= ) q_map.index =3D QBMAN_ANY_PORTAL_IDX; ret =3D process_portal_map(&q_map); if (ret) { - error(0, ret, "process_portal_map()"); + errno =3D ret; + warn("process_portal_map()"); kfree(q_pcfg); return NULL; } --=20 2.29.2