app/testpmd: use rte_rand() instead of random()

Message ID 20191121193407.13843-1-pbhagavatula@marvell.com (mailing list archive)
State Accepted, archived
Delegated to: Ferruh Yigit
Headers
Series app/testpmd: use rte_rand() instead of random() |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-compilation success Compile Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/Intel-compilation fail Compilation issues
ci/travis-robot success Travis build: passed

Commit Message

Pavan Nikhilesh Bhagavatula Nov. 21, 2019, 7:34 p.m. UTC
  From: Pavan Nikhilesh <pbhagavatula@marvell.com>

Use rte_rand() instead of random() for better randomness.

Coverity Issue: 337666

Signed-off-by: Pavan Nikhilesh <pbhagavatula@marvell.com>
---
 app/test-pmd/txonly.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

Ferruh Yigit Nov. 22, 2019, 4:38 p.m. UTC | #1
On 11/21/2019 7:34 PM, pbhagavatula@marvell.com wrote:
> From: Pavan Nikhilesh <pbhagavatula@marvell.com>
> 
> Use rte_rand() instead of random() for better randomness.
> 
> Coverity Issue: 337666
> 
> Signed-off-by: Pavan Nikhilesh <pbhagavatula@marvell.com>

Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>

Applied to dpdk-next-net/master, thanks.
  

Patch

diff --git a/app/test-pmd/txonly.c b/app/test-pmd/txonly.c
index 539043c34..3caf281cb 100644
--- a/app/test-pmd/txonly.c
+++ b/app/test-pmd/txonly.c
@@ -159,7 +159,7 @@  pkt_burst_prepare(struct rte_mbuf *pkt, struct rte_mempool *mbp,
 	uint8_t i;
 
 	if (unlikely(tx_pkt_split == TX_PKT_SPLIT_RND))
-		nb_segs = random() % tx_pkt_nb_segs + 1;
+		nb_segs = rte_rand() % tx_pkt_nb_segs + 1;
 	else
 		nb_segs = tx_pkt_nb_segs;