From: Stephen Hemminger Date: Thu, 18 Jul 2019 17:18:10 +0000 (-0700) Subject: cfgfile: remove unnecessary initialization X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=1b58407653efa1a69ba8872b2724263554b5e4f4;p=dpdk.git cfgfile: remove unnecessary initialization 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 --- diff --git a/lib/librte_cfgfile/rte_cfgfile.c b/lib/librte_cfgfile/rte_cfgfile.c index f8e7627a51..1ef298592f 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));