DPDK patches and discussions
 help / color / mirror / Atom feed
From: David Marchand <david.marchand@6wind.com>
To: dev@dpdk.org
Subject: [dpdk-dev] [PATCH 1/2] devargs: indent and cleanup
Date: Wed,  7 Jan 2015 14:03:28 +0100	[thread overview]
Message-ID: <1420635809-30976-2-git-send-email-david.marchand@6wind.com> (raw)
In-Reply-To: <1420635809-30976-1-git-send-email-david.marchand@6wind.com>

Prepare for next commit.
Fix some indent issues, refactor error code.

Signed-off-by: David Marchand <david.marchand@6wind.com>
---
 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

  reply	other threads:[~2015-01-07 13:03 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-07 13:03 [dpdk-dev] [PATCH 0/2] remove limit on devargs parameters length David Marchand
2015-01-07 13:03 ` David Marchand [this message]
2015-01-07 13:03 ` [dpdk-dev] [PATCH 2/2] devargs: remove limit on " David Marchand
2015-01-07 22:59   ` Stephen Hemminger
2015-01-08  8:19     ` David Marchand
2015-01-08  9:15     ` Panu Matilainen
2015-02-13 15:03 ` [dpdk-dev] [PATCH v2 0/3] remove limit on devargs " David Marchand
2015-02-13 15:03   ` [dpdk-dev] [PATCH v2 1/3] devargs: indent and cleanup David Marchand
2015-02-13 15:03   ` [dpdk-dev] [PATCH v2 2/3] devargs: remove limit on parameters length David Marchand
2015-02-13 15:03   ` [dpdk-dev] [PATCH v2 3/3] app/test: fix devargs tests David Marchand
2015-02-18 12:44   ` [dpdk-dev] [PATCH v2 0/3] remove limit on devargs parameters length Thomas Monjalon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1420635809-30976-2-git-send-email-david.marchand@6wind.com \
    --to=david.marchand@6wind.com \
    --cc=dev@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).