[PATCH v3 2/4] eal: fix errno not set if strftime return zero
Chengwen Feng
fengchengwen at huawei.com
Fri Jun 17 04:29:11 CEST 2022
The trace_session_name_generate() takes errno as the return value, but
the errno was not set if strftime return zero, the previously set errno
is returned in this case, this will result in inaccurate prompting.
This patch sets errno to ENOSPC if strftime return zero to fix it.
Fixes: 321dd5f8fa62 ("trace: add internal init and fini interface")
Cc: stable at dpdk.org
Signed-off-by: Chengwen Feng <fengchengwen at huawei.com>
---
lib/eal/common/eal_common_trace_utils.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/lib/eal/common/eal_common_trace_utils.c b/lib/eal/common/eal_common_trace_utils.c
index 64f58fb66a..09f97d3c34 100644
--- a/lib/eal/common/eal_common_trace_utils.c
+++ b/lib/eal/common/eal_common_trace_utils.c
@@ -109,8 +109,10 @@ trace_session_name_generate(char *trace_dir)
rc = strftime(trace_dir + rc, TRACE_DIR_STR_LEN - rc,
"%Y-%m-%d-%p-%I-%M-%S", tm_result);
- if (rc == 0)
+ if (rc == 0) {
+ errno = ENOSPC;
goto fail;
+ }
return rc;
fail:
--
2.33.0
More information about the dev
mailing list