X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;ds=sidebyside;f=lib%2Flibrte_cfgfile%2Frte_cfgfile.c;h=b54a523d2cda2afaad7818f5a29b2cff7b127c69;hb=463ced957c3f370e90e918bc75ff83166b70b31e;hp=4ef7decb363421989c092ac4a3055509c69a3b71;hpb=3f3d51ebc88bea669fbc3712da80f148cc12f6c5;p=dpdk.git diff --git a/lib/librte_cfgfile/rte_cfgfile.c b/lib/librte_cfgfile/rte_cfgfile.c index 4ef7decb36..b54a523d2c 100644 --- a/lib/librte_cfgfile/rte_cfgfile.c +++ b/lib/librte_cfgfile/rte_cfgfile.c @@ -258,12 +258,21 @@ rte_cfgfile_load_with_params(const char *filename, int flags, struct rte_cfgfile_section *sect = cfg->sections[curr_section]; - char *split[2]; - if (rte_strsplit(buffer, sizeof(buffer), split, 2, '=') - != 2) { - printf("Error at line %d - cannot split " - "string\n", lineno); - goto error1; + int n; + char *split[2] = {NULL}; + n = rte_strsplit(buffer, sizeof(buffer), split, 2, '='); + if (flags & CFG_FLAG_EMPTY_VALUES) { + if ((n < 1) || (n > 2)) { + printf("Error at line %d - cannot split string, n=%d\n", + lineno, n); + goto error1; + } + } else { + if (n != 2) { + printf("Error at line %d - cannot split string, n=%d\n", + lineno, n); + goto error1; + } } curr_entry++; @@ -293,7 +302,7 @@ rte_cfgfile_load_with_params(const char *filename, int flags, snprintf(entry->name, sizeof(entry->name), "%s", split[0]); snprintf(entry->value, sizeof(entry->value), "%s", - split[1]); + split[1] ? split[1] : ""); _strip(entry->name, strnlen(entry->name, sizeof(entry->name))); _strip(entry->value, strnlen(entry->value,