From 8559d31ea8a9eed936f9ad29b440cef1b0fcddbb Mon Sep 17 00:00:00 2001 From: David Griffith Date: Wed, 23 Oct 2019 17:04:32 -0700 Subject: [PATCH] Use EXIT_SUCCESS or EXIT_FAILURE for exit() calls for portability. --- src/curses/ux_audio.c | 2 +- src/curses/ux_audio_oss.c | 14 +++++++------- src/curses/ux_init.c | 16 ++++++++-------- src/dos/bcinit.c | 2 +- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/curses/ux_audio.c b/src/curses/ux_audio.c index 4982df4..336d9ff 100644 --- a/src/curses/ux_audio.c +++ b/src/curses/ux_audio.c @@ -879,7 +879,7 @@ os_init_sound(void) err = pthread_create(&unused_id, &attr, &audio_loop, NULL); if (err != 0) { fprintf(stderr, "Can't create audio thread :[%s]", strerror(err)); - exit(1); + exit(EXIT_FAILURE); } } diff --git a/src/curses/ux_audio_oss.c b/src/curses/ux_audio_oss.c index 2e344a4..b65e73a 100644 --- a/src/curses/ux_audio_oss.c +++ b/src/curses/ux_audio_oss.c @@ -78,7 +78,7 @@ static void sigterm_handler(int signal) { ioctl(dsp_fd, SNDCTL_DSP_RESET, 0); if (mixer_fd >= 0) ioctl(mixer_fd, SOUND_MIXER_WRITE_VOLUME, &old_volume); - _exit(0); + _exit(EXIT_SUCCESS); } static void oss_sigint_handler(int signal) { @@ -93,7 +93,7 @@ static void play_sound(int volume, int repeats) { dsp_fd = open(SOUND_DEV, O_WRONLY); if (dsp_fd < 0) { perror(SOUND_DEV); - _exit(1); + _exit(EXIT_FAILURE); } @@ -103,19 +103,19 @@ static void play_sound(int volume, int repeats) { */ if (ioctl(dsp_fd, SNDCTL_DSP_SETFMT, &format) == -1) { perror(SOUND_DEV); - exit(1); + exit(EXIT_FAILURE); } if (format != AFMT_U8) { fprintf(stderr, "bad sound format\n"); - exit(1); + exit(EXIT_FAILURE); } if (ioctl(dsp_fd, SNDCTL_DSP_CHANNELS, &channels) == -1) { perror(SOUND_DEV); - exit(1); + exit(EXIT_FAILURE); } if (channels != 1) { fprintf(stderr, "bad channels\n"); - exit(1); + exit(EXIT_FAILURE); } /* End sound fix from Torbjorn Andersson (no dot thingies) */ @@ -165,7 +165,7 @@ finish: ioctl(dsp_fd, SNDCTL_DSP_SYNC, 0); if (mixer_fd >= 0) ioctl(mixer_fd, SOUND_MIXER_WRITE_VOLUME, &old_volume); - _exit(0); + _exit(EXIT_SUCCESS); } diff --git a/src/curses/ux_init.c b/src/curses/ux_init.c index 74fa8e9..63ef72b 100644 --- a/src/curses/ux_init.c +++ b/src/curses/ux_init.c @@ -162,7 +162,7 @@ void os_fatal (const char *s, ...) } else { os_reset_screen(); ux_blorb_stop(); - exit(1); + exit(EXIT_FAILURE); } } @@ -175,7 +175,7 @@ void os_fatal (const char *s, ...) fputs ("\n\n", stderr); - exit (1); + exit (EXIT_FAILURE); } /* os_fatal */ /* extern char script_name[]; */ @@ -208,7 +208,7 @@ void os_process_arguments (int argc, char *argv[]) #ifndef WIN32 if ((getuid() == 0) || (geteuid() == 0)) { printf("I won't run as root!\n"); - exit(1); + exit(EXIT_FAILURE); } #endif @@ -220,7 +220,7 @@ void os_process_arguments (int argc, char *argv[]) if ((home = getenv(HOMEDIR)) == NULL) { printf("Hard drive on fire!\n"); - exit(1); + exit(EXIT_FAILURE); } @@ -310,7 +310,7 @@ void os_process_arguments (int argc, char *argv[]) case 'S': f_setup.script_cols = atoi(zoptarg); break; case 't': u_setup.tandy_bit = 1; break; case 'u': f_setup.undo_slots = atoi(zoptarg); break; - case 'v': print_version(); exit(0); break; + case 'v': print_version(); exit(EXIT_SUCCESS); break; case 'w': u_setup.screen_width = atoi(zoptarg); break; case 'x': f_setup.expand_abbreviations = 1; break; case 'Z': @@ -334,7 +334,7 @@ void os_process_arguments (int argc, char *argv[]) puts (INFORMATION); puts (INFO2); - exit (0); + exit (EXIT_SUCCESS); } /* This section is exceedingly messy and really can't be fixed @@ -448,7 +448,7 @@ void os_init_screen (void) if (initscr() == NULL) { /* Set up curses */ os_fatal("Unable to initialize curses. Maybe your $TERM setting is bad."); - exit(1); + exit(EXIT_FAILURE); } u_setup.curses_active = 1; /* Let os_fatal know curses is running */ raw(); /* Raw input mode, no line processing */ @@ -581,7 +581,7 @@ void os_quit(void) refresh(); endwin(); } - exit(1); + exit(EXIT_FAILURE); } /* os_quit */ diff --git a/src/dos/bcinit.c b/src/dos/bcinit.c index e3e07c2..60cdab1 100644 --- a/src/dos/bcinit.c +++ b/src/dos/bcinit.c @@ -371,7 +371,7 @@ void os_process_arguments(int argc, char *argv[]) if (zoptind != argc - 1) { printf("FROTZ V%s\tMSDOS / PCDOS Edition\n", VERSION); puts(information); - exit(EXIT_FAILURE); + exit(EXIT_SUCCESS); } /* Set the story file name */ -- 2.34.1