DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH 0/4] Avoid using perror
@ 2025-12-28 20:10 Stephen Hemminger
  2025-12-28 20:10 ` [PATCH 1/4] checkpatches: warn if perror is used Stephen Hemminger
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Stephen Hemminger @ 2025-12-28 20:10 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger

The DPDK uses its own logging library exclusively and drivers
and libraries should not be printing directly. One function that
was missed was perror() and some code was using it.

This series adds a checkpatch warning and fixes the
places that were using it.

Stephen Hemminger (4):
  checkpatches: warn if perror is used
  bus/dpaa: replace perror with log
  telemetry: replace perror with log
  common/dpaax: replace use of perror with log

 devtools/checkpatches.sh              | 2 +-
 drivers/bus/dpaa/base/qbman/process.c | 8 ++++----
 drivers/common/dpaax/dpaa_of.c        | 2 +-
 lib/telemetry/telemetry.c             | 4 ++--
 4 files changed, 8 insertions(+), 8 deletions(-)

-- 
2.51.0


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 1/4] checkpatches: warn if perror is used
  2025-12-28 20:10 [PATCH 0/4] Avoid using perror Stephen Hemminger
@ 2025-12-28 20:10 ` Stephen Hemminger
  2025-12-28 20:10 ` [PATCH 2/4] bus/dpaa: replace perror with log Stephen Hemminger
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Stephen Hemminger @ 2025-12-28 20:10 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Thomas Monjalon

The function perror is another way to print to stderr, which
should be discouraged in drivers and libraries.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 devtools/checkpatches.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/devtools/checkpatches.sh b/devtools/checkpatches.sh
index 9a8199659f..1c6099ac82 100755
--- a/devtools/checkpatches.sh
+++ b/devtools/checkpatches.sh
@@ -73,7 +73,7 @@ check_forbidden_additions() { # <patch>
 
 	# no output on stdout or stderr
 	awk -v FOLDERS="lib drivers" \
-		-v EXPRESSIONS="\\\<printf\\\> \\\<fprintf\\\(stdout, \\\<fprintf\\\(stderr," \
+		-v EXPRESSIONS="perror\\\( \\\<printf\\\> \\\<fprintf\\\(stdout, \\\<fprintf\\\(stderr," \
 		-v RET_ON_FAIL=1 \
 		-v MESSAGE='Writing to stdout or stderr' \
 		-f $(dirname $(readlink -f $0))/check-forbidden-tokens.awk \
-- 
2.51.0


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 2/4] bus/dpaa: replace perror with log
  2025-12-28 20:10 [PATCH 0/4] Avoid using perror Stephen Hemminger
  2025-12-28 20:10 ` [PATCH 1/4] checkpatches: warn if perror is used Stephen Hemminger
