DPDK patches and discussions
 help / color / mirror / Atom feed
From: Jerin Jacob <jerinjacobk@gmail.com>
To: Rakesh Kudurumalla <rkudurumalla@marvell.com>,
	Ferruh Yigit <ferruh.yigit@intel.com>
Cc: Nithin Dabilpuram <ndabilpuram@marvell.com>,
	Kiran Kumar K <kirankumark@marvell.com>,
	 Sunil Kumar Kori <skori@marvell.com>,
	Satha Rao <skoteshwar@marvell.com>, dpdk-dev <dev@dpdk.org>,
	 Jerin Jacob <jerinj@marvell.com>, dpdk stable <stable@dpdk.org>
Subject: Re: [PATCH] net/cnxk: fix compilation issue for gcc12
Date: Wed, 23 Feb 2022 17:11:28 +0530	[thread overview]
Message-ID: <CALBAE1ObR-Z6a0aG-kWHjH3LrU7NbGa_3--QV70jNeoN07RtJA@mail.gmail.com> (raw)
In-Reply-To: <20220223094919.2834940-1-rkudurumalla@marvell.com>

On Wed, Feb 23, 2022 at 3:20 PM Rakesh Kudurumalla
<rkudurumalla@marvell.com> wrote:
>
> resolve compilation error caused due to gcc 12 version
> error: storing the address of local variable message in *error.message
>
> Fixes: 26b034f78ca7 ("net/cnxk: support to validate meter policy")
>
> Cc: stable@dpdk.org
>

Reported-By: Ferruh Yigit <ferruh.yigit@intel.com>

> Signed-off-by: Rakesh Kudurumalla <rkudurumalla@marvell.com>
> ---
>  drivers/net/cnxk/cnxk_ethdev_mtr.c | 59 ++++++++++++++++++++++--------
>  1 file changed, 44 insertions(+), 15 deletions(-)
>
> diff --git a/drivers/net/cnxk/cnxk_ethdev_mtr.c b/drivers/net/cnxk/cnxk_ethdev_mtr.c
> index cc783e5f86..c8183aa12d 100644
> --- a/drivers/net/cnxk/cnxk_ethdev_mtr.c
> +++ b/drivers/net/cnxk/cnxk_ethdev_mtr.c
> @@ -285,15 +285,54 @@ cnxk_nix_mtr_profile_delete(struct rte_eth_dev *eth_dev, uint32_t profile_id,
>         return 0;
>  }
>
> +static int
> +update_mtr_err(uint32_t act_color, struct rte_mtr_error *error, bool action)
> +{
> +       const char *str;
> +       switch (act_color) {
> +       case RTE_COLOR_GREEN:
> +               if (action) {
> +                       str = "Green action is not valid";
> +                       goto notsup;
> +               } else {
> +                       str = "Green action is null";
> +                       goto notvalid;
> +               }
> +               break;
> +       case RTE_COLOR_YELLOW:
> +               if (action) {
> +                       str = "Yellow action is not valid";
> +                       goto notsup;
> +               } else {
> +                       str = "Yellow action is null";
> +                       goto notvalid;
> +               }
> +               break;
> +       case RTE_COLOR_RED:
> +               if (action) {
> +                       str = "Red action is not valid";
> +                       goto notsup;
> +               } else {
> +                       str = "Red action is null";
> +                       goto notvalid;
> +               }
> +               break;
> +       }
> +notsup:
> +       return -rte_mtr_error_set(error, ENOTSUP,
> +                                 RTE_MTR_ERROR_TYPE_METER_POLICY, NULL, str);
> +notvalid:
> +       return -rte_mtr_error_set(error, EINVAL,
> +                                 RTE_MTR_ERROR_TYPE_METER_POLICY, NULL, str);
> +}
> +
>  static int
>  cnxk_nix_mtr_policy_validate(struct rte_eth_dev *dev,
>                              struct rte_mtr_meter_policy_params *policy,
>                              struct rte_mtr_error *error)
>  {
> -       static const char *const action_color[] = {"Green", "Yellow", "Red"};
>         bool supported[RTE_COLORS] = {false, false, false};
>         const struct rte_flow_action *action;
> -       char message[1024];
>         uint32_t i;
>
>         RTE_SET_USED(dev);
> @@ -315,21 +354,11 @@ cnxk_nix_mtr_policy_validate(struct rte_eth_dev *dev,
>                                 if (action->type == RTE_FLOW_ACTION_TYPE_VOID)
>                                         supported[i] = true;
>
> -                               if (!supported[i]) {
> -                                       sprintf(message,
> -                                               "%s action is not valid",
> -                                               action_color[i]);
> -                                       return -rte_mtr_error_set(error,
> -                                         ENOTSUP,
> -                                         RTE_MTR_ERROR_TYPE_METER_POLICY, NULL,
> -                                         message);
> -                               }
> +                               if (!supported[i])
> +                                       return update_mtr_err(i, error, true);
>                         }
>                 } else {
> -                       sprintf(message, "%s action is null", action_color[i]);
> -                       return -rte_mtr_error_set(error, EINVAL,
> -                               RTE_MTR_ERROR_TYPE_METER_POLICY, NULL,
> -                               message);
> +                       return update_mtr_err(i, error, false);
>                 }
>         }
>
> --
> 2.25.1
>

  reply	other threads:[~2022-02-23 11:41 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-17 14:02 [PATCH] net/cnxk: fix dangling pointer in meter " Ferruh Yigit
2022-02-23  9:49 ` [PATCH] net/cnxk: fix compilation issue " Rakesh Kudurumalla
2022-02-23 11:41   ` Jerin Jacob [this message]
2022-02-23 17:13     ` Jerin Jacob
2022-02-23  9:55 ` Rakesh Kudurumalla

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=CALBAE1ObR-Z6a0aG-kWHjH3LrU7NbGa_3--QV70jNeoN07RtJA@mail.gmail.com \
    --to=jerinjacobk@gmail.com \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@intel.com \
    --cc=jerinj@marvell.com \
    --cc=kirankumark@marvell.com \
    --cc=ndabilpuram@marvell.com \
    --cc=rkudurumalla@marvell.com \
    --cc=skori@marvell.com \
    --cc=skoteshwar@marvell.com \
    --cc=stable@dpdk.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).