浏览代码

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)
Signed-off-by: Philippe Reynes <philippe.reynes@softathome.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Philippe Reynes 3 年之前
父节点
当前提交
cc34f04efd
共有 1 个文件被更改,包括 2 次插入2 次删除
  1. 2 2
      tools/image-host.c

+ 2 - 2
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++;
 	}