/
index
/
ust.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
inline
| side by side (parent:
c39f729
)
fixed a bug with -# not converting to -s# on some platforms
author
git
<redacted>
Tue, 17 Feb 2026 18:58:29 +0000
(13:58 -0500)
committer
git
<redacted>
Tue, 17 Feb 2026 18:58:29 +0000
(13:58 -0500)
ust.c
patch
|
blob
|
history
diff --git
a/ust.c
b/ust.c
index 56d0482cf81b9a3353a2b54466a012133e029554..9c2c57f63cc6a318ef76830e2ca8d0458a7b91c1 100644
(file)
--- a/
ust.c
+++ b/
ust.c
@@
-13,7
+13,7
@@
#ifdef __linux__
#include <asm/termbits.h>
#include <asm/ioctls.h>
#ifdef __linux__
#include <asm/termbits.h>
#include <asm/ioctls.h>
-#else
+#else
/* needed for termios2, which is itself needed for non-standard bauds */
#include <termios.h>
#endif
#include <termios.h>
#endif
@@
-61,7
+61,7
@@
static void die(int code, const char *msg, ...);
static struct termios cntrl, origterm = {0}, newterm = {0};
#endif
static struct termios cntrl, origterm = {0}, newterm = {0};
#endif
-static const unsigned int uintmax = ~(unsigned int)0;
+static const unsigned int uintmax = ~(unsigned int)0;
/* unsigned -1 to return on error */
static struct timespec wts;
static char *writebuff = NULL;
static char *readbuff = NULL;
static struct timespec wts;
static char *writebuff = NULL;
static char *readbuff = NULL;
@@
-353,7
+353,6
@@
writeport(void *unused)
int escape = 0;
int escape = 0;
-
Args bsargs, nocrargs, nolfargs, lfincrargs;
bsargs.sizem = wbuffsz;
nocrargs = nolfargs = lfincrargs = bsargs;
Args bsargs, nocrargs, nolfargs, lfincrargs;
bsargs.sizem = wbuffsz;
nocrargs = nolfargs = lfincrargs = bsargs;
@@
-429,7
+428,6
@@
readport(void *unused)
lfincrargs.find = CR; lfincrargs.input = LF; lfincrargs.offset = 1;
crinlfargs.find = LF; crinlfargs.input = CR; crinlfargs.offset = -1;
lfincrargs.find = CR; lfincrargs.input = LF; lfincrargs.offset = 1;
crinlfargs.find = LF; crinlfargs.input = CR; crinlfargs.offset = -1;
-
/* disable stdout buffering */
setvbuf(stdout, NULL, _IONBF, 0);
/* disable stdout buffering */
setvbuf(stdout, NULL, _IONBF, 0);
@@
-749,17
+747,16
@@
die(int code, const char *msg, ...)
int
main(int argc, char **argv)
{
int
main(int argc, char **argv)
{
+ char *t = NULL;
+ /* glibc's `asprintf()` won't set the string to NULL on failure automatically */
for (int i = 1; i < argc; i++ ) {
if (argv[i][0] == '-' && argv[i][1] >= '0' && argv[i][1] <= '9') {
for (int i = 1; i < argc; i++ ) {
if (argv[i][0] == '-' && argv[i][1] >= '0' && argv[i][1] <= '9') {
- char *t = NULL;
- /* glibc's `asprintf()` won't set the string to NULL on failure automatically */
asprintf(&t, "-s%s", argv[i] + 1);
if (!t) {
fprintf(stderr, "cannot convert -# to -s#\n");
break;
}
argv[i] = t;
asprintf(&t, "-s%s", argv[i] + 1);
if (!t) {
fprintf(stderr, "cannot convert -# to -s#\n");
break;
}
argv[i] = t;
- free(t);
}
}
}
}
@@
-890,9
+887,13
@@
main(int argc, char **argv)
argv[0]);
break;
}
argv[0]);
break;
}
-
-
}
}
+ /*
+ * not the best practice, but in order for this `free()`
+ * to not get executed ust needs to be killed,
+ * which means the OS *should* free the memory
+ */
+ free(t);
if (!rxspdset)
ispeed = ospeed;
if (!rxspdset)
ispeed = ospeed;