Thread (30 messages) 30 messages, 8 authors, 2021-12-09

Re: [PATCH v1] gpudev: return EINVAL if invalid input pointer for free and unregister

From: Bruce Richardson <hidden>
Date: 2021-11-19 10:15:42

On Fri, Nov 19, 2021 at 09:34:08AM +0000, Ferruh Yigit wrote:
On 11/18/2021 8:19 PM, Tyler Retzlaff wrote:
quoted
On Thu, Nov 18, 2021 at 07:28:02PM +0000, eagostini@nvidia.com wrote:
quoted
From: Elena Agostini <redacted>

Signed-off-by: Elena Agostini <redacted>
---
  lib/gpudev/gpudev.c     | 10 ++++++++++
  lib/gpudev/rte_gpudev.h |  2 ++
  2 files changed, 12 insertions(+)
diff --git a/lib/gpudev/gpudev.c b/lib/gpudev/gpudev.c
index 2b174d8bd5..97575ed979 100644
--- a/lib/gpudev/gpudev.c
+++ b/lib/gpudev/gpudev.c
@@ -576,6 +576,11 @@ rte_gpu_mem_free(int16_t dev_id, void *ptr)
  		return -rte_errno;
  	}
+	if (ptr == NULL) {
+		rte_errno = EINVAL;
+		return -rte_errno;
+	}
in general dpdk has real problems with how it indicates that an error
occurred and what error occurred consistently.

some api's return 0 on success
   and maybe return -errno if ! 0
   and maybe return errno if ! 0
   and maybe set rte_errno if ! 0

some api's return -1 on failure
   and set rte_errno if -1

some api's return < 0 on failure
   and maybe set rte_errno
   and maybe return -errno
   and maybe set rte_errno and return -rte_errno
This is a generic comment, cc'ed a few more folks to make the comment more
visible.
Yes, it's inconsistent. However, this only applies to functions which
return integer values. Other functions which return pointer values are
hopefully standardized to return NULL on error. [Which means any error code
must be in rte_errno.]

/Bruce
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help