From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 151FAA034C for ; Wed, 23 Feb 2022 10:56:00 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0B88C40E5A; Wed, 23 Feb 2022 10:56:00 +0100 (CET) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by mails.dpdk.org (Postfix) with ESMTP id 79C0E40E5A; Wed, 23 Feb 2022 10:55:58 +0100 (CET) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.16.1.2/8.16.1.2) with ESMTP id 21N9gP1E022557; Wed, 23 Feb 2022 01:55:56 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=pfpt0220; bh=UIHJAGMAQ0bUp6To7D2TXiQN4nBgCXI3Sip3A+4Ba04=; b=EB1aYG+d8O2t+o6J8i1b2Uq6sKPdbJ38xQkVD/+JuDramXwf4dAIE5XXz2MeCd/q5TpV 1a9N0vNyZ3dMrIrmU8vObuSgGJ5N7WjfKkZo27EPSWPPeETsiaTFje0si3lNG6VpXAuM oi/wE4KC/L3yERhW/6UZ6dKhJHLba3ff+KuUJrK9CnXm1eiHKeSRNibw5lI9gMU3swiP FQdEH3IDUbHbV/xg7bKuo5n6chaIxmar2a8sMDVBOpYvXrWKIH/k0SJkmsyERmKjtVrt QdYOLlefiBqwARr9mZz5heu8kfUaxyI83pxdXP9vtF/m2nr60Qec8XJVwIKRLoBztQho Yg== Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 3edjerg1yt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Wed, 23 Feb 2022 01:55:56 -0800 Received: from DC5-EXCH02.marvell.com (10.69.176.39) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 23 Feb 2022 01:55:45 -0800 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server id 15.0.1497.18 via Frontend Transport; Wed, 23 Feb 2022 01:55:45 -0800 Received: from localhost.localdomain (unknown [10.28.48.103]) by maili.marvell.com (Postfix) with ESMTP id 4EE933F708F; Wed, 23 Feb 2022 01:55:43 -0800 (PST) From: Rakesh Kudurumalla To: Nithin Dabilpuram , Kiran Kumar K , Sunil Kumar Kori , Satha Rao CC: , , Rakesh Kudurumalla , Subject: [PATCH] net/cnxk: fix compilation issue for gcc12 Date: Wed, 23 Feb 2022 15:25:40 +0530 Message-ID: <20220223095540.2835045-1-rkudurumalla@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220117140226.3019392-1-ferruh.yigit@intel.com> References: <20220117140226.3019392-1-ferruh.yigit@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-ORIG-GUID: Xd5-TzQABorxcFFsIfTr5g-WgxvWmm9A X-Proofpoint-GUID: Xd5-TzQABorxcFFsIfTr5g-WgxvWmm9A X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.816,Hydra:6.0.425,FMLib:17.11.64.514 definitions=2022-02-23_03,2022-02-21_02,2022-02-23_01 X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org 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 Signed-off-by: Rakesh Kudurumalla --- v2 : removed changeid 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