Skip to content

Commit

Permalink
Return error codes from elfdeps
Browse files Browse the repository at this point in the history
processFile() always returned errors for things like non-existent file
and non-elf file etc but we've ignored it all. Reflect such errors with
non-zero exit code as per common practise.
  • Loading branch information
pmatilai committed Aug 24, 2018
1 parent b5eed5a commit 4cc32de
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions tools/elfdeps.c
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,7 @@ static int processFile(const char *fn, int dtype)

int main(int argc, char *argv[])
{
int rc = 0;
int provides = 0;
int requires = 0;
poptContext optCon;
Expand Down Expand Up @@ -381,16 +382,18 @@ int main(int argc, char *argv[])
if (poptPeekArg(optCon)) {
const char *fn;
while ((fn = poptGetArg(optCon)) != NULL) {
(void) processFile(fn, requires);
if (processFile(fn, requires))
rc = EXIT_FAILURE;
}
} else {
char fn[BUFSIZ];
while (fgets(fn, sizeof(fn), stdin) != NULL) {
fn[strlen(fn)-1] = '\0';
(void) processFile(fn, requires);
if (processFile(fn, requires))
rc = EXIT_FAILURE;
}
}

poptFreeContext(optCon);
return 0;
return rc;
}

0 comments on commit 4cc32de

Please sign in to comment.