eal/windows: add missing SPDX license tag
[dpdk.git] / lib / librte_eal / common / eal_common_trace_utils.c
index 77ea8f7..64f58fb 100644 (file)
@@ -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);