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 B241DA034D for ; Wed, 23 Feb 2022 10:50:03 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A709E41170; Wed, 23 Feb 2022 10:50:03 +0100 (CET) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by mails.dpdk.org (Postfix) with ESMTP id 1B53040140; Wed, 23 Feb 2022 10:49:59 +0100 (CET) Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.16.1.2/8.16.1.2) with ESMTP id 21N9e4r6003614; Wed, 23 Feb 2022 01:49:59 -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=J8D5ThekoleEk+rC9HW/BgvWrukmkDAclwYXdtDAZSM=; b=k5Hq1uGDNV5JYRO9Nl5Nci7VtvrT0/7kyYR8hd7y3AFMv2/j+Uq3MS18xQMZZ/1+K3Ql Nht2UJTGu4ckWWa3kX6TGUvvuiJkMhnjm2QWdvTvJTRXgRI9XBiJQ+hS7H0bziedKx1F O6Jr0Y2aHiywY5iTedhi2iU/7oIW8YmAx/nsXpH1eno0iM7gxZ7UzwvhvwKJCL0bxhD1 XCzpZ1HMglVhZ74kh9RsXsb8vh+VP8E4dW8Je716u1nClZaZr+0W3Re8v78CsCXW7eEh CvjnD3DswhUFnJo/qn+ktFOhVOYVFheKS3vLN9Lm5fWJlxgu7lYyNuy7RnGBJWa39oBF SA== Received: from dc5-exch02.marvell.com ([199.233.59.182]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 3edjga014x-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Wed, 23 Feb 2022 01:49:59 -0800 Received: from DC5-EXCH02.marvell.com (10.69.176.39) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Wed, 23 Feb 2022 01:49:57 -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:49:57 -0800 Received: from localhost.localdomain (unknown [10.28.48.103]) by maili.marvell.com (Postfix) with ESMTP id 502AC3F7088; Wed, 23 Feb 2022 01:49:55 -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:19:19 +0530 Message-ID: <20220223094919.2834940-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: bhWu5AXABT1O5okkgxA6VxlmtuRrfMm5 X-Proofpoint-GUID: bhWu5AXABT1O5okkgxA6VxlmtuRrfMm5 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 Change-Id: Ia4cf18471ae33691c34229ab537f208389e0f780 --- 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