[dpdk-dev,09/13] eal: replace rte_panic instances in common_memzone

Message ID 1522841257-11826-10-git-send-email-arnon@qwilt.com (mailing list archive)
State Superseded, archived
Headers

Checks

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

Commit Message

Arnon Warshavsky April 4, 2018, 11:27 a.m. UTC
  replace panic calls with log and retrun value.

Signed-off-by: Arnon Warshavsky <arnon@qwilt.com>
---
 lib/librte_eal/common/eal_common_memzone.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
  

Comments

Anatoly Burakov April 4, 2018, 12:09 p.m. UTC | #1
On 04-Apr-18 12:27 PM, Arnon Warshavsky wrote:
> replace panic calls with log and retrun value.
> 
> Signed-off-by: Arnon Warshavsky <arnon@qwilt.com>
> ---
>   lib/librte_eal/common/eal_common_memzone.c | 5 +++--
>   1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/lib/librte_eal/common/eal_common_memzone.c b/lib/librte_eal/common/eal_common_memzone.c
> index 1ab3ade..fa0a407 100644
> --- a/lib/librte_eal/common/eal_common_memzone.c
> +++ b/lib/librte_eal/common/eal_common_memzone.c
> @@ -314,8 +314,9 @@
>   	if (addr == NULL)
>   		ret = -EINVAL;
>   	else if (mcfg->memzone_cnt == 0) {
> -		rte_panic("%s(): memzone address not NULL but memzone_cnt is 0!\n",
> -				__func__);
> +		RTE_LOG(CRIT, EAL, "%s(): memzone address not NULL but memzone_cnt"
> +				" is 0!\n", __func__);
> +		return -1;
>   	} else {
>   		memset(&mcfg->memzone[idx], 0, sizeof(mcfg->memzone[idx]));
>   		mcfg->memzone_cnt--;
> 

This changes public API. For now, memzone docs mention either return 
value of 0, or return value of -EINVAL in case of invalid arguments:

/**
  * Free a memzone.
  *
  * @param mz
  *   A pointer to the memzone
  * @return
  *  -EINVAL - invalid parameter.
  *  0 - success
  */

I'm not sure returning -EINVAL is suitable in this case (the parameter 
was valid, but an internal error happened - I can't think of any 
suitable errno value off hand), and adding a new return value changes 
API, which presumably would require a deprecation notice.

Thomas?
  
Thomas Monjalon April 4, 2018, 12:34 p.m. UTC | #2
04/04/2018 14:09, Burakov, Anatoly:
> On 04-Apr-18 12:27 PM, Arnon Warshavsky wrote:
> > replace panic calls with log and retrun value.
> > 
> > Signed-off-by: Arnon Warshavsky <arnon@qwilt.com>
> > ---
> >   lib/librte_eal/common/eal_common_memzone.c | 5 +++--
> >   1 file changed, 3 insertions(+), 2 deletions(-)
> > 
> > diff --git a/lib/librte_eal/common/eal_common_memzone.c b/lib/librte_eal/common/eal_common_memzone.c
> > index 1ab3ade..fa0a407 100644
> > --- a/lib/librte_eal/common/eal_common_memzone.c
> > +++ b/lib/librte_eal/common/eal_common_memzone.c
> > @@ -314,8 +314,9 @@
> >   	if (addr == NULL)
> >   		ret = -EINVAL;
> >   	else if (mcfg->memzone_cnt == 0) {
> > -		rte_panic("%s(): memzone address not NULL but memzone_cnt is 0!\n",
> > -				__func__);
> > +		RTE_LOG(CRIT, EAL, "%s(): memzone address not NULL but memzone_cnt"
> > +				" is 0!\n", __func__);
> > +		return -1;
> >   	} else {
> >   		memset(&mcfg->memzone[idx], 0, sizeof(mcfg->memzone[idx]));
> >   		mcfg->memzone_cnt--;
> > 
> 
> This changes public API. For now, memzone docs mention either return 
> value of 0, or return value of -EINVAL in case of invalid arguments:
> 
> /**
>   * Free a memzone.
>   *
>   * @param mz
>   *   A pointer to the memzone
>   * @return
>   *  -EINVAL - invalid parameter.
>   *  0 - success
>   */
> 
> I'm not sure returning -EINVAL is suitable in this case (the parameter 
> was valid, but an internal error happened - I can't think of any 
> suitable errno value off hand), and adding a new return value changes 
> API, which presumably would require a deprecation notice.
> 
> Thomas?

