From 5b1517778e20f04f18ca0e9a89c32f0a01b78783 Mon Sep 17 00:00:00 2001 From: Daniele Forsi IU5HKX Date: Thu, 7 Aug 2025 11:38:12 +0200 Subject: [PATCH] Replace "goto again" with "continue" (third case) When the software on the other side of the pty closes the device, the simulator would close and reopen its side but it is unneeded because it can continue to call read() without doing anything special. --- simulators/simatd578.c | 4 +--- simulators/simft1000.c | 4 +--- simulators/simft736.c | 4 +--- simulators/simft747gx.c | 4 +--- simulators/simft817.c | 4 +--- simulators/simft847.c | 4 +--- simulators/simft897.c | 4 +--- simulators/simjupiter.c | 4 +--- simulators/simmicom.c | 4 +--- simulators/simorion.c | 4 +--- simulators/simpmr171.c | 4 +--- simulators/simspid.c | 4 +--- 12 files changed, 12 insertions(+), 36 deletions(-) diff --git a/simulators/simatd578.c b/simulators/simatd578.c index ad897ebec..b6d5e43de 100644 --- a/simulators/simatd578.c +++ b/simulators/simatd578.c @@ -53,7 +53,6 @@ int main(int argc, char *argv[]) { unsigned char buf[BUFSIZE], buf2[256]; -again: int fd = openPort(argv[1]); while (1) @@ -63,8 +62,7 @@ again: if (bytes == 0) { - close(fd); - goto again; + continue; } if (bytes != 8) diff --git a/simulators/simft1000.c b/simulators/simft1000.c index 14485a74d..30e2429e3 100644 --- a/simulators/simft1000.c +++ b/simulators/simft1000.c @@ -21,7 +21,6 @@ int main(int argc, char *argv[]) { unsigned char buf[BUFSIZE]; -again: int fd = openPort(argv[1]); while (1) @@ -30,8 +29,7 @@ again: if (bytes == 0) { - close(fd); - goto again; + continue; } if (bytes != 5) diff --git a/simulators/simft736.c b/simulators/simft736.c index 28b7c77b4..c10614dfc 100644 --- a/simulators/simft736.c +++ b/simulators/simft736.c @@ -21,7 +21,6 @@ int main(int argc, char *argv[]) { unsigned char buf[BUFSIZE]; -again: int fd = openPort(argv[1]); while (1) @@ -30,8 +29,7 @@ again: if (bytes == 0) { - close(fd); - goto again; + continue; } if (bytes != 5) diff --git a/simulators/simft747gx.c b/simulators/simft747gx.c index a52076cb5..5fca30362 100644 --- a/simulators/simft747gx.c +++ b/simulators/simft747gx.c @@ -23,7 +23,6 @@ int main(int argc, char *argv[]) { unsigned char buf[BUFSIZE]; -again: int fd = openPort(argv[1]); while (1) @@ -32,8 +31,7 @@ again: if (bytes == 0) { - close(fd); - goto again; + continue; } if (bytes != 5) diff --git a/simulators/simft817.c b/simulators/simft817.c index 583c24f16..cd9ebeaa2 100644 --- a/simulators/simft817.c +++ b/simulators/simft817.c @@ -22,7 +22,6 @@ int main(int argc, char *argv[]) { unsigned char buf[BUFSIZE]; -again: int fd = openPort(argv[1]); while (1) @@ -31,8 +30,7 @@ again: if (bytes == 0) { - close(fd); - goto again; + continue; } if (bytes != 5) diff --git a/simulators/simft847.c b/simulators/simft847.c index c3c6befd0..a8800012a 100644 --- a/simulators/simft847.c +++ b/simulators/simft847.c @@ -24,7 +24,6 @@ int main(int argc, char *argv[]) unsigned char buf[BUFSIZE]; int freq, i, n; -again: int fd = openPort(argv[1]); while (1) @@ -33,8 +32,7 @@ again: if (bytes == 0) { - close(fd); - goto again; + continue; } if (bytes != 5) diff --git a/simulators/simft897.c b/simulators/simft897.c index 0e2d2210e..0af8f83c8 100644 --- a/simulators/simft897.c +++ b/simulators/simft897.c @@ -25,7 +25,6 @@ int main(int argc, char *argv[]) unsigned char buf[BUFSIZE]; int n; -again: int fd = openPort(argv[1]); while (1) @@ -34,8 +33,7 @@ again: if (bytes == 0) { - close(fd); - goto again; + continue; } if (bytes != 5) diff --git a/simulators/simjupiter.c b/simulators/simjupiter.c index 706546cae..9c96078d0 100644 --- a/simulators/simjupiter.c +++ b/simulators/simjupiter.c @@ -21,7 +21,6 @@ int main(int argc, char *argv[]) { unsigned char buf[BUFSIZE]; -again: int fd = openPort(argv[1]); while (1) @@ -30,8 +29,7 @@ again: if (bytes == 0) { - close(fd); - goto again; + continue; } if (bytes != 5) diff --git a/simulators/simmicom.c b/simulators/simmicom.c index 4b03e03d5..3b25b6c0b 100644 --- a/simulators/simmicom.c +++ b/simulators/simmicom.c @@ -50,7 +50,6 @@ int main(int argc, char *argv[]) { unsigned char buf[BUFSIZE]; -again: int fd = openPort(argv[1]); while (1) @@ -59,8 +58,7 @@ again: if (bytes == 0) { - close(fd); - goto again; + continue; } switch (buf[3]) diff --git a/simulators/simorion.c b/simulators/simorion.c index 36de57b65..642e40b1e 100644 --- a/simulators/simorion.c +++ b/simulators/simorion.c @@ -40,7 +40,6 @@ int main(int argc, char *argv[]) { char buf[BUFSIZE], reply[256]; -again: int fd = openPort(argv[1]); while (1) @@ -49,8 +48,7 @@ again: if (bytes == 0) { - close(fd); - goto again; + continue; } if (strncmp(buf, "?V", 2) == 0) diff --git a/simulators/simpmr171.c b/simulators/simpmr171.c index 14cd5b488..adf726425 100644 --- a/simulators/simpmr171.c +++ b/simulators/simpmr171.c @@ -56,7 +56,6 @@ int main(int argc, char *argv[]) { unsigned char buf[BUFSIZE]; -again: int fd = openPort(argv[1]); while (1) @@ -65,8 +64,7 @@ again: if (bytes == 0) { - close(fd); - goto again; + continue; } switch (buf[5]) diff --git a/simulators/simspid.c b/simulators/simspid.c index 706546cae..9c96078d0 100644 --- a/simulators/simspid.c +++ b/simulators/simspid.c @@ -21,7 +21,6 @@ int main(int argc, char *argv[]) { unsigned char buf[BUFSIZE]; -again: int fd = openPort(argv[1]); while (1) @@ -30,8 +29,7 @@ again: if (bytes == 0) { - close(fd); - goto again; + continue; } if (bytes != 5)