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

Philippe Reynes philippe.reynes at softathome.com
Fri Nov 13 16:37:46 CET 2020


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)
Signed-off-by: Philippe Reynes <philippe.reynes at softathome.com>
---
 tools/image-host.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/image-host.c b/tools/image-host.c
index 24079b8a27..e32cc64257 100644
--- a/tools/image-host.c
+++ b/tools/image-host.c
@@ -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++;
 	}
 
-- 
2.17.1



More information about the U-Boot mailing list