git.droids-corp.org
/
dpdk.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
eal/windows: add missing SPDX license tag
[dpdk.git]
/
lib
/
librte_eal
/
common
/
eal_common_trace_utils.c
diff --git
a/lib/librte_eal/common/eal_common_trace_utils.c
b/lib/librte_eal/common/eal_common_trace_utils.c
index
eed861e
..
64f58fb
100644
(file)
--- a/
lib/librte_eal/common/eal_common_trace_utils.c
+++ b/
lib/librte_eal/common/eal_common_trace_utils.c
@@
-245,22
+245,19
@@
int
eal_trace_dir_args_save(char const *val)
{
struct trace *trace = trace_obj_get();
eal_trace_dir_args_save(char const *val)
{
struct trace *trace = trace_obj_get();
- uint32_t size = sizeof(trace->dir);
- char *dir_path = NULL;
+ char *dir_path;
int rc;
int rc;
- if (strlen(val) >= size) {
+ if (strlen(val) >= size
of(trace->dir) - 1
) {
trace_err("input string is too big");
return -ENAMETOOLONG;
}
trace_err("input string is too big");
return -ENAMETOOLONG;
}
- dir_path = (char *)calloc(1, size);
- if (dir_path == NULL) {
- trace_err("fail to allocate memory");
+ if (asprintf(&dir_path, "%s/", val) == -1) {
+ trace_err("failed to copy directory: %s", strerror(errno));
return -ENOMEM;
}
return -ENOMEM;
}
- sprintf(dir_path, "%s/", val);
rc = trace_dir_update(dir_path);
free(dir_path);
rc = trace_dir_update(dir_path);
free(dir_path);