Commit ec2610b1 authored by Jakub Kicinski's avatar Jakub Kicinski

Merge branch 'selftests-net-fix-a-few-small-compiler-warnings'

Willem de Bruijn says:

====================
selftests/net: fix a few small compiler warnings

Observed a clang warning when backporting cmsg_sender.
Ran the same build against all the .c files under selftests/net.

This is clang-14 with -Wall
Which is what tools/testing/selftests/net/Makefile also enables.
====================

Link: https://lore.kernel.org/r/20231124171645.1011043-1-willemdebruijn.kernel@gmail.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parents ccf49ceb 00a4f8fd
...@@ -148,7 +148,6 @@ void receive_response(struct __test_metadata *_metadata, ...@@ -148,7 +148,6 @@ void receive_response(struct __test_metadata *_metadata,
.msg_iov = &iov, .msg_iov = &iov,
.msg_iovlen = 1 .msg_iovlen = 1
}; };
struct unix_diag_req *udr;
struct nlmsghdr *nlh; struct nlmsghdr *nlh;
int ret; int ret;
......
...@@ -416,9 +416,9 @@ int main(int argc, char *argv[]) ...@@ -416,9 +416,9 @@ int main(int argc, char *argv[])
{ {
struct addrinfo hints, *ai; struct addrinfo hints, *ai;
struct iovec iov[1]; struct iovec iov[1];
unsigned char *buf;
struct msghdr msg; struct msghdr msg;
char cbuf[1024]; char cbuf[1024];
char *buf;
int err; int err;
int fd; int fd;
......
...@@ -2263,7 +2263,7 @@ static int check_results(void) ...@@ -2263,7 +2263,7 @@ static int check_results(void)
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
unsigned int nr_process = 1; long nr_process = 1;
int route_sock = -1, ret = KSFT_SKIP; int route_sock = -1, ret = KSFT_SKIP;
int test_desc_fd[2]; int test_desc_fd[2];
uint32_t route_seq; uint32_t route_seq;
...@@ -2284,7 +2284,7 @@ int main(int argc, char **argv) ...@@ -2284,7 +2284,7 @@ int main(int argc, char **argv)
exit_usage(argv); exit_usage(argv);
} }
if (nr_process > MAX_PROCESSES || !nr_process) { if (nr_process > MAX_PROCESSES || nr_process < 1) {
printk("nr_process should be between [1; %u]", printk("nr_process should be between [1; %u]",
MAX_PROCESSES); MAX_PROCESSES);
exit_usage(argv); exit_usage(argv);
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include <sys/ioctl.h> #include <sys/ioctl.h>
#include <sys/poll.h> #include <sys/poll.h>
#include <sys/random.h>
#include <sys/sendfile.h> #include <sys/sendfile.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/socket.h> #include <sys/socket.h>
...@@ -1125,15 +1126,11 @@ int main_loop_s(int listensock) ...@@ -1125,15 +1126,11 @@ int main_loop_s(int listensock)
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) { if (getrandom(&foo, sizeof(foo), 0) == -1) {
int ret = read(fd, &foo, sizeof(foo)); perror("getrandom");
exit(1);
if (ret < 0)
srand(fd + foo);
close(fd);
} }
srand(foo); srand(foo);
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include <time.h> #include <time.h>
#include <sys/ioctl.h> #include <sys/ioctl.h>
#include <sys/random.h>
#include <sys/socket.h> #include <sys/socket.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/wait.h> #include <sys/wait.h>
...@@ -519,15 +520,11 @@ static int client(int unixfd) ...@@ -519,15 +520,11 @@ static int client(int unixfd)
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) { if (getrandom(&foo, sizeof(foo), 0) == -1) {
int ret = read(fd, &foo, sizeof(foo)); perror("getrandom");
exit(1);
if (ret < 0)
srand(fd + foo);
close(fd);
} }
srand(foo); srand(foo);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment