From: David Marchand Date: Thu, 30 Apr 2020 17:27:16 +0000 (+0200) Subject: trace: avoid confusion on optarg X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=b86aebcb6f22a3f282eaa5624764f827988b48b9;p=dpdk.git trace: avoid confusion on optarg Prefer a local name to optarg which is a global symbol from the C library. Fixes: 8c8066ea6a7b ("trace: add trace mode configuration parameter") Signed-off-by: David Marchand Acked-by: Sunil Kumar Kori --- diff --git a/lib/librte_eal/common/eal_common_trace_utils.c b/lib/librte_eal/common/eal_common_trace_utils.c index fce8892c38..a7c5893b00 100644 --- a/lib/librte_eal/common/eal_common_trace_utils.c +++ b/lib/librte_eal/common/eal_common_trace_utils.c @@ -135,7 +135,7 @@ fail: } int -eal_trace_args_save(const char *optarg) +eal_trace_args_save(const char *val) { struct trace *trace = trace_obj_get(); char *trace_args; @@ -144,17 +144,17 @@ eal_trace_args_save(const char *optarg) nb_args = trace->args.nb_args; if (nb_args >= TRACE_MAX_ARGS) { - trace_err("ignoring trace %s as limit exceeds", optarg); + trace_err("ignoring trace %s as limit exceeds", val); return 0; } - trace_args = calloc(1, (strlen(optarg) + 1)); + trace_args = calloc(1, (strlen(val) + 1)); if (trace_args == NULL) { - trace_err("fail to allocate memory for %s", optarg); + trace_err("fail to allocate memory for %s", val); return -ENOMEM; } - memcpy(trace_args, optarg, strlen(optarg)); + memcpy(trace_args, val, strlen(val)); trace->args.args[nb_args++] = trace_args; trace->args.nb_args = nb_args; return 0; @@ -194,17 +194,17 @@ trace_args_apply(const char *arg) } int -eal_trace_bufsz_args_save(char const *optarg) +eal_trace_bufsz_args_save(char const *val) { struct trace *trace = trace_obj_get(); uint64_t bufsz; - if (optarg == NULL) { + if (val == NULL) { trace_err("no optarg is passed"); return -EINVAL; } - bufsz = rte_str_to_size(optarg); + bufsz = rte_str_to_size(val); if (bufsz == 0) { trace_err("buffer size cannot be zero"); return -EINVAL; @@ -224,14 +224,14 @@ trace_bufsz_args_apply(void) } int -eal_trace_mode_args_save(const char *optarg) +eal_trace_mode_args_save(const char *val) { struct trace *trace = trace_obj_get(); - size_t len = strlen(optarg); + size_t len = strlen(val); unsigned long tmp; char *pattern; - if (optarg == NULL) { + if (val == NULL) { trace_err("no optarg is passed"); return -EINVAL; } @@ -247,7 +247,7 @@ eal_trace_mode_args_save(const char *optarg) return -ENOMEM; } - sprintf(pattern, "%s*", optarg); + sprintf(pattern, "%s*", val); if (fnmatch(pattern, "overwrite", 0) == 0) tmp = RTE_TRACE_MODE_OVERWRITE; @@ -264,19 +264,19 @@ eal_trace_mode_args_save(const char *optarg) } int -eal_trace_dir_args_save(char const *optarg) +eal_trace_dir_args_save(char const *val) { struct trace *trace = trace_obj_get(); uint32_t size = sizeof(trace->dir); char *dir_path = NULL; int rc; - if (optarg == NULL) { + if (val == NULL) { trace_err("no optarg is passed"); return -EINVAL; } - if (strlen(optarg) >= size) { + if (strlen(val) >= size) { trace_err("input string is too big"); return -ENAMETOOLONG; } @@ -287,7 +287,7 @@ eal_trace_dir_args_save(char const *optarg) return -ENOMEM; } - sprintf(dir_path, "%s/", optarg); + sprintf(dir_path, "%s/", val); rc = trace_dir_update(dir_path); free(dir_path); diff --git a/lib/librte_eal/common/eal_trace.h b/lib/librte_eal/common/eal_trace.h index f53ccc0d50..7d95bd2aa9 100644 --- a/lib/librte_eal/common/eal_trace.h +++ b/lib/librte_eal/common/eal_trace.h @@ -111,10 +111,10 @@ void trace_mem_per_thread_free(void); /* EAL interface */ int eal_trace_init(void); void eal_trace_fini(void); -int eal_trace_args_save(const char *optarg); +int eal_trace_args_save(const char *val); void eal_trace_args_free(void); -int eal_trace_dir_args_save(const char *optarg); -int eal_trace_mode_args_save(const char *optarg); -int eal_trace_bufsz_args_save(const char *optarg); +int eal_trace_dir_args_save(const char *val); +int eal_trace_mode_args_save(const char *val); +int eal_trace_bufsz_args_save(const char *val); #endif /* __EAL_TRACE_H */