All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Dumitrescu, Cristian" <cristian.dumitrescu@intel.com>
To: David Marchand <david.marchand@redhat.com>,
	"dev@dpdk.org" <dev@dpdk.org>
Cc: "Lin, Xueqin" <xueqin.lin@intel.com>,
	"Peng, ZhihongX" <zhihongx.peng@intel.com>
Subject: Re: [dpdk-dev] [PATCH] pipeline: remove unreachable branch
Date: Wed, 3 Nov 2021 12:55:35 +0000	[thread overview]
Message-ID: <DM8PR11MB5670213526A311FD10C9D9A1EB8C9@DM8PR11MB5670.namprd11.prod.outlook.com> (raw)
In-Reply-To: <20211103065658.8100-1-david.marchand@redhat.com>



> -----Original Message-----
> From: David Marchand <david.marchand@redhat.com>
> Sent: Wednesday, November 3, 2021 6:57 AM
> To: dev@dpdk.org
> Cc: Dumitrescu, Cristian <cristian.dumitrescu@intel.com>; Lin, Xueqin
> <xueqin.lin@intel.com>; Peng, ZhihongX <zhihongx.peng@intel.com>
> Subject: [PATCH] pipeline: remove unreachable branch
> 
> A previous change blamed it on compiler/ASan, while this is a real
> (yet minor) issue.
> 
> This return -EINVAL is never reached since we test all combinations of
> fidx and fcin booleans.
> All branches end up with a return 0, factorize them.
> 
> Fixes: 84f5ac9418ea ("pipeline: fix build with ASan")
> Fixes: f38913b7fb8e ("pipeline: add meter array to SWX")
> 
> Signed-off-by: David Marchand <david.marchand@redhat.com>
> ---
> ---
>  lib/pipeline/rte_swx_pipeline.c | 10 +---------
>  1 file changed, 1 insertion(+), 9 deletions(-)
> 
> diff --git a/lib/pipeline/rte_swx_pipeline.c b/lib/pipeline/rte_swx_pipeline.c
> index 1afaffefd4..0bdda7e0b3 100644
> --- a/lib/pipeline/rte_swx_pipeline.c
> +++ b/lib/pipeline/rte_swx_pipeline.c
> @@ -4539,8 +4539,6 @@ instr_meter_translate(struct rte_swx_pipeline *p,
>  		instr->meter.color_out.struct_id =
> (uint8_t)color_out_struct_id;
>  		instr->meter.color_out.n_bits = fcout->n_bits;
>  		instr->meter.color_out.offset = fcout->offset / 8;
> -
> -		return 0;
>  	}
> 
>  	/* index = HMEFT, length = HMEFT, color_in = I, color_out = MEF. */
> @@ -4575,8 +4573,6 @@ instr_meter_translate(struct rte_swx_pipeline *p,
>  		instr->meter.color_out.struct_id =
> (uint8_t)color_out_struct_id;
>  		instr->meter.color_out.n_bits = fcout->n_bits;
>  		instr->meter.color_out.offset = fcout->offset / 8;
> -
> -		return 0;
>  	}
> 
>  	/* index = I, length = HMEFT, color_in = MEFT, color_out = MEF. */
> @@ -4607,8 +4603,6 @@ instr_meter_translate(struct rte_swx_pipeline *p,
>  		instr->meter.color_out.struct_id =
> (uint8_t)color_out_struct_id;
>  		instr->meter.color_out.n_bits = fcout->n_bits;
>  		instr->meter.color_out.offset = fcout->offset / 8;
> -
> -		return 0;
>  	}
> 
>  	/* index = I, length = HMEFT, color_in = I, color_out = MEF. */
> @@ -4638,11 +4632,9 @@ instr_meter_translate(struct rte_swx_pipeline *p,
>  		instr->meter.color_out.struct_id =
> (uint8_t)color_out_struct_id;
>  		instr->meter.color_out.n_bits = fcout->n_bits;
>  		instr->meter.color_out.offset = fcout->offset / 8;
> -
> -		return 0;
>  	}
> 
> -	return -EINVAL;
> +	return 0;
>  }
> 
>  static inline void
> --
> 2.23.0

This is a great idea, thanks David!

I think it is a good compromise between keeping Coverity happy and preserving the code structure and readability, so

Acked-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>


  reply	other threads:[~2021-11-03 12:55 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-03  6:56 [dpdk-dev] [PATCH] pipeline: remove unreachable branch David Marchand
2021-11-03 12:55 ` Dumitrescu, Cristian [this message]
2021-11-04 17:20   ` Thomas Monjalon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=DM8PR11MB5670213526A311FD10C9D9A1EB8C9@DM8PR11MB5670.namprd11.prod.outlook.com \
    --to=cristian.dumitrescu@intel.com \
    --cc=david.marchand@redhat.com \
    --cc=dev@dpdk.org \
    --cc=xueqin.lin@intel.com \
    --cc=zhihongx.peng@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.