changeset 43:f6497b2822c8

capture: make ubxport and input_readonly local variables Signed-off-by: Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
author Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
date Thu, 16 Jan 2020 11:13:56 -0500
parents c8f1737bcaf0
children 9ed7bbc034bf
files capture.c
diffstat 1 files changed, 5 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/capture.c	Thu Jan 16 11:07:55 2020 -0500
+++ b/capture.c	Thu Jan 16 11:13:56 2020 -0500
@@ -30,8 +30,6 @@
 #include "ubx.h"
 
 static char file_buffer[65536 + 8]; /* worst case message */
-static uint8_t ubxport;
-static bool input_readonly;
 
 static void usage(const char *prog)
 {
@@ -43,7 +41,7 @@
 	exit(1);
 }
 
-static int cfg_port(FILE *file)
+static int cfg_port(FILE *file, bool ro, uint8_t ubxport)
 {
 	struct ubx_cfg_prt_uart prt_uart = {
 		.port = ubxport,
@@ -109,7 +107,7 @@
 	int ret;
 	int i;
 
-	if (input_readonly)
+	if (ro)
 		return 0;
 
 	switch (ubxport) {
@@ -186,6 +184,8 @@
 {
 	struct stat stat;
 	struct termios termios;
+	bool input_readonly;
+	uint8_t ubxport;
 	FILE *ifile;
 	FILE *rfile;
 	int ret;
@@ -272,7 +272,7 @@
 	if (setvbuf(ifile, file_buffer, _IOFBF, sizeof(file_buffer)) == EOF)
 		fprintf(stderr, "Warn: Failed to mark stream as buffered\n");
 
-	ret = cfg_port(ifile);
+	ret = cfg_port(ifile, input_readonly, ubxport);
 	if (ret) {
 		fprintf(stderr, "Error: Failed to configure port: %s\n",
 			xstrerror(ret));