gbaconv

A set of tools aimed at GameBoy Advance developers
Log | Files | Refs | README | LICENSE

commit a3c04b6f29dcdb8e57b7250f6110647509b073a9
parent 86c0fddeb8d18b6eb6b682f6c8ef8027d2971b8b
Author: Frederic Cambus <fred@statdns.com>
Date:   Thu,  9 May 2019 14:57:05 +0200

Use EXIT_SUCCESS and EXIT_FAILURE macros for return values.

Diffstat:
Mpcx2gba.c | 18+++++++++---------
Mwav2gba.c | 19++++++++++---------
2 files changed, 19 insertions(+), 18 deletions(-)

diff --git a/pcx2gba.c b/pcx2gba.c @@ -6,7 +6,7 @@ * PCX to GBA Converter * * Created: 2002-12-09 - * Last Updated: 2019-03-25 + * Last Updated: 2019-05-09 * * GBAconv is released under the BSD 2-Clause license. * See LICENSE file for details. @@ -63,28 +63,28 @@ int main(int argc, char *argv[]) { if (argc != 3) { printf("USAGE: pcx2gba input.pcx array_name (Input File must be 8-bpp PCX)\n\n"); - return 0; + return EXIT_SUCCESS; } fd = open(argv[1], O_RDONLY); if (fd == -1) - return 1; + return EXIT_FAILURE; if (fstat(fd, &st) == -1) { close(fd); - return 1; + return EXIT_FAILURE; } if (st.st_size < PCX_HEADER_LENGTH + PCX_PALETTE_LENGTH) { printf("ERROR: Input File is not a PCX file\n\n"); - return 1; + return EXIT_FAILURE; } /* mmap input file into memory */ input_file_buffer = mmap(NULL, st.st_size, PROT_READ, MAP_PRIVATE, fd, 0); if (input_file_buffer == MAP_FAILED) { close(fd); - return 1; + return EXIT_FAILURE; } memcpy(&pcx_header, input_file_buffer, PCX_HEADER_LENGTH); @@ -92,13 +92,13 @@ int main(int argc, char *argv[]) { /* Check that the file is a valid PCX file */ if (pcx_header.ID != 10) { printf("ERROR: Input File is not a PCX file\n\n"); - return 1; + return EXIT_FAILURE; } /* Check that the file is a 8-bpp PCX */ if (pcx_header.bits_per_pixel != 8) { printf("ERROR: Input File is not 8-bpp\n\n"); - return 1; + return EXIT_FAILURE; } /* Uncompress RLE encoded PCX Input File */ @@ -152,5 +152,5 @@ int main(int argc, char *argv[]) { munmap(input_file_buffer, st.st_size); close(fd); - return 0; + return EXIT_SUCCESS; } diff --git a/wav2gba.c b/wav2gba.c @@ -6,7 +6,7 @@ * WAV to GBA Converter * * Created: 2002-12-10 - * Last Updated: 2019-03-25 + * Last Updated: 2019-05-09 * * GBAconv is released under the BSD 2-Clause license. * See LICENSE file for details. @@ -14,6 +14,7 @@ #include <fcntl.h> #include <stdio.h> +#include <stdlib.h> #include <string.h> #include <unistd.h> #include <sys/mman.h> @@ -45,28 +46,28 @@ int main(int argc, char *argv[]) { if (argc != 3) { printf("USAGE: wav2gba input.wav array_name (Input File must be 8-bit, MONO)\n\n"); - return 0; + return EXIT_SUCCESS; } fd = open(argv[1], O_RDONLY); if (fd == -1) - return 1; + return EXIT_FAILURE; if (fstat(fd, &st) == -1) { close(fd); - return 1; + return EXIT_FAILURE; } /* mmap input file into memory */ input_file_buffer = mmap(NULL, st.st_size, PROT_READ, MAP_PRIVATE, fd, 0); if (input_file_buffer == MAP_FAILED) { close(fd); - return 1; + return EXIT_FAILURE; } if (st.st_size < WAVE_HEADER_LENGTH) { printf("ERROR: Input File is not a WAV file\n\n"); - return 1; + return EXIT_FAILURE; } /* Check that the file is a valid 8-bit MONO WAV */ @@ -74,12 +75,12 @@ int main(int argc, char *argv[]) { if (wave_header.channels != 1) { printf("ERROR: Input File is not MONO\n\n"); - return 1; + return EXIT_FAILURE; } if (wave_header.bits_per_sample != 8) { printf("ERROR: Input File is not 8-bit\n\n"); - return 1; + return EXIT_FAILURE; } fprintf(stderr, "INPUT FILE: %s (8-bit, MONO, %i Hz)\n", argv[1], wave_header.sample_rate); @@ -99,5 +100,5 @@ int main(int argc, char *argv[]) { munmap(input_file_buffer, st.st_size); close(fd); - return 0; + return EXIT_SUCCESS; }