Skip to contentSkip to conversation

tools: image-host.c: use random instead of rand

PATCH New Philippe Reynes 3 participants 3 messages Nov 13, 2020 – Nov 20, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tools: image-host.c: use random instead of rand

According to the manpage of rand, it is recommended to use random instead of rand. This commit updates the function get_random_data to use random.

Reported-by Coverity (CID: 312953)
---
 tools/image-host.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
tools/image-host.c +2 -2
index 24079b8a27..e32cc64257 100644
@@ -339,10 +339,10 @@ static int get_random_data(void *data, int size)
 		goto out;
 	}
 
-	srand(date.tv_nsec);
+	srandom(date.tv_nsec);
 
 	for (i = 0; i < size; i++) {
-		*tmp = rand() & 0xff;
+		*tmp = random() & 0xff;
 		tmp++;
 	}
 
Signature · 1 line
2.17.1
#1 lore raw

PATCH 1/1 tools: image-host.c: use random instead of rand

Quoted 10 lines · Philippe Reynes

According to the manpage of rand, it is recommended to use random instead of rand. This commit updates the function get_random_data to use random.

Reported-by Coverity (CID: 312953)
---
 tools/image-host.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
#2 lore raw

PATCH 1/1 tools: image-host.c: use random instead of rand

In reply to Philippe Reynes
Quoted 7 lines · Philippe Reynes

According to the manpage of rand, it is recommended to use random instead of rand. This commit updates the function get_random_data to use random.

Reported-by Coverity (CID: 312953)

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20201119/8879907c/attachment.sig>