DPDK patches and discussions
 help / color / mirror / Atom feed
From: David Marchand <david.marchand@redhat.com>
To: dev@dpdk.org
Cc: thomas@monjalon.net, Jerin Jacob <jerinj@marvell.com>,
	Sunil Kumar Kori <skori@marvell.com>
Subject: [dpdk-dev] [PATCH 4/8] trace: avoid confusion on optarg
Date: Sun,  3 May 2020 22:31:31 +0200
Message-ID: <20200503203135.6493-5-david.marchand@redhat.com> (raw)
In-Reply-To: <20200503203135.6493-1-david.marchand@redhat.com>

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 <david.marchand@redhat.com>
---
 .../common/eal_common_trace_utils.c           | 32 +++++++++----------
 lib/librte_eal/common/eal_trace.h             |  8 ++---
 2 files changed, 20 insertions(+), 20 deletions(-)

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 @@ trace_dir_update(const char *str)
 }
 
 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 */
-- 
2.23.0


  parent reply	other threads:[~2020-05-03 20:32 UTC|newest]

Thread overview: 55+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-03 20:31 [dpdk-dev] [PATCH 0/8] Traces cleanup for rc2 David Marchand
2020-05-03 20:31 ` [dpdk-dev] [PATCH 1/8] cryptodev: fix trace points registration David Marchand
2020-05-04  7:41   ` [dpdk-dev] [EXT] " Sunil Kumar Kori
2020-05-03 20:31 ` [dpdk-dev] [PATCH 2/8] trace: simplify trace point registration David Marchand
2020-05-04  2:46   ` Jerin Jacob
2020-05-04 14:02     ` Thomas Monjalon
2020-05-04 14:04     ` David Marchand
2020-05-04 14:39       ` Jerin Jacob
2020-05-04 17:08         ` David Marchand
2020-05-04 17:19           ` Jerin Jacob
2020-05-04 17:40             ` David Marchand
2020-05-04 17:54               ` Jerin Jacob
2020-05-04 21:31                 ` Thomas Monjalon
2020-05-05  3:43                   ` Jerin Jacob
2020-05-05  7:01                     ` Thomas Monjalon
2020-05-05  7:17                       ` Jerin Jacob
2020-05-05  7:24                         ` Thomas Monjalon
2020-05-05  7:33                           ` Jerin Jacob
2020-05-05  8:23                             ` David Marchand
2020-05-05 10:12                               ` Jerin Jacob
2020-05-05 10:26                                 ` Thomas Monjalon
2020-05-05 10:46                                   ` Jerin Jacob
2020-05-05 11:48                                     ` Olivier Matz
2020-05-05 11:35                                 ` David Marchand
2020-05-05 12:26                                   ` Jerin Jacob
2020-05-05 15:25                                     ` Jerin Jacob
2020-05-05 16:28                                       ` David Marchand
2020-05-05 16:46                                         ` Jerin Jacob
2020-05-05 16:58                                           ` Thomas Monjalon
2020-05-05 17:08                                             ` Jerin Jacob
2020-05-05 17:09                                               ` Jerin Jacob
2020-05-05 17:20                                                 ` Thomas Monjalon
2020-05-05 17:28                                                   ` Jerin Jacob
2020-05-05 20:10                                                     ` Thomas Monjalon
2020-05-06  6:11                                                       ` Jerin Jacob
2020-07-04 14:31   ` Jerin Jacob
2020-07-04 15:14   ` [dpdk-dev] [PATCH v2] " David Marchand
2020-07-05 19:41     ` Thomas Monjalon
2020-05-03 20:31 ` [dpdk-dev] [PATCH 3/8] trace: simplify trace point headers David Marchand
2020-05-04  6:12   ` Jerin Jacob
2020-05-03 20:31 ` David Marchand [this message]
2020-05-04  7:55   ` [dpdk-dev] [EXT] [PATCH 4/8] trace: avoid confusion on optarg Sunil Kumar Kori
2020-05-04 14:09     ` David Marchand
2020-05-05  5:45       ` Sunil Kumar Kori
2020-05-05  5:47         ` Sunil Kumar Kori
2020-05-03 20:31 ` [dpdk-dev] [PATCH 5/8] trace: remove unneeded checks in internal API David Marchand
2020-05-04  8:16   ` [dpdk-dev] [EXT] " Sunil Kumar Kori
2020-05-03 20:31 ` [dpdk-dev] [PATCH 6/8] trace: remove limitation on patterns number David Marchand
2020-05-04  8:48   ` [dpdk-dev] [EXT] " Sunil Kumar Kori
2020-05-04 14:14     ` David Marchand
2020-05-05  5:54       ` Sunil Kumar Kori
2020-05-03 20:31 ` [dpdk-dev] [PATCH 7/8] trace: remove string duplication David Marchand
2020-05-04  9:01   ` [dpdk-dev] [EXT] " Sunil Kumar Kori
2020-05-03 20:31 ` [dpdk-dev] [PATCH 8/8] trace: fix build with gcc 10 David Marchand
2020-05-06 13:06 ` [dpdk-dev] [PATCH 0/8] Traces cleanup for rc2 David Marchand

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200503203135.6493-5-david.marchand@redhat.com \
    --to=david.marchand@redhat.com \
    --cc=dev@dpdk.org \
    --cc=jerinj@marvell.com \
    --cc=skori@marvell.com \
    --cc=thomas@monjalon.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

DPDK patches and discussions

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://inbox.dpdk.org/dev/0 dev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 dev dev/ https://inbox.dpdk.org/dev \
		dev@dpdk.org
	public-inbox-index dev

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://inbox.dpdk.org/inbox.dpdk.dev


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git