From 2240d9ca9f1b367ef985eef8a3a028936ac71f56 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Fri, 7 Sep 2012 06:02:53 -0400 Subject: Replace exit({0,1}) with exit(EXIT_{SUCCESS,FAILURE}) Note there are some exit(2) instances we bneed to decide what to do with. --- cgps.c | 6 +++--- crc24q.c | 2 +- daemon.c | 2 +- driver_nmea2000.c | 2 +- gpsctl.c | 36 ++++++++++++++++++------------------ gpsd.c | 10 +++++----- gpsdctl.c | 6 +++--- gpsdecode.c | 10 +++++----- gpsmon.c | 18 +++++++++--------- gpspipe.c | 40 ++++++++++++++++++++-------------------- gpxlogger.c | 18 +++++++++--------- lcdgps.c | 12 ++++++------ test_bits.c | 2 +- test_json.c | 16 ++++++++-------- test_libgps.c | 8 ++++---- test_packet.c | 4 ++-- 16 files changed, 96 insertions(+), 96 deletions(-) diff --git a/cgps.c b/cgps.c index 4b358f9e..5596fa7c 100644 --- a/cgps.c +++ b/cgps.c @@ -167,7 +167,7 @@ static void die(int sig) } /* Bye! */ - exit(0); + exit(EXIT_SUCCESS); } static enum deg_str_type deg_type = deg_dd; @@ -672,7 +672,7 @@ static void usage(char *prog) " Valid only for USA (Lower 48 + AK) and Western Europe.\n", prog); - exit(1); + exit(EXIT_FAILURE); } /* @@ -755,7 +755,7 @@ int main(int argc, char *argv[]) case 'V': (void)fprintf(stderr, "cgps: %s (revision %s)\n", VERSION, REVISION); - exit(0); + exit(EXIT_SUCCESS); case 'l': switch (optarg[0]) { case 'd': diff --git a/crc24q.c b/crc24q.c index 03d64501..dfa90cbb 100644 --- a/crc24q.c +++ b/crc24q.c @@ -70,7 +70,7 @@ int main(int argc, char *argv[]) putchar('\n'); } - exit(0); + exit(EXIT_SUCCESS); } #endif diff --git a/daemon.c b/daemon.c index e701fef4..f8804586 100644 --- a/daemon.c +++ b/daemon.c @@ -28,7 +28,7 @@ int daemon(int nochdir, int noclose) case 0: /* child side */ break; default: /* parent side */ - exit(0); + exit(EXIT_SUCCESS); } /*@ +type @*/ diff --git a/driver_nmea2000.c b/driver_nmea2000.c index f3afccc9..eb54e7cd 100644 --- a/driver_nmea2000.c +++ b/driver_nmea2000.c @@ -766,7 +766,7 @@ static ssize_t nmea2000_get(struct gps_device_t *session) } return frame.can_dlc & 0x0f; } -// printf("NMEA2000 get: exit(0)\n"); +// printf("NMEA2000 get: exit(EXIT_SUCCESS)\n"); return 0; } diff --git a/gpsctl.c b/gpsctl.c index bdf90d29..10d72331 100644 --- a/gpsctl.c +++ b/gpsctl.c @@ -235,10 +235,10 @@ static void onsig(int sig) { if (sig == SIGALRM) { gpsd_report(LOG_ERROR, "packet recognition timed out.\n"); - exit(1); + exit(EXIT_FAILURE); } else { gpsd_report(LOG_ERROR, "killed by signal %d\n", sig); - exit(0); + exit(EXIT_SUCCESS); } } @@ -292,7 +292,7 @@ int main(int argc, char **argv) if ((cooklen = hex_escapes(cooked, control)) <= 0) { gpsd_report(LOG_ERROR, "invalid escape string (error %d)\n", (int)cooklen); - exit(1); + exit(EXIT_FAILURE); } #else gpsd_report(LOG_ERROR, "control_send capability has been conditioned out.\n"); @@ -329,7 +329,7 @@ int main(int argc, char **argv) #endif /* CONTROLSEND_ENABLE */ (void)puts((*dp)->type_name); } - exit(0); + exit(EXIT_SUCCESS); case 'n': /* switch to NMEA mode */ #ifdef RECONFIGURE_ENABLE to_nmea = true; @@ -400,7 +400,7 @@ int main(int argc, char **argv) if (((int)to_nmea + (int)to_binary + (int)reset) > 1) { gpsd_report(LOG_ERROR, "make up your mind, would you?\n"); - exit(0); + exit(EXIT_SUCCESS); } (void) signal(SIGINT, onsig); @@ -425,17 +425,17 @@ int main(int argc, char **argv) if (!gps_query(&gpsdata, DEVICELIST_SET, (int)timeout, "?DEVICES;\n")) { gpsd_report(LOG_ERROR, "no DEVICES response received.\n"); (void)gps_close(&gpsdata); - exit(1); + exit(EXIT_FAILURE); } if (gpsdata.devices.ndevices == 0) { gpsd_report(LOG_ERROR, "no devices connected.\n"); (void)gps_close(&gpsdata); - exit(1); + exit(EXIT_FAILURE); } else if (gpsdata.devices.ndevices > 1 && device == NULL) { gpsd_report(LOG_ERROR, "multiple devices and no device specified.\n"); (void)gps_close(&gpsdata); - exit(1); + exit(EXIT_FAILURE); } gpsd_report(LOG_PROG,"%d device(s) found.\n",gpsdata.devices.ndevices); @@ -451,7 +451,7 @@ int main(int argc, char **argv) } gpsd_report(LOG_ERROR, "specified device not found in device list.\n"); (void)gps_close(&gpsdata); - exit(1); + exit(EXIT_FAILURE); devicelist_entry_matches:; } (void)memcpy(&gpsdata.dev, @@ -464,7 +464,7 @@ int main(int argc, char **argv) if (gps_stream(&gpsdata, WATCH_ENABLE|WATCH_JSON, NULL) == -1) { gpsd_report(LOG_ERROR, "stream set failed.\n"); (void)gps_close(&gpsdata); - exit(1); + exit(EXIT_FAILURE); } while (devcount > 0) { @@ -472,7 +472,7 @@ int main(int argc, char **argv) if (gps_read(&gpsdata) == -1) { gpsd_report(LOG_ERROR, "data read failed.\n"); (void)gps_close(&gpsdata); - exit(1); + exit(EXIT_FAILURE); } if (gpsdata.set & DEVICE_SET) { @@ -485,7 +485,7 @@ int main(int argc, char **argv) } gpsd_report(LOG_ERROR, "data read failed.\n"); (void)gps_close(&gpsdata); - exit(1); + exit(EXIT_FAILURE); matching_device_seen:; } @@ -494,7 +494,7 @@ int main(int argc, char **argv) gpsd_report(LOG_SHOUT, "%s can't be identified.\n", gpsdata.dev.path); (void)gps_close(&gpsdata); - exit(0); + exit(EXIT_SUCCESS); } /* if no control operation was specified, just ID the device */ @@ -510,7 +510,7 @@ int main(int argc, char **argv) if (reset) { gpsd_report(LOG_PROG, "cannot reset with gpsd running.\n"); - exit(0); + exit(EXIT_SUCCESS); } /*@-boolops@*/ @@ -593,7 +593,7 @@ int main(int argc, char **argv) if (device == NULL || forcetype == NULL) { gpsd_report(LOG_ERROR, "device and type must be specified for the reset operation.\n"); - exit(1); + exit(EXIT_FAILURE); } /*@ -mustfreeonly -immediatetrans @*/ @@ -617,7 +617,7 @@ int main(int argc, char **argv) if (session.device_type->mode_switcher) session.device_type->mode_switcher(&session, MODE_NMEA); gpsd_wrap(&session); - exit(0); + exit(EXIT_SUCCESS); /*@ +mustfreeonly +immediatetrans @*/ #endif /* RECONFIGURE_ENABLE */ } else { @@ -644,7 +644,7 @@ int main(int argc, char **argv) if (device == NULL) { gpsd_report(LOG_ERROR, "device must be specified for low-level access.\n"); - exit(1); + exit(EXIT_FAILURE); } gpsd_time_init(&context, time(NULL)); gpsd_init(&session, &context, device); @@ -695,7 +695,7 @@ int main(int argc, char **argv) /* if no control operation was specified, we're done */ if (speed==NULL && !to_nmea && !to_binary && control==NULL) - exit(0); + exit(EXIT_SUCCESS); /* maybe user wants to see the packet rather than send it */ if (echo) diff --git a/gpsd.c b/gpsd.c index 93d0ca75..289fac9b 100644 --- a/gpsd.c +++ b/gpsd.c @@ -1904,7 +1904,7 @@ int main(int argc, char *argv[]) #endif /* RECONFIGURE_ENABLE */ (void)puts((*dp)->type_name); } - exit(0); + exit(EXIT_SUCCESS); case 'S': #ifdef SOCKET_EXPORT_ENABLE gpsd_service = optarg; @@ -1920,12 +1920,12 @@ int main(int argc, char *argv[]) break; case 'V': (void)printf("gpsd: %s (revision %s)\n", VERSION, REVISION); - exit(0); + exit(EXIT_SUCCESS); case 'h': case '?': default: usage(); - exit(0); + exit(EXIT_SUCCESS); } } @@ -1952,7 +1952,7 @@ int main(int argc, char *argv[]) && optind >= argc) { gpsd_report(LOG_ERROR, "can't run with neither control socket nor devices\n"); - exit(1); + exit(EXIT_FAILURE); } /* @@ -1988,7 +1988,7 @@ int main(int argc, char *argv[]) if (optind >= argc) { gpsd_report(LOG_ERROR, "can't run with no devices specified\n"); - exit(1); + exit(EXIT_FAILURE); } #endif /* defined(CONTROL_SOCKET_ENABLE) || defined(SYSTEMD_ENABLE) */ diff --git a/gpsdctl.c b/gpsdctl.c index 6b32cb6c..48c26097 100644 --- a/gpsdctl.c +++ b/gpsdctl.c @@ -89,7 +89,7 @@ int main(int argc, char *argv[]) openlog("gpsdctl", 0, LOG_DAEMON); if (argc != 3) { (void)syslog(LOG_ERR, "requires action and argument (%d)", argc); - exit(1); + exit(EXIT_FAILURE); } else { /*@-observertrans@*/ char *sockenv = getenv("GPSD_SOCKET"); @@ -102,9 +102,9 @@ int main(int argc, char *argv[]) /* coverity[string_size] */ if (gpsd_control(argv[1], argv[2]) < 0) - exit(1); + exit(EXIT_FAILURE); else - exit(0); + exit(EXIT_SUCCESS); /*@+observertrans@*/ } } diff --git a/gpsdecode.c b/gpsdecode.c index f08cc98b..26649f97 100644 --- a/gpsdecode.c +++ b/gpsdecode.c @@ -604,7 +604,7 @@ static void encode(FILE *fpin, FILE *fpout) (void)fprintf(stderr, "gpsdecode: dying with status %d (%s) on line %d\n", status, json_error_string(status), lineno); - exit(1); + exit(EXIT_FAILURE); } json_data_report(session.gpsdata.set, &session, &policy, @@ -668,12 +668,12 @@ int main(int argc, char **argv) case 'V': (void)fprintf(stderr, "gpsdecode revision " VERSION "\n"); - exit(0); + exit(EXIT_SUCCESS); case '?': default: (void)fputs("gpsdecode [-v]\n", stderr); - exit(1); + exit(EXIT_FAILURE); } } //argc -= optind; @@ -684,11 +684,11 @@ int main(int argc, char **argv) encode(stdin, stdout); #else (void)fprintf(stderr, "gpsdecode: encoding support isn't compiled.\n"); - exit(1); + exit(EXIT_FAILURE); #endif /* SOCKET_EXPORT_ENABLE */ } else decode(stdin, stdout); - exit(0); + exit(EXIT_SUCCESS); } /* gpsdecode.c ends here */ diff --git a/gpsmon.c b/gpsmon.c index c2cd87c1..8955c34a 100644 --- a/gpsmon.c +++ b/gpsmon.c @@ -502,15 +502,15 @@ int main(int argc, char **argv) (void)fputs((*active)->driver->type_name, stdout); (void)fputc('\n', stdout); } - exit(0); + exit(EXIT_SUCCESS); case 'V': (void)printf("gpsmon: %s (revision %s)\n", VERSION, REVISION); - exit(0); + exit(EXIT_SUCCESS); case 'l': /* enable logging at startup */ logfile = fopen(optarg, "w"); if (logfile == NULL) { (void)fprintf(stderr, "Couldn't open logfile for writing.\n"); - exit(1); + exit(EXIT_FAILURE); } break; case 't': @@ -524,11 +524,11 @@ int main(int argc, char **argv) } if (matches > 1) { (void)fprintf(stderr, "-T option matched more than one driver.\n"); - exit(1); + exit(EXIT_FAILURE); } else if (matches == 0) { (void)fprintf(stderr, "-T option didn't match any driver.\n"); - exit(1); + exit(EXIT_FAILURE); } active = NULL; break; @@ -542,7 +542,7 @@ int main(int argc, char **argv) fputs ("usage: gpsmon [-?hVln] [-D debuglevel] [-t type] [server[:port:[device]]]\n", stderr); - exit(1); + exit(EXIT_FAILURE); } } /*@ +branchstate @*/ @@ -570,7 +570,7 @@ int main(int argc, char **argv) argv[0], source.server, source.port, session.gpsdata.gps_fd, netlib_errstr(session.gpsdata.gps_fd)); - exit(1); + exit(EXIT_FAILURE); } if (source.device != NULL) { if (nmea) { @@ -624,7 +624,7 @@ int main(int argc, char **argv) (void)endwin(); (void)fputs("gpsmon: assertion failure, probable I/O error\n", stderr); - exit(1); + exit(EXIT_FAILURE); } (void)initscr(); @@ -1016,7 +1016,7 @@ int main(int argc, char **argv) if (explanation != NULL) (void)fputs(explanation, stderr); - exit(0); + exit(EXIT_SUCCESS); } /* gpsmon.c ends here */ diff --git a/gpspipe.c b/gpspipe.c index 69aa7484..4fdb0bf2 100644 --- a/gpspipe.c +++ b/gpspipe.c @@ -64,13 +64,13 @@ static void open_serial(char *device) */ if ((fd_out = open(device, O_RDWR | O_NOCTTY)) == -1) { fprintf(stderr, "gpspipe: error opening serial port\n"); - exit(1); + exit(EXIT_FAILURE); } /* Save current serial port settings for later */ if (tcgetattr(fd_out, &oldtio) != 0) { fprintf(stderr, "gpspipe: error reading serial port settings\n"); - exit(1); + exit(EXIT_FAILURE); } /* Clear struct for new port settings. */ @@ -85,7 +85,7 @@ static void open_serial(char *device) (void)tcflush(fd_out, TCIFLUSH); if (tcsetattr(fd_out, TCSANOW, &newtio) != 0) { (void)fprintf(stderr, "gpspipe: error configuring serial port\n"); - exit(1); + exit(EXIT_FAILURE); } } @@ -187,7 +187,7 @@ int main(int argc, char **argv) case 'V': (void)fprintf(stderr, "%s: %s (revision %s)\n", argv[0], VERSION, REVISION); - exit(0); + exit(EXIT_SUCCESS); case 's': serialport = optarg; break; @@ -198,7 +198,7 @@ int main(int argc, char **argv) case 'h': default: usage(); - exit(1); + exit(EXIT_FAILURE); } } /*@+branchstate@*/ @@ -211,18 +211,18 @@ int main(int argc, char **argv) if (serialport != NULL && !raw) { (void)fprintf(stderr, "gpspipe: use of '-s' requires '-r'.\n"); - exit(1); + exit(EXIT_FAILURE); } if (outfile == NULL && daemonize) { (void)fprintf(stderr, "gpspipe: use of '-d' requires '-f'.\n"); - exit(1); + exit(EXIT_FAILURE); } if (!raw && !watch && !binary) { (void)fprintf(stderr, "gpspipe: one of '-R', '-r', or '-w' is required.\n"); - exit(1); + exit(EXIT_FAILURE); } /* Daemonize if the user requested it. */ @@ -253,7 +253,7 @@ int main(int argc, char **argv) (void)fprintf(stderr, "gpspipe: unable to open output file: %s\n", outfile); - exit(1); + exit(EXIT_FAILURE); } } @@ -266,7 +266,7 @@ int main(int argc, char **argv) (void)fprintf(stderr, "gpspipe: could not connect to gpsd %s:%s, %s(%d)\n", source.server, source.port, strerror(errno), errno); - exit(1); + exit(EXIT_FAILURE); } /*@ +nullpass +onlytrans @*/ @@ -292,7 +292,7 @@ int main(int argc, char **argv) if (r == -1 && errno != EINTR) { (void)fprintf(stderr, "gpspipe: select error %s(%d)\n", strerror(errno), errno); - exit(1); + exit(EXIT_FAILURE); } else if (r == 0) continue; @@ -320,13 +320,13 @@ int main(int argc, char **argv) (void)fprintf(stderr, "gpspipe: write error, %s(%d)\n", strerror(errno), errno); - exit(1); + exit(EXIT_FAILURE); } } if (fputc(c, fp) == EOF) { fprintf(stderr, "gpspipe: Write Error, %s(%d)\n", strerror(errno), errno); - exit(1); + exit(EXIT_FAILURE); } if (c == '\n') { @@ -335,7 +335,7 @@ int main(int argc, char **argv) fprintf(stderr, "gpspipe: Serial port write Error, %s(%d)\n", strerror(errno), errno); - exit(1); + exit(EXIT_FAILURE); } j = 0; } @@ -346,12 +346,12 @@ int main(int argc, char **argv) (void)fprintf(stderr, "gpspipe: fflush Error, %s(%d)\n", strerror(errno), errno); - exit(1); + exit(EXIT_FAILURE); } if (count > 0) { if (0 >= --count) { /* completed count */ - exit(0); + exit(EXIT_SUCCESS); } } } @@ -363,9 +363,9 @@ int main(int argc, char **argv) else (void)fprintf(stderr, "gpspipe: read error %s(%d)\n", strerror(errno), errno); - exit(1); + exit(EXIT_FAILURE); } else { - exit(0); + exit(EXIT_SUCCESS); } } } @@ -375,12 +375,12 @@ int main(int argc, char **argv) /* Restore the old serial port settings. */ if (tcsetattr(fd_out, TCSANOW, &oldtio) != 0) { (void)fprintf(stderr, "Error restoring serial port settings\n"); - exit(1); + exit(EXIT_FAILURE); } } #endif /* __UNUSED__ */ - exit(0); + exit(EXIT_SUCCESS); } /*@ +compdestroy @*/ diff --git a/gpxlogger.c b/gpxlogger.c index eff63ef5..e9140ded 100644 --- a/gpxlogger.c +++ b/gpxlogger.c @@ -174,7 +174,7 @@ static void quit_handler(int signum) syslog(LOG_INFO, "exiting, signal %d received", signum); print_gpx_footer(); (void)gps_close(&gpsdata); - exit(0); + exit(EXIT_SUCCESS); } /************************************************************************** @@ -192,7 +192,7 @@ static void usage(void) "defaults to '%s -i 5 -e %s localhost:2947'\n", progname, progname, export_default()->name); /*@-nullderef@*/ - exit(1); + exit(EXIT_FAILURE); } /*@-mustfreefresh -mustfreeonly -branchstate -globstate@*/ @@ -207,7 +207,7 @@ int main(int argc, char **argv) if (export_default() == NULL) { (void)fprintf(stderr, "%s: no export methods.\n", progname); - exit(1); + exit(EXIT_FAILURE); } logfile = stdout; @@ -229,7 +229,7 @@ int main(int argc, char **argv) (void)fprintf(stderr, "%s: %s is not a known export method.\n", progname, optarg); - exit(1); + exit(EXIT_FAILURE); } break; case 'f': /* Output file name. */ @@ -274,13 +274,13 @@ int main(int argc, char **argv) break; case 'l': export_list(stderr); - exit(0); + exit(EXIT_SUCCESS); case 'm': minmove = (double )atoi(optarg); break; case 'V': (void)fprintf(stderr, "%s revision " REVISION "\n", progname); - exit(0); + exit(EXIT_SUCCESS); default: usage(); /* NOTREACHED */ @@ -289,7 +289,7 @@ int main(int argc, char **argv) if (daemonize && logfile == stdout) { syslog(LOG_ERR, "Daemon mode with no valid logfile name - exiting."); - exit(1); + exit(EXIT_FAILURE); } if (method != NULL) @@ -327,7 +327,7 @@ int main(int argc, char **argv) (void)fprintf(stderr, "%s: no gpsd running or network error: %d, %s\n", progname, errno, gps_errstr(errno)); - exit(1); + exit(EXIT_FAILURE); } if (source.device != NULL) @@ -339,6 +339,6 @@ int main(int argc, char **argv) print_gpx_footer(); (void)gps_close(&gpsdata); - exit(0); + exit(EXIT_SUCCESS); } /*@+mustfreefresh +mustfreeonly +branchstate +globstate@*/ diff --git a/lcdgps.c b/lcdgps.c index 38000392..f90ce122 100644 --- a/lcdgps.c +++ b/lcdgps.c @@ -248,7 +248,7 @@ static void usage( char *prog) " n = Nautical\"\n" , prog); - exit(1); + exit(EXIT_FAILURE); } int main(int argc, char *argv[]) @@ -292,7 +292,7 @@ int main(int argc, char *argv[]) switch (option) { case 'V': (void)fprintf(stderr, "lcdgs revision " REVISION "\n"); - exit(0); + exit(EXIT_SUCCESS); case 'h': default: usage(argv[0]); @@ -366,7 +366,7 @@ int main(int argc, char *argv[]) h = gethostbyname(LCDDHOST); if(h==NULL) { printf("%s: unknown host '%s'\n",argv[0],LCDDHOST); - exit(1); + exit(EXIT_FAILURE); } servAddr.sin_family = h->h_addrtype; @@ -377,7 +377,7 @@ int main(int argc, char *argv[]) sd = socket(AF_INET, SOCK_STREAM, 0); if(sd == -1) { perror("cannot open socket "); - exit(1); + exit(EXIT_FAILURE); } /* bind any port number */ @@ -389,14 +389,14 @@ int main(int argc, char *argv[]) if(rc == -1) { printf("%s: cannot bind port TCP %u\n",argv[0],LCDDPORT); perror("error "); - exit(1); + exit(EXIT_FAILURE); } /* connect to server */ rc = connect(sd, (struct sockaddr *) &servAddr, sizeof(servAddr)); if(rc == -1) { perror("cannot connect "); - exit(1); + exit(EXIT_FAILURE); } /* Do the initial field label setup. */ diff --git a/test_bits.c b/test_bits.c index ad990711..69139912 100644 --- a/test_bits.c +++ b/test_bits.c @@ -219,5 +219,5 @@ int main(int argc, char *argv[]) success ? "succeeded" : "FAILED"); } - exit(failures ? 1 : 0); + exit(failures ? EXIT_FAILURE : EXIT_SUCCESS); } diff --git a/test_json.c b/test_json.c index 85059f83..7d63c049 100644 --- a/test_json.c +++ b/test_json.c @@ -20,7 +20,7 @@ static void assert_case(int num, int status) if (status != 0) { (void)fprintf(stderr, "case %d FAILED, status %d (%s).\n", num, status, json_error_string(status)); - exit(1); + exit(EXIT_FAILURE); } } @@ -30,7 +30,7 @@ static void assert_string(char *attr, char *fld, char *val) (void)fprintf(stderr, "'%s' string attribute eval failed, value = %s.\n", attr, fld); - exit(1); + exit(EXIT_FAILURE); } } @@ -40,7 +40,7 @@ static void assert_integer(char *attr, int fld, int val) (void)fprintf(stderr, "'%s' integer attribute eval failed, value = %d.\n", attr, fld); - exit(1); + exit(EXIT_FAILURE); } } @@ -50,7 +50,7 @@ static void assert_uinteger(char *attr, uint fld, uint val) (void)fprintf(stderr, "'%s' integer attribute eval failed, value = %u.\n", attr, fld); - exit(1); + exit(EXIT_FAILURE); } } @@ -61,7 +61,7 @@ static void assert_boolean(char *attr, bool fld, bool val) (void)fprintf(stderr, "'%s' boolean attribute eval failed, value = %s.\n", attr, fld ? "true" : "false"); - exit(1); + exit(EXIT_FAILURE); } /*@+boolcompare@*/ } @@ -76,7 +76,7 @@ static void assert_real(char *attr, double fld, double val) (void)fprintf(stderr, "'%s' real attribute eval failed, value = %f.\n", attr, fld); - exit(1); + exit(EXIT_FAILURE); } } @@ -228,7 +228,7 @@ int main(int argc UNUSED, char *argv[]UNUSED) case 'h': default: (void)fputs("usage: test_json [-D lvl]\n", stderr); - exit(1); + exit(EXIT_FAILURE); } } @@ -314,5 +314,5 @@ int main(int argc UNUSED, char *argv[]UNUSED) (void)fprintf(stderr, "succeeded.\n"); - exit(0); + exit(EXIT_SUCCESS); } diff --git a/test_libgps.c b/test_libgps.c index 1655fdda..d794fa01 100644 --- a/test_libgps.c +++ b/test_libgps.c @@ -21,7 +21,7 @@ static void onsig(int sig) { (void)fprintf(stderr, "libgps: died with signal %d\n", sig); - exit(1); + exit(EXIT_FAILURE); } /* must start zeroed, otherwise the unit test will try to chase garbage pointer fields. */ @@ -53,7 +53,7 @@ int main(int argc, char *argv[]) sizeof(struct attitude_t), sizeof(struct rawdata_t), sizeof(collect.devices), sizeof(struct policy_t), sizeof(struct version_t), sizeof(struct gst_t)); - exit(0); + exit(EXIT_SUCCESS); case 'D': debug = atoi(optarg); break; @@ -61,7 +61,7 @@ int main(int argc, char *argv[]) case 'h': default: (void)fputs("usage: test_libgps [-b] [-D lvl] [-s]\n", stderr); - exit(1); + exit(EXIT_FAILURE); } } @@ -75,7 +75,7 @@ int main(int argc, char *argv[]) } } else if (gps_open(NULL, 0, &collect) <= 0) { (void)fputs("Daemon is not running.\n", stdout); - exit(1); + exit(EXIT_FAILURE); } else if (optind < argc) { (void)strlcpy(buf, argv[optind], BUFSIZ); (void)strlcat(buf, "\n", BUFSIZ); diff --git a/test_packet.c b/test_packet.c index ad0a61e4..09ea5093 100644 --- a/test_packet.c +++ b/test_packet.c @@ -329,7 +329,7 @@ int main(int argc, char *argv[]) mp = singletests + atoi(optarg) - 1; (void)fwrite(mp->test, mp->testlen, sizeof(char), stdout); (void)fflush(stdout); - exit(0); + exit(EXIT_SUCCESS); case 't': singletest = atoi(optarg); break; @@ -350,5 +350,5 @@ int main(int argc, char *argv[]) (void)fputs("=== EOF with buffer nonempty test ===\n", stdout); runon_test(&runontests[0]); } - exit(failcount > 0 ? 1 : 0); + exit(failcount > 0 ? EXIT_FAILURE : EXIT_SUCCESS); } -- cgit v1.2.1