Skip to content

Commit

Permalink
Fix returns
Browse files Browse the repository at this point in the history
  • Loading branch information
penguin-teal committed Nov 10, 2023
1 parent ec6945c commit 97ef69f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
7 changes: 3 additions & 4 deletions src/hash.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
10 changes: 8 additions & 2 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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;
}

0 comments on commit 97ef69f

Please sign in to comment.