From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wi0-f181.google.com (mail-wi0-f181.google.com [209.85.212.181]) by dpdk.org (Postfix) with ESMTP id D83F0B4C9 for ; Fri, 13 Feb 2015 16:03:21 +0100 (CET) Received: by mail-wi0-f181.google.com with SMTP id r20so12758436wiv.2 for ; Fri, 13 Feb 2015 07:03:21 -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=lXeT41umdR8Z7yvzCqj+zi2k8l/7LfYHWVAVpsP6639/ldxkQulEjcEQ6b377nBr+y IUbYiTwgTBq6SacbOFqwrpBEpBfv2+pZKjtv7MS6u9f2il4TKfXn/ZWTdCasK32DnihY xBVuxp48EMHN0w8Z0VQ7Iqt1oFkYbonInHJAjq2IWPsNLNoyCcraCaVi0fNCLYr3shxm Hh1xkhZRB7eNdqqWX5NblzMmuKU85eHD4P+OkH1W28NtC/9uQnOnLpR/umo2YIjPgp7A 8LihcZA4BKF5tnQMWaBBKj8AcIDE7aHtOZ2SUhrl2ZW0y/HGLKW1iQ8IqFky04lByBuS KO5A== X-Gm-Message-State: ALoCoQn6KSwDn+wuBrJZ6UO0ZkKmzyQX9dZveS8ATW3poj8nLoRpGnog+dthH5tryTIaV5QdTohf X-Received: by 10.180.90.16 with SMTP id bs16mr7593166wib.16.1423839801697; Fri, 13 Feb 2015 07:03:21 -0800 (PST) Received: from alcyon.dev.6wind.com (6wind.net2.nerim.net. [213.41.180.237]) by mx.google.com with ESMTPSA id e18sm10413605wjz.27.2015.02.13.07.03.20 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 13 Feb 2015 07:03:20 -0800 (PST) From: David Marchand To: dev@dpdk.org Date: Fri, 13 Feb 2015 16:03:13 +0100 Message-Id: <1423839795-29450-2-git-send-email-david.marchand@6wind.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1423839795-29450-1-git-send-email-david.marchand@6wind.com> References: <1420635809-30976-1-git-send-email-david.marchand@6wind.com> <1423839795-29450-1-git-send-email-david.marchand@6wind.com> Subject: [dpdk-dev] [PATCH v2 1/3] 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: Fri, 13 Feb 2015 15:03:22 -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