[5/8] trace: remove unneeded checks in internal API

Message ID 20200503203135.6493-6-david.marchand@redhat.com (mailing list archive)
State Accepted, archived
Delegated to: David Marchand
Headers
Series Traces cleanup for rc2 |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

David Marchand May 3, 2020, 8:31 p.m. UTC
  The trace framework can be configured via 4 EAL options:
- --trace which calls eal_trace_args_save,
- --trace-dir which calls eal_trace_dir_args_save,
- --trace-bufsz which calls eal_trace_bufsz_args_save,
- --trace-mode which calls eal_trace_mode_args_save.

Those 4 internal callbacks are getting passed a non NULL value:
optarg won't be NULL since those options are declared with
required_argument (man getopt_long).

eal_trace_bufsz_args_save() already trusted passed value, align the other
3 internal callbacks.

Coverity issue: 357768
Fixes: 8c8066ea6a7b ("trace: add trace mode configuration parameter")

Signed-off-by: David Marchand <david.marchand@redhat.com>
---
 lib/librte_eal/common/eal_common_trace_utils.c | 15 ---------------
 1 file changed, 15 deletions(-)
  

Comments

Sunil Kumar Kori May 4, 2020, 8:16 a.m. UTC | #1
>-----Original Message-----
>From: David Marchand <david.marchand@redhat.com>
>Sent: Monday, May 4, 2020 2:02 AM
>To: dev@dpdk.org
>Cc: thomas@monjalon.net; Jerin Jacob Kollanukkaran <jerinj@marvell.com>;
>Sunil Kumar Kori <skori@marvell.com>
>Subject: [EXT] [PATCH 5/8] trace: remove unneeded checks in internal API
>
>External Email
>
>----------------------------------------------------------------------
>The trace framework can be configured via 4 EAL options:
>- --trace which calls eal_trace_args_save,
>- --trace-dir which calls eal_trace_dir_args_save,
>- --trace-bufsz which calls eal_trace_bufsz_args_save,
>- --trace-mode which calls eal_trace_mode_args_save.
>
>Those 4 internal callbacks are getting passed a non NULL value:
>optarg won't be NULL since those options are declared with
>required_argument (man getopt_long).
>
>eal_trace_bufsz_args_save() already trusted passed value, align the other
>3 internal callbacks.
>
>Coverity issue: 357768
>Fixes: 8c8066ea6a7b ("trace: add trace mode configuration parameter")
>
>Signed-off-by: David Marchand <david.marchand@redhat.com>
>---

Acked-by: Sunil Kumar Kori <skori@mavell.com>

[snip]
  

Patch

diff --git a/lib/librte_eal/common/eal_common_trace_utils.c b/lib/librte_eal/common/eal_common_trace_utils.c
index a7c5893b00..4077acf428 100644
--- a/lib/librte_eal/common/eal_common_trace_utils.c
+++ b/lib/librte_eal/common/eal_common_trace_utils.c
@@ -199,11 +199,6 @@  eal_trace_bufsz_args_save(char const *val)
 	struct trace *trace = trace_obj_get();
 	uint64_t bufsz;
 
-	if (val == NULL) {
-		trace_err("no optarg is passed");
-		return -EINVAL;
-	}
-
 	bufsz = rte_str_to_size(val);
 	if (bufsz == 0) {
 		trace_err("buffer size cannot be zero");
@@ -231,11 +226,6 @@  eal_trace_mode_args_save(const char *val)
 	unsigned long tmp;
 	char *pattern;
 
-	if (val == NULL) {
-		trace_err("no optarg is passed");
-		return -EINVAL;
-	}
-
 	if (len == 0) {
 		trace_err("value is not provided with option");
 		return -EINVAL;
@@ -271,11 +261,6 @@  eal_trace_dir_args_save(char const *val)
 	char *dir_path = NULL;
 	int rc;
 
-	if (val == NULL) {
-		trace_err("no optarg is passed");
-		return -EINVAL;
-	}
-
 	if (strlen(val) >= size) {
 		trace_err("input string is too big");
 		return -ENAMETOOLONG;