[v5,2/3] eal: return error code when failure

Message ID 0c755de289f228e67897818639a171cbf1d768ae.1603207676.git.wangyunjian@huawei.com (mailing list archive)
State Accepted, archived
Delegated to: David Marchand
Headers
Series fixes for device event |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Yunjian Wang Oct. 21, 2020, 11:19 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

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

Comments

David Marchand Oct. 22, 2020, 12:51 p.m. UTC | #1
On Wed, Oct 21, 2020 at 1:19 PM wangyunjian <wangyunjian@huawei.com> 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

This API is experimental, its description is vague enough and we can
change it in the current release.
But I see this as a change in behavior for existing users, not a fix
and I would not backport it.

Opinions?


>
> Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
> Acked-by: Jeff Guo <jia.guo@intel.com>
> ---
>  lib/librte_eal/common/eal_common_dev.c | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/lib/librte_eal/common/eal_common_dev.c b/lib/librte_eal/common/eal_common_dev.c
> index 363a2ca95e..d990bfd20d 100644
> --- a/lib/librte_eal/common/eal_common_dev.c
> +++ b/lib/librte_eal/common/eal_common_dev.c
> @@ -530,9 +530,15 @@ rte_dev_event_callback_unregister(const char *device_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;
>  }
> --
> 2.23.0
>
  
Yunjian Wang Oct. 23, 2020, 9:05 a.m. UTC | #2
> -----Original Message-----
> From: David Marchand [mailto:david.marchand@redhat.com]
> Sent: Thursday, October 22, 2020 8:52 PM
> To: wangyunjian <wangyunjian@huawei.com>
> Cc: dev <dev@dpdk.org>; Jeff Guo <jia.guo@intel.com>; Jerin Jacob
> Kollanukkaran <jerinj@marvell.com>; Lilijun (Jerry) <jerry.lilijun@huawei.com>;
> xudingke <xudingke@huawei.com>; dpdk stable <stable@dpdk.org>; Kevin
> Traynor <ktraynor@redhat.com>; Luca Boccassi <bluca@debian.org>
> Subject: Re: [dpdk-dev] [PATCH v5 2/3] eal: return error code when failure
> 
> On Wed, Oct 21, 2020 at 1:19 PM wangyunjian <wangyunjian@huawei.com>
> 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
> 
> This API is experimental, its description is vague enough and we can change it
> in the current release.
> But I see this as a change in behavior for existing users, not a fix and I would
> not backport it.
> 
> Opinions?

Agree, not backport it.

Yunjian

> 
> 
> >
> > Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
> > Acked-by: Jeff Guo <jia.guo@intel.com>
> > ---
> >  lib/librte_eal/common/eal_common_dev.c | 8 +++++++-
> >  1 file changed, 7 insertions(+), 1 deletion(-)
> >
> > diff --git a/lib/librte_eal/common/eal_common_dev.c
> > b/lib/librte_eal/common/eal_common_dev.c
> > index 363a2ca95e..d990bfd20d 100644
> > --- a/lib/librte_eal/common/eal_common_dev.c
> > +++ b/lib/librte_eal/common/eal_common_dev.c
> > @@ -530,9 +530,15 @@ rte_dev_event_callback_unregister(const char
> *device_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;
> >  }
> > --
> > 2.23.0
> >
> 
> 
> --
> David Marchand
  

Patch

diff --git a/lib/librte_eal/common/eal_common_dev.c b/lib/librte_eal/common/eal_common_dev.c
index 363a2ca95e..d990bfd20d 100644
--- a/lib/librte_eal/common/eal_common_dev.c
+++ b/lib/librte_eal/common/eal_common_dev.c
@@ -530,9 +530,15 @@  rte_dev_event_callback_unregister(const char *device_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;
 }