From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wg0-f41.google.com (mail-wg0-f41.google.com [74.125.82.41]) by dpdk.org (Postfix) with ESMTP id 8F8745A66 for ; Wed, 7 Jan 2015 14:03:37 +0100 (CET) Received: by mail-wg0-f41.google.com with SMTP id l18so1156930wgh.0 for ; Wed, 07 Jan 2015 05:03:37 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=vwe5ViVz7fIiespbpIbLBc9UgosaI6xGf0EgHaizTtY=; b=TksneaLcHSr86/iyeDzjn9T5xXpJtl9IUqKIEXl1zFEdiUTCgbqFXSnH+Yl7pBfAdX 1r8ykyT5j0qhqRh6SW0NOxQ741Lgxi+KvmO1CjMRpA82LgNDyGabI+7cq2+KJUpY2ET4 /AsyBCkUhE/+s0BaWhAwmNdl3QefU982D/kcrz0j+XLluxvqjrHFTyfou3OSYUebrwWG o3xpGI38s0Eqx2mjgoY2iVkRVYy7q3y/7fANUVlUtEZUtmbNT2OUjCuGlQfdwPc4ewQo wBgkp8z47Ka4yFSxvSCfixtgJ9wbJ4AYa4Mjw0d+jkhGXkYNxgf4pozoj8ERgFG7zPnM j+3Q== X-Gm-Message-State: ALoCoQmE5xYoSyy8RTPdbubKjZy+cDfi35aMQXSbIcTFK9OlxGUQxgWFzS/Ifgs/K4GP03DxF9q8 X-Received: by 10.180.75.176 with SMTP id d16mr7082854wiw.77.1420635817307; Wed, 07 Jan 2015 05:03:37 -0800 (PST) Received: from alcyon.dev.6wind.com (guy78-3-82-239-227-177.fbx.proxad.net. [82.239.227.177]) by mx.google.com with ESMTPSA id eu8sm2476343wib.21.2015.01.07.05.03.35 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 07 Jan 2015 05:03:36 -0800 (PST) From: David Marchand To: dev@dpdk.org Date: Wed, 7 Jan 2015 14:03:28 +0100 Message-Id: <1420635809-30976-2-git-send-email-david.marchand@6wind.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1420635809-30976-1-git-send-email-david.marchand@6wind.com> References: <1420635809-30976-1-git-send-email-david.marchand@6wind.com> Subject: [dpdk-dev] [PATCH 1/2] devargs: indent and cleanup X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 07 Jan 2015 13:03:38 -0000 Prepare for next commit. Fix some indent issues, refactor error code. Signed-off-by: David Marchand --- lib/librte_eal/common/eal_common_devargs.c | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/lib/librte_eal/common/eal_common_devargs.c b/lib/librte_eal/common/eal_common_devargs.c index 4c7d11a..8c9b31a 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 */ -- 1.7.10.4