diff --git a/src/hash.c b/src/hash.c index cbd3d3c..fd3e10e 100644 --- a/src/hash.c +++ b/src/hash.c @@ -124,12 +124,11 @@ bool doHashes(struct AppArgs *appArgs, FILE *outF) if(!hashSize) { - if(inVal) free(inVal); - fprintf(stderr, "Hashing failed. (got hashSize was zero)\n"); - return 1; + return false; } - printOut(hash, outF, &appArgs); + printOut(hash, outF, appArgs); + return true; } diff --git a/src/main.c b/src/main.c index f20ad67..4a93b77 100644 --- a/src/main.c +++ b/src/main.c @@ -10,10 +10,13 @@ int main(int argc, char **argv) { char *inVal = NULL; + int code; + bool success; struct AppArgs appArgs; + if(!doArgp(&appArgs, argc, argv)) return 2; - int code = getInput(&appArgs, &inVal); + code = getInput(&appArgs, &inVal); if(code) return code; if(appArgs.escape) @@ -54,9 +57,12 @@ int main(int argc, char **argv) return 2; } - doHashes(&appArgs, outF); + success = doHashes(&appArgs, outF); + if(inVal) free(inVal); fclose(outF); + if(!success) return 2; + return 0; }