net/cnxk: fix dangling pointer in meter for gcc12
Checks
Commit Message
Observed with: gcc (GCC) 12.0.0 20220116 (experimental)
In file included from ../drivers/net/cnxk/cnxk_ethdev.h:16,
from ../drivers/net/cnxk/cnxk_ethdev_mtr.c:5:
In function ‘rte_mtr_error_set’,
inlined from ‘cnxk_nix_mtr_policy_validate’ at ../drivers/net/cnxk/cnxk_ethdev_mtr.c:311:14:
../lib/ethdev/rte_mtr_driver.h:188:24: error: storing the address of local variable ‘message’ in ‘*error.message’ [-Werror=dangling-pointer=]
188 | *error = (struct rte_mtr_error){
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
189 | .type = type,
| ~~~~~~~~~~~~~
190 | .cause = cause,
| ~~~~~~~~~~~~~~~
191 | .message = message,
| ~~~~~~~~~~~~~~~~~~~
192 | };
| ~
../drivers/net/cnxk/cnxk_ethdev_mtr.c: In function ‘cnxk_nix_mtr_policy_validate’:
../drivers/net/cnxk/cnxk_ethdev_mtr.c:288:14: note: ‘message’ declared here
288 | char message[1024];
| ^~~~~~~
../drivers/net/cnxk/cnxk_ethdev_mtr.c:288:14: note: ‘error’ declared here
It is a valid compiler warning, make local variable a global one.
Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
---
Fix is done in a quickest way, mainly to report the issue,
please feel free to suggest another solution for the build error.
---
drivers/net/cnxk/cnxk_ethdev_mtr.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
@@ -285,7 +285,7 @@ cnxk_nix_mtr_policy_validate(struct rte_eth_dev *dev,
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];
+ static char message[1024];
uint32_t i;
RTE_SET_USED(dev);