#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
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;
int escape = 0;
-
Args bsargs, nocrargs, nolfargs, lfincrargs;
bsargs.sizem = wbuffsz;
nocrargs = nolfargs = lfincrargs = bsargs;
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);
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') {
- 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;
- free(t);
}
}
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;