diff lcdtest/testmain.c @ 27:4b7cac119fb5

lcdtest: added our own local exitcodes.h header
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 27 May 2018 21:49:46 +0000
parents 225556110fa6
children de3d3cfcbb35
line wrap: on
line diff
--- a/lcdtest/testmain.c	Sun May 27 21:36:07 2018 +0000
+++ b/lcdtest/testmain.c	Sun May 27 21:49:46 2018 +0000
@@ -3,6 +3,7 @@
 #include <stdlib.h>
 #include <unistd.h>
 #include <ftdi.h>
+#include "exitcodes.h"
 
 char *device_serial;
 struct ftdi_context ftdi;
@@ -20,7 +21,7 @@
 			continue;
 		default:
 			/* error msg already printed */
-			exit(1);
+			exit(ERROR_USAGE);
 		}
 	}
 	switch (argc - optind) {
@@ -29,12 +30,12 @@
 	case 1:
 		if (chdir(argv[optind]) < 0) {
 			perror(argv[optind]);
-			exit(1);
+			exit(ERROR_UNIX);
 		}
 		break;
 	default:
 		fprintf(stderr, "usage: %s [options] [chdir]\n", argv[0]);
-		exit(1);
+		exit(ERROR_USAGE);
 	}
 }
 
@@ -47,12 +48,12 @@
 	ftdi_init(&ftdi);
 	if (ftdi_usb_open_desc(&ftdi, 0x0403, 0x7157, 0, device_serial) < 0) {
 		fprintf(stderr, "FTDI USB open failed: %s\n", ftdi.error_str);
-		exit(1);
+		exit(ERROR_FTDI);
 	}
 	if (ftdi_set_bitmode(&ftdi, 0, BITMODE_MCU) < 0) {
 		fprintf(stderr, "unable to enter MCU mode: %s\n",
 			ftdi.error_str);
-		exit(1);
+		exit(ERROR_FTDI);
 	}
 	for (;;) {
 		if (isatty(0)) {