selftests/net: mptcp: fix uninitialized variable warnings
[platform/kernel/linux-starfive.git] / tools / testing / selftests / net / mptcp / mptcp_inq.c
index 8672d89..218aac4 100644 (file)
@@ -18,6 +18,7 @@
 #include <time.h>
 
 #include <sys/ioctl.h>
+#include <sys/random.h>
 #include <sys/socket.h>
 #include <sys/types.h>
 #include <sys/wait.h>
@@ -519,15 +520,11 @@ static int client(int unixfd)
 
 static void init_rng(void)
 {
-       int fd = open("/dev/urandom", O_RDONLY);
        unsigned int foo;
 
-       if (fd > 0) {
-               int ret = read(fd, &foo, sizeof(foo));
-
-               if (ret < 0)
-                       srand(fd + foo);
-               close(fd);
+       if (getrandom(&foo, sizeof(foo), 0) == -1) {
+               perror("getrandom");
+               exit(1);
        }
 
        srand(foo);