From: David Marchand Date: Fri, 13 Feb 2015 15:03:13 +0000 (+0100) Subject: devargs: indent and cleanup X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=0215a4c61f732e1dc07c50917f53da5004c66825;p=dpdk.git devargs: indent and cleanup Prepare for next commit. Fix some indent issues, refactor error code. Signed-off-by: David Marchand Acked-by: Thomas Monjalon --- diff --git a/lib/librte_eal/common/eal_common_devargs.c b/lib/librte_eal/common/eal_common_devargs.c index 4c7d11af13..8c9b31ace7 100644 --- a/lib/librte_eal/common/eal_common_devargs.c +++ b/lib/librte_eal/common/eal_common_devargs.c @@ -48,7 +48,7 @@ struct rte_devargs_list devargs_list = int rte_eal_devargs_add(enum rte_devtype devtype, const char *devargs_str) { - struct rte_devargs *devargs; + struct rte_devargs *devargs = NULL; char buf[RTE_DEVARGS_LEN]; char *sep; int ret; @@ -57,14 +57,14 @@ rte_eal_devargs_add(enum rte_devtype devtype, const char *devargs_str) if (ret < 0 || ret >= (int)sizeof(buf)) { RTE_LOG(ERR, EAL, "user device args too large: <%s>\n", devargs_str); - return -1; + goto fail; } /* use malloc instead of rte_malloc as it's called early at init */ devargs = malloc(sizeof(*devargs)); if (devargs == NULL) { RTE_LOG(ERR, EAL, "cannot allocate devargs\n"); - return -1; + goto fail; } memset(devargs, 0, sizeof(*devargs)); devargs->type = devtype; @@ -81,28 +81,29 @@ rte_eal_devargs_add(enum rte_devtype devtype, const char *devargs_str) case RTE_DEVTYPE_BLACKLISTED_PCI: /* try to parse pci identifier */ if (eal_parse_pci_BDF(buf, &devargs->pci.addr) != 0 && - eal_parse_pci_DomBDF(buf, &devargs->pci.addr) != 0) { - RTE_LOG(ERR, EAL, - "invalid PCI identifier <%s>\n", buf); - free(devargs); - return -1; + eal_parse_pci_DomBDF(buf, &devargs->pci.addr) != 0) { + RTE_LOG(ERR, EAL, "invalid PCI identifier <%s>\n", buf); + goto fail; } break; case RTE_DEVTYPE_VIRTUAL: /* save driver name */ ret = snprintf(devargs->virtual.drv_name, - sizeof(devargs->virtual.drv_name), "%s", buf); + sizeof(devargs->virtual.drv_name), "%s", buf); if (ret < 0 || ret >= (int)sizeof(devargs->virtual.drv_name)) { - RTE_LOG(ERR, EAL, - "driver name too large: <%s>\n", buf); - free(devargs); - return -1; + RTE_LOG(ERR, EAL, "driver name too large: <%s>\n", buf); + goto fail; } break; } TAILQ_INSERT_TAIL(&devargs_list, devargs, next); return 0; + +fail: + if (devargs) + free(devargs); + return -1; } /* count the number of devices of a specified type */