DPDK patches and discussions
 help / color / mirror / Atom feed
From: Adrien Mazarguil <adrien.mazarguil@6wind.com>
To: dev@dpdk.org
Cc: Nelio Laranjeiro <nelio.laranjeiro@6wind.com>,
	Wei Zhao <wei.zhao1@intel.com>,
	Beilei Xing <beilei.xing@intel.com>
Subject: [dpdk-dev] [PATCH 2/5] ethdev: modify flow API's error setting function
Date: Tue, 10 Jan 2017 14:08:27 +0100	[thread overview]
Message-ID: <dcddb91fcdffb3b964a5fc4ec08cf7e07b78f43d.1484046037.git.adrien.mazarguil@6wind.com> (raw)
In-Reply-To: <cover.1484046037.git.adrien.mazarguil@6wind.com>

Based on initial PMD implementations of the flow API, returning the error
structure which may be NULL is useless and always discarded.

Returning the error code instead appears to be much more convenient.

Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
Cc: Nelio Laranjeiro <nelio.laranjeiro@6wind.com>
Cc: Wei Zhao <wei.zhao1@intel.com>
Cc: Beilei Xing <beilei.xing@intel.com>
---
 lib/librte_ether/rte_flow.c        | 24 ++++++++++++------------
 lib/librte_ether/rte_flow_driver.h |  6 +++---
 2 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/lib/librte_ether/rte_flow.c b/lib/librte_ether/rte_flow.c
index d98fb1b..aaa70d6 100644
--- a/lib/librte_ether/rte_flow.c
+++ b/lib/librte_ether/rte_flow.c
@@ -78,9 +78,9 @@ rte_flow_validate(uint8_t port_id,
 		return -rte_errno;
 	if (likely(!!ops->validate))
 		return ops->validate(dev, attr, pattern, actions, error);
-	rte_flow_error_set(error, ENOSYS, RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
-			   NULL, rte_strerror(ENOSYS));
-	return -rte_errno;
+	return -rte_flow_error_set(error, ENOSYS,
+				   RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
+				   NULL, rte_strerror(ENOSYS));
 }
 
 /* Create a flow rule on a given port. */
@@ -116,9 +116,9 @@ rte_flow_destroy(uint8_t port_id,
 		return -rte_errno;
 	if (likely(!!ops->destroy))
 		return ops->destroy(dev, flow, error);
-	rte_flow_error_set(error, ENOSYS, RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
-			   NULL, rte_strerror(ENOSYS));
-	return -rte_errno;
+	return -rte_flow_error_set(error, ENOSYS,
+				   RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
+				   NULL, rte_strerror(ENOSYS));
 }
 
 /* Destroy all flow rules associated with a port. */
@@ -133,9 +133,9 @@ rte_flow_flush(uint8_t port_id,
 		return -rte_errno;
 	if (likely(!!ops->flush))
 		return ops->flush(dev, error);
-	rte_flow_error_set(error, ENOSYS, RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
-			   NULL, rte_strerror(ENOSYS));
-	return -rte_errno;
+	return -rte_flow_error_set(error, ENOSYS,
+				   RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
+				   NULL, rte_strerror(ENOSYS));
 }
 
 /* Query an existing flow rule. */
@@ -153,7 +153,7 @@ rte_flow_query(uint8_t port_id,
 		return -rte_errno;
 	if (likely(!!ops->query))
 		return ops->query(dev, flow, action, data, error);
-	rte_flow_error_set(error, ENOSYS, RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
-			   NULL, rte_strerror(ENOSYS));
-	return -rte_errno;
+	return -rte_flow_error_set(error, ENOSYS,
+				   RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
+				   NULL, rte_strerror(ENOSYS));
 }
diff --git a/lib/librte_ether/rte_flow_driver.h b/lib/librte_ether/rte_flow_driver.h
index cc97785..d020536 100644
--- a/lib/librte_ether/rte_flow_driver.h
+++ b/lib/librte_ether/rte_flow_driver.h
@@ -139,9 +139,9 @@ struct rte_flow_ops {
  *   Human-readable error message.
  *
  * @return
- *   Pointer to flow error structure.
+ *   Error code (\code).
  */
-static inline struct rte_flow_error *
+static inline int
 rte_flow_error_set(struct rte_flow_error *error,
 		   int code,
 		   enum rte_flow_error_type type,
@@ -156,7 +156,7 @@ rte_flow_error_set(struct rte_flow_error *error,
 		};
 	}
 	rte_errno = code;
-	return error;
+	return code;
 }
 
 /**
-- 
2.1.4

  parent reply	other threads:[~2017-01-10 13:08 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-10 13:08 [dpdk-dev] [PATCH 0/5] Assorted fixes for the flow API Adrien Mazarguil
2017-01-10 13:08 ` [dpdk-dev] [PATCH 1/5] app/testpmd: fix array bounds checks Adrien Mazarguil
2017-01-10 13:08 ` Adrien Mazarguil [this message]
2017-01-10 13:08 ` [dpdk-dev] [PATCH 3/5] ethdev: clarify MARK and FLAG actions in flow API Adrien Mazarguil
2017-01-10 13:08 ` [dpdk-dev] [PATCH 4/5] ethdev: clarify RSS action " Adrien Mazarguil
2017-01-10 13:08 ` [dpdk-dev] [PATCH 5/5] ethdev: define default item masks " Adrien Mazarguil
2017-01-11 15:57 ` [dpdk-dev] [PATCH 0/5] Assorted fixes for the " 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=dcddb91fcdffb3b964a5fc4ec08cf7e07b78f43d.1484046037.git.adrien.mazarguil@6wind.com \
    --to=adrien.mazarguil@6wind.com \
    --cc=beilei.xing@intel.com \
    --cc=dev@dpdk.org \
    --cc=nelio.laranjeiro@6wind.com \
    --cc=wei.zhao1@intel.com \
    /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).