X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=lib%2Flibrte_eal%2Fcommon%2Feal_common_trace_utils.c;h=64f58fb66a1576b5c8d69e9b7d984fc7d0c49604;hb=84fb33fec179ea96f814aed9f658d5a2df20745d;hp=77ea8f78e14d9057c61552be5ecc332785267727;hpb=970a407648b39944b1fb15a5ebf4bc9f711f3690;p=dpdk.git diff --git a/lib/librte_eal/common/eal_common_trace_utils.c b/lib/librte_eal/common/eal_common_trace_utils.c index 77ea8f78e1..64f58fb66a 100644 --- a/lib/librte_eal/common/eal_common_trace_utils.c +++ b/lib/librte_eal/common/eal_common_trace_utils.c @@ -173,19 +173,11 @@ eal_trace_args_free(void) int trace_args_apply(const char *arg) { - char *str; - - str = strdup(arg); - if (str == NULL) - return -1; - - if (rte_trace_regexp(str, true) < 0) { - trace_err("cannot enable trace for %s", str); - free(str); + if (rte_trace_regexp(arg, true) < 0) { + trace_err("cannot enable trace for %s", arg); return -1; } - free(str); return 0; } @@ -253,22 +245,19 @@ int 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; - if (strlen(val) >= size) { + if (strlen(val) >= sizeof(trace->dir) - 1) { 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; } - sprintf(dir_path, "%s/", val); rc = trace_dir_update(dir_path); free(dir_path);