hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/tools/testing/selftests/bpf/urandom_read.c
....@@ -7,11 +7,19 @@
77
88 #define BUF_SIZE 256
99
10
+static __attribute__((noinline))
11
+void urandom_read(int fd, int count)
12
+{
13
+ char buf[BUF_SIZE];
14
+ int i;
15
+
16
+ for (i = 0; i < count; ++i)
17
+ read(fd, buf, BUF_SIZE);
18
+}
19
+
1020 int main(int argc, char *argv[])
1121 {
1222 int fd = open("/dev/urandom", O_RDONLY);
13
- int i;
14
- char buf[BUF_SIZE];
1523 int count = 4;
1624
1725 if (fd < 0)
....@@ -20,8 +28,7 @@
2028 if (argc == 2)
2129 count = atoi(argv[1]);
2230
23
- for (i = 0; i < count; ++i)
24
- read(fd, buf, BUF_SIZE);
31
+ urandom_read(fd, count);
2532
2633 close(fd);
2734 return 0;