@ 2025-12-28 20:10 ` Stephen Hemminger
  2025-12-28 20:10 ` [PATCH 3/4] telemetry: " Stephen Hemminger
  2025-12-28 20:10 ` [PATCH 4/4] common/dpaax: replace use of " Stephen Hemminger
  3 siblings, 0 replies; 5+ messages in thread
From: Stephen Hemminger @ 2025-12-28 20:10 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Hemant Agrawal, Sachin Saxena

Use existing logging instead of calling perror.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/bus/dpaa/base/qbman/process.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/bus/dpaa/base/qbman/process.c b/drivers/bus/dpaa/base/qbman/process.c
index 2d805c5bd9..77362cd6e5 100644
--- a/drivers/bus/dpaa/base/qbman/process.c
+++ b/drivers/bus/dpaa/base/qbman/process.c
@@ -142,7 +142,7 @@ int process_portal_map(struct dpaa_ioctl_portal_map *params)
 
 	ret = ioctl(fd, DPAA_IOCTL_PORTAL_MAP, params);
 	if (ret) {
-		perror("ioctl(DPAA_IOCTL_PORTAL_MAP)");
+		DPAA_BUS_ERR("Failed ioctl DPAA_IOCTL_PORTAL_MAP: %s", strerror(errno));
 		return ret;
 	}
 	return 0;
@@ -157,7 +157,7 @@ int process_portal_unmap(struct dpaa_portal_map *map)
 
 	ret = ioctl(fd, DPAA_IOCTL_PORTAL_UNMAP, map);
 	if (ret) {
-		perror("ioctl(DPAA_IOCTL_PORTAL_UNMAP)");
+		DPAA_BUS_ERR("Failed ioctl DPAA_IOCTL_PORTAL_UNMAP: %s", strerror(errno));
 		return ret;
 	}
 	return 0;
@@ -215,7 +215,7 @@ static int process_portal_allocate(struct dpaa_ioctl_raw_portal *portal)
 
 	ret = ioctl(fd, DPAA_IOCTL_ALLOC_RAW_PORTAL, portal);
 	if (ret) {
-		perror("ioctl(DPAA_IOCTL_ALLOC_RAW_PORTAL)");
+		DPAA_BUS_ERR("Failed ioctl DPAA_IOCTL_ALLOC_RAW_PORTAL: %s", strerror(errno));
 		return ret;
 	}
 	return 0;
@@ -230,7 +230,7 @@ static int process_portal_free(struct dpaa_ioctl_raw_portal *portal)
 
 	ret = ioctl(fd, DPAA_IOCTL_FREE_RAW_PORTAL, portal);
 	if (ret) {
-		perror("ioctl(DPAA_IOCTL_FREE_RAW_PORTAL)");
+		DPAA_BUS_ERR("Failed ioctl DPAA_IOCTL_FREE_RAW_PORTAL: %s", strerror(errno));
 		return ret;
 	}
 	return 0;
-- 
2.51.0


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 3/4] telemetry: replace perror with log
  2025-12-28 20:10 [PATCH 0/4] Avoid using perror Stephen Hemminger
  2025-12-28 20:10 ` [PATCH 1/4] checkpatches: warn if perror is used Stephen Hemminger
  2025-12-28 20:10 ` [PATCH 2/4] bus/dpaa: replace perror with log Stephen Hemminger
@ 2025-12-28 20:10 ` Stephen Hemminger
  2025-12-28 20:10 ` [PATCH 4/4] common/dpaax: replace use of " Stephen Hemminger
  3 siblings, 0 replies; 5+ messages in thread
From: Stephen Hemminger @ 2025-12-28 20:10 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Bruce Richardson

Use logging instead of print to stderr.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/telemetry/telemetry.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/telemetry/telemetry.c b/lib/telemetry/telemetry.c
index cf4324421d..b109d076d4 100644
--- a/lib/telemetry/telemetry.c
+++ b/lib/telemetry/telemetry.c
@@ -365,7 +365,7 @@ output_json(const char *cmd, const struct rte_tel_data *d, int s)
 	used += prefix_used;
 	used += strlcat(out_buf + used, "}", sizeof(out_buf) - used);
 	if (write(s, out_buf, used) < 0)
-		perror("Error writing to socket");
+		TMTY_LOG_LINE(ERR, "Error writing to socket: %s", strerror(errno));
 }
 
 static void
@@ -384,7 +384,7 @@ perform_command(const struct cmd_callback *cb, const char *cmd, const char *para
 		int used = snprintf(out_buf, sizeof(out_buf), "{\"%.*s\":null}",
 				MAX_CMD_LEN, cmd ? cmd : "none");
 		if (write(s, out_buf, used) < 0)
-			perror("Error writing to socket");
+			TMTY_LOG_LINE(ERR, "Error writing to socket: %s", strerror(errno));
 		return;
 	}
 	output_json(cmd, &data, s);
-- 
2.51.0


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 4/4] common/dpaax: replace use of perror with log
  2025-12-28 20:10 [PATCH 0/4] Avoid using perror Stephen Hemminger
                   ` (2 preceding siblings ...)
  2025-12-28 20:10 ` [PATCH 3/4] telemetry: " Stephen Hemminger
@ 2025-12-28 20:10 ` Stephen Hemminger
  3 siblings, 0 replies; 5+ messages in thread
From: Stephen Hemminger @ 2025-12-28 20:10 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Hemant Agrawal, Sachin Saxena

Use log functions instead of perror.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/common/dpaax/dpaa_of.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/common/dpaax/dpaa_of.c b/drivers/common/dpaax/dpaa_of.c
index 23035f530d..d44c893bb4 100644
--- a/drivers/common/dpaax/dpaa_of.c
+++ b/drivers/common/dpaax/dpaa_of.c
@@ -117,7 +117,7 @@ iterate_dir(struct dirent **d, int num, struct dt_dir *dt)
 		case DT_DIR:
 			subdir = malloc(sizeof(*subdir));
 			if (!subdir) {
-				perror("malloc");
+				DPAAX_LOG(ERR, "malloc failed");
 				return -ENOMEM;
 			}
 			strlcpy(subdir->node.node.name, d[loop]->d_name,
-- 
2.51.0


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2025-12-28 20:17 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-12-28 20:10 [PATCH 0/4] Avoid using perror Stephen Hemminger
2025-12-28 20:10 ` [PATCH 1/4] checkpatches: warn if perror is used Stephen Hemminger
2025-12-28 20:10 ` [PATCH 2/4] bus/dpaa: replace perror with log Stephen Hemminger
2025-12-28 20:10 ` [PATCH 3/4] telemetry: " Stephen Hemminger
2025-12-28 20:10 ` [PATCH 4/4] common/dpaax: replace use of " Stephen Hemminger

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).