From: David Marchand Date: Tue, 24 Feb 2015 09:41:31 +0000 (+0100) Subject: devargs: restore empty devargs X-Git-Tag: spdx-start~9563 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=23df14d1baf53eb014207f438beee81677d46186;p=dpdk.git devargs: restore empty devargs Following commit c07691ae1089, an implicit change has been done in the devargs API. This triggers problem in virtual pmds that did not check for parameters validity as it was implicitely valid. Fix this by restoring the empty argument as "" and add a note in the api. Restore associated tests. Fixes: c07691ae1089 ("devargs: remove limit on parameters length") Reported-by: Tetsuya Mukawa Signed-off-by: David Marchand Tested-by: Tetsuya Mukawa --- diff --git a/app/test/test_devargs.c b/app/test/test_devargs.c index 08fb7812d2..f7fc59cdf4 100644 --- a/app/test/test_devargs.c +++ b/app/test/test_devargs.c @@ -107,7 +107,7 @@ test_devargs(void) devargs->pci.addr.devid != 0 || devargs->pci.addr.function != 1) goto fail; - if (devargs->args) + if (!devargs->args || strcmp(devargs->args, "") != 0) goto fail; free_devargs_list(); diff --git a/lib/librte_eal/common/eal_common_devargs.c b/lib/librte_eal/common/eal_common_devargs.c index 3aace0838a..eadd71975c 100644 --- a/lib/librte_eal/common/eal_common_devargs.c +++ b/lib/librte_eal/common/eal_common_devargs.c @@ -73,10 +73,13 @@ rte_eal_devargs_add(enum rte_devtype devtype, const char *devargs_str) if (sep != NULL) { sep[0] = '\0'; devargs->args = strdup(sep + 1); - if (devargs->args == NULL) { - RTE_LOG(ERR, EAL, "cannot allocate for devargs args\n"); - goto fail; - } + } else { + devargs->args = strdup(""); + } + + if (devargs->args == NULL) { + RTE_LOG(ERR, EAL, "cannot allocate for devargs args\n"); + goto fail; } switch (devargs->type) { diff --git a/lib/librte_eal/common/include/rte_devargs.h b/lib/librte_eal/common/include/rte_devargs.h index 996e180537..68343339dc 100644 --- a/lib/librte_eal/common/include/rte_devargs.h +++ b/lib/librte_eal/common/include/rte_devargs.h @@ -88,7 +88,7 @@ struct rte_devargs { char drv_name[32]; } virtual; }; - /** Arguments string as given by user. */ + /** Arguments string as given by user or "" for no argument. */ char *args; };