From b1a2c664a90c9ec52f02f6d8650ae87ae6517ec1 Mon Sep 17 00:00:00 2001 From: "Anthony J. Bentley" Date: Sat, 4 Jun 2011 21:33:03 -0600 Subject: [PATCH] Revert use of system exit codes. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit While well‐intentioned, in practice this hurts portability and really, nobody checks the return codes anyway. --- src/asm/main.c | 13 ++++++------- src/asm/yaccprt1.y | 1 - src/lib/main.c | 7 +++---- src/link/main.c | 7 +++---- src/link/mapfile.c | 5 ++--- src/link/object.c | 5 ++--- 6 files changed, 16 insertions(+), 22 deletions(-) diff --git a/src/asm/main.c b/src/asm/main.c index f3dac270..f3e61932 100644 --- a/src/asm/main.c +++ b/src/asm/main.c @@ -10,7 +10,6 @@ #include #include #include -#include #include #include @@ -137,7 +136,7 @@ opt_Parse(char *s) newopt.gbgfx[2] = s[3]; newopt.gbgfx[3] = s[4]; } else { - errx(EX_USAGE, "Must specify exactly 4 characters for option 'g'"); + errx(1, "Must specify exactly 4 characters for option 'g'"); } break; case 'b': @@ -231,7 +230,7 @@ PrintUsage(void) printf("RGBAsm v" ASM_VERSION " (part of ASMotor " ASMOTOR_VERSION ")\n\n"); printf("Usage: rgbasm [-b chars] [-g chars] [-i path] [-o outfile] [-p pad_value] file\n"); - exit(EX_USAGE); + exit(1); } /* * RGBAsm - MAIN.C @@ -274,7 +273,7 @@ main(int argc, char *argv[]) newopt.binary[0] = optarg[1]; newopt.binary[1] = optarg[2]; } else { - errx(EX_USAGE, "Must specify exactly 2 characters for option 'b'"); + errx(1, "Must specify exactly 2 characters for option 'b'"); } case 'g': if (strlen(optarg) == 4) { @@ -283,7 +282,7 @@ main(int argc, char *argv[]) newopt.gbgfx[2] = optarg[3]; newopt.gbgfx[3] = optarg[4]; } else { - errx(EX_USAGE, "Must specify exactly 4 characters for option 'g'"); + errx(1, "Must specify exactly 4 characters for option 'g'"); } break; case 'i': @@ -295,9 +294,9 @@ main(int argc, char *argv[]) case 'p': newopt.fillchar = strtoul(optarg, &ep, 0); if (optarg[0] == '\0' || *ep != '\0') - errx(EX_USAGE, "Invalid argument for option 'p'"); + errx(1, "Invalid argument for option 'p'"); if (newopt.fillchar < 0 || newopt.fillchar > 0xFF) - errx(EX_USAGE, "Argument for option 'p' must be between 0 and 0xFF"); + errx(1, "Argument for option 'p' must be between 0 and 0xFF"); break; default: PrintUsage(); diff --git a/src/asm/yaccprt1.y b/src/asm/yaccprt1.y index 1eec02ec..ce27ba92 100644 --- a/src/asm/yaccprt1.y +++ b/src/asm/yaccprt1.y @@ -5,7 +5,6 @@ #include #include #include -#include #include "asm/symbol.h" #include "asm/asm.h" diff --git a/src/lib/main.c b/src/lib/main.c index f63565c5..89174e0a 100644 --- a/src/lib/main.c +++ b/src/lib/main.c @@ -4,7 +4,6 @@ #include #include #include -#include #include "asmotor.h" @@ -21,7 +20,7 @@ usage(void) { printf("RGBLib v" LIB_VERSION " (part of ASMotor " ASMOTOR_VERSION ")\n\n"); printf("usage: rgblib file [add | delete | extract | list] [module ...]\n"); - exit(EX_USAGE); + exit(1); } /* * The main routine @@ -85,10 +84,10 @@ main(int argc, char *argv[]) ("Extracted module '%s'\n", argv[argn]); } else - err(EX_NOINPUT, + err(1, "Unable to write module '%s'", argv[argn]); } else - errx(EX_NOINPUT, "Module not found"); + errx(1, "Module not found"); argn += 1; argc -= 1; diff --git a/src/link/main.c b/src/link/main.c index db5ad6c4..ebaf2b11 100644 --- a/src/link/main.c +++ b/src/link/main.c @@ -2,7 +2,6 @@ #include #include #include -#include #include #include "asmotor.h" @@ -40,7 +39,7 @@ usage(void) printf("usage: rgblink [-t] [-l library] [-m mapfile] [-n symfile] [-o outfile]\n"); printf("\t [-s symbol] [-z pad_value] objectfile [...]\n"); - exit(EX_USAGE); + exit(1); } /* @@ -74,9 +73,9 @@ main(int argc, char *argv[]) case 'p': fillchar = strtoul(optarg, &ep, 0); if (optarg[0] == '\0' || *ep != '\0') - errx(EX_USAGE, "Invalid argument for option 'p'"); + errx(1, "Invalid argument for option 'p'"); if (fillchar < 0 || fillchar > 0xFF) - errx(EX_USAGE, "Argument for option 'p' must be between 0 and 0xFF"); + errx(1, "Argument for option 'p' must be between 0 and 0xFF"); break; case 's': options |= OPT_SMART_C_LINK; diff --git a/src/link/mapfile.c b/src/link/mapfile.c index 85aef7ea..1b5eaebf 100644 --- a/src/link/mapfile.c +++ b/src/link/mapfile.c @@ -3,7 +3,6 @@ #include #include #include -#include #include "asmotor.h" @@ -22,7 +21,7 @@ SetMapfileName(char *name) mf = fopen(name, "w"); if (mf == NULL) - err(EX_CANTCREAT, "Cannot open mapfile '%s'", name); + err(1, "Cannot open mapfile '%s'", name); } void @@ -31,7 +30,7 @@ SetSymfileName(char *name) sf = fopen(name, "w"); if (sf == NULL) - errx(EX_CANTCREAT, "Cannot open symfile '%s'", name); + errx(1, "Cannot open symfile '%s'", name); fprintf(sf, ";File generated by xLink v" LINK_VERSION "\n\n"); } diff --git a/src/link/object.c b/src/link/object.c index 2b49568c..718f0f3f 100644 --- a/src/link/object.c +++ b/src/link/object.c @@ -8,7 +8,6 @@ #include #include #include -#include #include "link/mylink.h" #include "link/main.h" @@ -446,7 +445,7 @@ obj_Readfile(char *tzObjectfile) pObjfile = fopen(tzObjectfile, "rb"); if (pObjfile == NULL) - err(EX_NOINPUT, "Unable to open object '%s'", + err(1, "Unable to open object '%s'", tzObjectfile); obj_ReadOpenFile(pObjfile, tzObjectfile); fclose(pObjfile); @@ -496,7 +495,7 @@ lib_Readfile(char *tzLibfile) pObjfile = fopen(tzLibfile, "rb"); if (pObjfile == NULL) - err(EX_NOINPUT, "Unable to open object '%s'", tzLibfile); + err(1, "Unable to open object '%s'", tzLibfile); if (!pObjfile) { errx(5, "Unable to open '%s'", tzLibfile); }