It does not fully change the API, since the success value is not changed.
I think we can accept one more error value if doxygen is properly updated.
  
Arnon Warshavsky April 4, 2018, 8:44 p.m. UTC | #3
Thanks. Will update the doxigen

On Wed, Apr 4, 2018 at 3:34 PM, Thomas Monjalon <thomas@monjalon.net> wrote:

> 04/04/2018 14:09, Burakov, Anatoly:
> > On 04-Apr-18 12:27 PM, Arnon Warshavsky wrote:
> > > replace panic calls with log and retrun value.
> > >
> > > Signed-off-by: Arnon Warshavsky <arnon@qwilt.com>
> > > ---
> > >   lib/librte_eal/common/eal_common_memzone.c | 5 +++--
> > >   1 file changed, 3 insertions(+), 2 deletions(-)
> > >
> > > diff --git a/lib/librte_eal/common/eal_common_memzone.c
> b/lib/librte_eal/common/eal_common_memzone.c
> > > index 1ab3ade..fa0a407 100644
> > > --- a/lib/librte_eal/common/eal_common_memzone.c
> > > +++ b/lib/librte_eal/common/eal_common_memzone.c
> > > @@ -314,8 +314,9 @@
> > >     if (addr == NULL)
> > >             ret = -EINVAL;
> > >     else if (mcfg->memzone_cnt == 0) {
> > > -           rte_panic("%s(): memzone address not NULL but memzone_cnt
> is 0!\n",
> > > -                           __func__);
> > > +           RTE_LOG(CRIT, EAL, "%s(): memzone address not NULL but
> memzone_cnt"
> > > +                           " is 0!\n", __func__);
> > > +           return -1;
> > >     } else {
> > >             memset(&mcfg->memzone[idx], 0, sizeof(mcfg->memzone[idx]));
> > >             mcfg->memzone_cnt--;
> > >
> >
> > This changes public API. For now, memzone docs mention either return
> > value of 0, or return value of -EINVAL in case of invalid arguments:
> >
> > /**
> >   * Free a memzone.
> >   *
> >   * @param mz
> >   *   A pointer to the memzone
> >   * @return
> >   *  -EINVAL - invalid parameter.
> >   *  0 - success
> >   */
> >
> > I'm not sure returning -EINVAL is suitable in this case (the parameter
> > was valid, but an internal error happened - I can't think of any
> > suitable errno value off hand), and adding a new return value changes
> > API, which presumably would require a deprecation notice.
> >
> > Thomas?
>
> It does not fully change the API, since the success value is not changed.
> I think we can accept one more error value if doxygen is properly updated.
>
>
>
>
  

Patch

diff --git a/lib/librte_eal/common/eal_common_memzone.c b/lib/librte_eal/common/eal_common_memzone.c
index 1ab3ade..fa0a407 100644
--- a/lib/librte_eal/common/eal_common_memzone.c
+++ b/lib/librte_eal/common/eal_common_memzone.c
@@ -314,8 +314,9 @@ 
 	if (addr == NULL)
 		ret = -EINVAL;
 	else if (mcfg->memzone_cnt == 0) {
-		rte_panic("%s(): memzone address not NULL but memzone_cnt is 0!\n",
-				__func__);
+		RTE_LOG(CRIT, EAL, "%s(): memzone address not NULL but memzone_cnt"
+				" is 0!\n", __func__);
+		return -1;
 	} else {
 		memset(&mcfg->memzone[idx], 0, sizeof(mcfg->memzone[idx]));
 		mcfg->memzone_cnt--;