selftests/net: mptcp: fix uninitialized variable warnings
[platform/kernel/linux-starfive.git] / tools / testing / selftests / net / mptcp / mptcp_connect.c
index e54653e..e6b514c 100644 (file)
@@ -18,6 +18,7 @@
 
 #include <sys/ioctl.h>
 #include <sys/poll.h>
 
 #include <sys/ioctl.h>
 #include <sys/poll.h>
+#include <sys/random.h>
 #include <sys/sendfile.h>
 #include <sys/stat.h>
 #include <sys/socket.h>
 #include <sys/sendfile.h>
 #include <sys/stat.h>
 #include <sys/socket.h>
@@ -98,8 +99,8 @@ static struct cfg_sockopt_types cfg_sockopt_types;
 static void die_usage(void)
 {
        fprintf(stderr, "Usage: mptcp_connect [-6] [-c cmsg] [-f offset] [-i file] [-I num] [-j] [-l] "
 static void die_usage(void)
 {
        fprintf(stderr, "Usage: mptcp_connect [-6] [-c cmsg] [-f offset] [-i file] [-I num] [-j] [-l] "
-               "[-m mode] [-M mark] [-o option] [-p port] [-P mode] [-j] [-l] [-r num] "
-               "[-s MPTCP|TCP] [-S num] [-r num] [-t num] [-T num] [-u] [-w sec] connect_address\n");
+               "[-m mode] [-M mark] [-o option] [-p port] [-P mode] [-r num] [-R num] "
+               "[-s MPTCP|TCP] [-S num] [-t num] [-T num] [-w sec] connect_address\n");
        fprintf(stderr, "\t-6 use ipv6\n");
        fprintf(stderr, "\t-c cmsg -- test cmsg type <cmsg>\n");
        fprintf(stderr, "\t-f offset -- stop the I/O after receiving and sending the specified amount "
        fprintf(stderr, "\t-6 use ipv6\n");
        fprintf(stderr, "\t-c cmsg -- test cmsg type <cmsg>\n");
        fprintf(stderr, "\t-f offset -- stop the I/O after receiving and sending the specified amount "
@@ -118,13 +119,13 @@ static void die_usage(void)
        fprintf(stderr, "\t-p num -- use port num\n");
        fprintf(stderr,
                "\t-P [saveWithPeek|saveAfterPeek] -- save data with/after MSG_PEEK form tcp socket\n");
        fprintf(stderr, "\t-p num -- use port num\n");
        fprintf(stderr,
                "\t-P [saveWithPeek|saveAfterPeek] -- save data with/after MSG_PEEK form tcp socket\n");
-       fprintf(stderr, "\t-t num -- set poll timeout to num\n");
-       fprintf(stderr, "\t-T num -- set expected runtime to num ms\n");
        fprintf(stderr, "\t-r num -- enable slow mode, limiting each write to num bytes "
                "-- for remove addr tests\n");
        fprintf(stderr, "\t-R num -- set SO_RCVBUF to num\n");
        fprintf(stderr, "\t-s [MPTCP|TCP] -- use mptcp(default) or tcp sockets\n");
        fprintf(stderr, "\t-S num -- set SO_SNDBUF to num\n");
        fprintf(stderr, "\t-r num -- enable slow mode, limiting each write to num bytes "
                "-- for remove addr tests\n");
        fprintf(stderr, "\t-R num -- set SO_RCVBUF to num\n");
        fprintf(stderr, "\t-s [MPTCP|TCP] -- use mptcp(default) or tcp sockets\n");
        fprintf(stderr, "\t-S num -- set SO_SNDBUF to num\n");
+       fprintf(stderr, "\t-t num -- set poll timeout to num\n");
+       fprintf(stderr, "\t-T num -- set expected runtime to num ms\n");
        fprintf(stderr, "\t-w num -- wait num sec before closing the socket\n");
        exit(1);
 }
        fprintf(stderr, "\t-w num -- wait num sec before closing the socket\n");
        exit(1);
 }
@@ -1050,15 +1051,11 @@ again:
 
 static void init_rng(void)
 {
 
 static void init_rng(void)
 {
-       int fd = open("/dev/urandom", O_RDONLY);
        unsigned int foo;
 
        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);
        }
 
        srand(foo);