diff mbox series

[3/3] eal: return error code when failure

Message ID 65433c2a9efdb47b1c9dba63d9bd1cb160e08097.1591186247.git.wangyunjian@huawei.com (mailing list archive)
State Superseded, archived
Delegated to: David Marchand
Headers show
Series fixes for device event | expand

Checks

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

Commit Message

Yunjian Wang June 3, 2020, 12:55 p.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

Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
---
 lib/librte_eal/common/eal_common_dev.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

Comments

Guo, Jia July 2, 2020, 9:18 a.m. UTC | #1
hi, yunjian

On 6/3/2020 8:55 PM, wangyunjian wrote:
> 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
>
> Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
> ---
>   lib/librte_eal/common/eal_common_dev.c | 7 ++++++-
>   1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/lib/librte_eal/common/eal_common_dev.c b/lib/librte_eal/common/eal_common_dev.c
> index 6b465bc..5f5e333 100644
> --- a/lib/librte_eal/common/eal_common_dev.c
> +++ b/lib/librte_eal/common/eal_common_dev.c
> @@ -536,9 +536,14 @@ static int cmp_dev_name(const struct rte_device *dev, const void *_name)
>   			free(event_cb);
>   			ret++;
>   		} else {
> -			continue;
> +			ret = -EAGAIN;
> +			break;
>   		}
>   	}


Suggest add a blank line here if there will be another version.


> +	/* this callback is not be registered */
> +	if (ret == 0)
> +		ret = -ENOENT;
> +
>   	rte_spinlock_unlock(&dev_event_lock);
>   	return ret;
>   }

Look good and thanks.

Acked-by: Jeff Guo <jia.guo@intel.com>
Yunjian Wang July 2, 2020, 10:43 a.m. UTC | #2
> -----Original Message-----
> From: Jeff Guo [mailto:jia.guo@intel.com]
> Sent: Thursday, July 2, 2020 5:19 PM
> To: wangyunjian <wangyunjian@huawei.com>; dev@dpdk.org
> Cc: Lilijun (Jerry) <jerry.lilijun@huawei.com>; xudingke
> <xudingke@huawei.com>; stable@dpdk.org
> Subject: Re: [dpdk-dev] [PATCH 3/3] eal: return error code when failure
> 
> hi, yunjian
> 
> On 6/3/2020 8:55 PM, wangyunjian wrote:
> > 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
> >
> > Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
> > ---
> >   lib/librte_eal/common/eal_common_dev.c | 7 ++++++-
> >   1 file changed, 6 insertions(+), 1 deletion(-)
> >
> > diff --git a/lib/librte_eal/common/eal_common_dev.c
> > b/lib/librte_eal/common/eal_common_dev.c
> > index 6b465bc..5f5e333 100644
> > --- a/lib/librte_eal/common/eal_common_dev.c
> > +++ b/lib/librte_eal/common/eal_common_dev.c
> > @@ -536,9 +536,14 @@ static int cmp_dev_name(const struct rte_device
> *dev, const void *_name)
> >   			free(event_cb);
> >   			ret++;
> >   		} else {
> > -			continue;
> > +			ret = -EAGAIN;
> > +			break;
> >   		}
> >   	}
> 
> 
> Suggest add a blank line here if there will be another version.

Thanks, I will fix it in next version.

Yunjian

> 
> 
> > +	/* this callback is not be registered */
> > +	if (ret == 0)
> > +		ret = -ENOENT;
> > +
> >   	rte_spinlock_unlock(&dev_event_lock);
> >   	return ret;
> >   }
> 
> Look good and thanks.
> 
> Acked-by: Jeff Guo <jia.guo@intel.com>
diff mbox series

Patch

diff --git a/lib/librte_eal/common/eal_common_dev.c b/lib/librte_eal/common/eal_common_dev.c
index 6b465bc..5f5e333 100644
--- a/lib/librte_eal/common/eal_common_dev.c
+++ b/lib/librte_eal/common/eal_common_dev.c
@@ -536,9 +536,14 @@  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;
 }