- commit
- f52b480
- parent
- c573931
- author
- Neale Pickett
- date
- 2024-01-22 16:26:38 -0700 MST
Use better PRNG
1 files changed,
+2,
-5
M
baud.c
M
baud.c
+2,
-5
1@@ -55,9 +55,6 @@ main(int argc, char *argv[]) {
2 noiselen = atoi(argv[3]);
3 }
4
5- // In musl, the first value is 0
6- rand();
7-
8 int cps = baud / 10; // 8N1 has 10 bits per octet: 8 data, 1 start, 1 parity
9 int delay = SECOND / cps;
10 int noisybits = 0;
11@@ -65,9 +62,9 @@ main(int argc, char *argv[]) {
12 while ((c = getchar()) != EOF) {
13 usleep(delay);
14 for (int bit = 0; bit < 8; bit++) {
15- int r = rand() % NOISINESS_DENOMINATOR;
16+ int r = random() % NOISINESS_DENOMINATOR;
17 if (r < noisiness) {
18- noisybits = rand() % noiselen;
19+ noisybits = random() % noiselen;
20 }
21
22 if (noisybits) {