[v4,2/3] eal: return error code when failure
diff mbox series

Message ID cc0b1a2ef0725cd3c05be33e7f4798beb7d3a47e.1593768308.git.wangyunjian@huawei.com
State New
Delegated to: David Marchand
Headers show
Series
  • fixes for device event
Related show

Checks

Context Check Description
ci/Intel-compilation success Compilation OK
ci/checkpatch success coding style OK

Commit Message

wangyunjian July 3, 2020, 9:46 a.m. UTC
From: Yunjian Wang <wangyunjian@huawei.com>

Fix return value, using -EAGAIN instead of 0 when the callback is busy
and using -ENOENT instead of 0 when the callback is not found.

Fixes: a753e53d517b ("eal: add device event monitor framework")
Cc: stable@dpdk.org

Acked-by: Jeff Guo <jia.guo@intel.com>
Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
---
 lib/librte_eal/common/eal_common_dev.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

Patch
diff mbox series

diff --git a/lib/librte_eal/common/eal_common_dev.c b/lib/librte_eal/common/eal_common_dev.c
index 363a2ca..d990bfd 100644
--- a/lib/librte_eal/common/eal_common_dev.c
+++ b/lib/librte_eal/common/eal_common_dev.c
@@ -530,9 +530,15 @@  static int cmp_dev_name(const struct rte_device *dev, const void *_name)
 			free(event_cb);
 			ret++;
 		} else {
-			continue;
+			ret = -EAGAIN;
+			break;
 		}
 	}
+
+	/* this callback is not be registered */
+	if (ret == 0)
+		ret = -ENOENT;
+
 	rte_spinlock_unlock(&dev_event_lock);
 	return ret;
 }