From: Bruce Richardson Date: Mon, 8 Apr 2019 09:46:39 +0000 (+0100) Subject: app/testpmd: fix variable use before null check X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=17250a2affdf88557911bbff086a00d05960a7ca;p=dpdk.git app/testpmd: fix variable use before null check The value returned from rte_eth_dev_tx_offload_name() function is used for string comparison before being checked for NULL. Move the NULL check up to be done first. Coverity issue: 279438 Fixes: c73a9071877a ("app/testpmd: add commands to test new offload API") Cc: stable@dpdk.org Signed-off-by: Bruce Richardson Acked-by: Rami Rosen --- diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index 0558bc58a8..5a10c5f38b 100644 --- a/app/test-pmd/cmdline.c +++ b/app/test-pmd/cmdline.c @@ -18310,13 +18310,13 @@ search_tx_offload(const char *name) single_offload = 1; for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) { single_name = rte_eth_dev_tx_offload_name(single_offload); + if (single_name == NULL) + break; if (!strcasecmp(single_name, name)) { found = 1; break; } else if (!strcasecmp(single_name, "UNKNOWN")) break; - else if (single_name == NULL) - break; single_offload <<= 1; }