DPDK patches and discussions
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: dev@dpdk.org
Cc: Stephen Hemminger <stephen@networkplumber.org>
Subject: [dpdk-dev] [PATCH v2 1/3] cfgfile: remove unnecessary initialization
Date: Wed, 17 Jul 2019 17:48:20 -0700	[thread overview]
Message-ID: <20190718004822.25431-2-stephen@networkplumber.org> (raw)
In-Reply-To: <20190718004822.25431-1-stephen@networkplumber.org>

No need to initialize variable if it is immediately overwritten.
It is better style not do unnecessary initialization with modern
tools since it lets compiler and other static checkers detect
uninitialized data.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/librte_cfgfile/rte_cfgfile.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/lib/librte_cfgfile/rte_cfgfile.c b/lib/librte_cfgfile/rte_cfgfile.c
index f8e7627a5169..1ef298592fa5 100644
--- a/lib/librte_cfgfile/rte_cfgfile.c
+++ b/lib/librte_cfgfile/rte_cfgfile.c
@@ -160,9 +160,9 @@ struct rte_cfgfile *
 rte_cfgfile_load_with_params(const char *filename, int flags,
 			     const struct rte_cfgfile_parameters *params)
 {
-	char buffer[CFG_NAME_LEN + CFG_VALUE_LEN + 4] = {0};
+	char buffer[CFG_NAME_LEN + CFG_VALUE_LEN + 4];
 	int lineno = 0;
-	struct rte_cfgfile *cfg = NULL;
+	struct rte_cfgfile *cfg;
 
 	if (rte_cfgfile_check_params(params))
 		return NULL;
@@ -174,7 +174,7 @@ rte_cfgfile_load_with_params(const char *filename, int flags,
 	cfg = rte_cfgfile_create(flags);
 
 	while (fgets(buffer, sizeof(buffer), f) != NULL) {
-		char *pos = NULL;
+		char *pos;
 		size_t len = strnlen(buffer, sizeof(buffer));
 		lineno++;
 		if ((len >= sizeof(buffer) - 1) && (buffer[len-1] != '\n')) {
@@ -260,7 +260,7 @@ struct rte_cfgfile *
 rte_cfgfile_create(int flags)
 {
 	int i;
-	struct rte_cfgfile *cfg = NULL;
+	struct rte_cfgfile *cfg;
 
 	cfg = malloc(sizeof(*cfg));
 
-- 
2.17.1


  reply	other threads:[~2019-07-18  0:48 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-16 17:27 [dpdk-dev] [PATCH 0/3] cfgfile: cleanup patches Stephen Hemminger
2019-07-16 17:27 ` [dpdk-dev] [PATCH 1/3] cfgfile: remove unnecessary initialization Stephen Hemminger
2019-07-16 17:27 ` [dpdk-dev] [PATCH 2/3] cfgfile: use RTE_LOG for errors Stephen Hemminger
2019-07-17 21:01   ` Thomas Monjalon
2019-07-17 22:10     ` Stephen Hemminger
2019-07-16 17:27 ` [dpdk-dev] [PATCH 3/3] cfgfile: use calloc Stephen Hemminger
2019-07-17 13:38 ` [dpdk-dev] [PATCH 0/3] cfgfile: cleanup patches Bruce Richardson
2019-07-18  0:48 ` [dpdk-dev] [PATCH v2 " Stephen Hemminger
2019-07-18  0:48   ` Stephen Hemminger [this message]
2019-07-18  0:48   ` [dpdk-dev] [PATCH v2 2/3] cfgfile: use RTE_LOG for errors Stephen Hemminger
2019-07-18  8:31     ` Bruce Richardson
2019-07-18 14:34       ` Stephen Hemminger
2019-07-18 14:36         ` Bruce Richardson
2019-07-18 14:41           ` Stephen Hemminger
2019-07-18 17:12           ` Stephen Hemminger
2019-07-18  0:48   ` [dpdk-dev] [PATCH v2 3/3] cfgfile: use calloc Stephen Hemminger
2019-07-18 17:18 ` [dpdk-dev] [PATCH v3 0/3] cfgfile: cleanup patches Stephen Hemminger
2019-07-18 17:18   ` [dpdk-dev] [PATCH v3 1/3] cfgfile: remove unnecessary initialization Stephen Hemminger
2019-07-18 17:18   ` [dpdk-dev] [PATCH v3 2/3] cfgfile: use RTE_LOG for errors Stephen Hemminger
2019-07-18 22:39     ` Thomas Monjalon
2019-07-18 17:18   ` [dpdk-dev] [PATCH v3 3/3] cfgfile: use calloc Stephen Hemminger
2019-07-18 22:44   ` [dpdk-dev] [PATCH v3 0/3] cfgfile: cleanup patches Thomas Monjalon

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=20190718004822.25431-2-stephen@networkplumber.org \
    --to=stephen@networkplumber.org \
    --cc=dev@dpdk.org \
    /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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).