Skip to content

Commit

Permalink
kcapi-hasher: propagate failed check
Browse files Browse the repository at this point in the history
Return code of -c was based on the result of the last record check in
a checkfile. Now, if at least one check fails then this failure is
propagated into return code.

Signed-off-by: Stephan Mueller <smueller@chronox.de>
  • Loading branch information
The-Mule authored and smuellerDD committed Nov 25, 2023
1 parent a3fcea2 commit 38a27c1
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion apps/kcapi-hasher.c
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,7 @@ static int process_checkfile(const struct hash_params *params,
FILE *file = NULL;
int ret = 0;
int checked_any = 0;
int failed_any = 0;
struct kcapi_handle *handle;
const char *hashname = params->name.kcapiname;

Expand Down Expand Up @@ -689,6 +690,7 @@ static int process_checkfile(const struct hash_params *params,
if (log < CHK_QUIET)
printf("%s: OK\n", filename);
} else {
failed_any = 1;
if (log < CHK_STATUS)
printf("%s: Not OK\n", filename);
}
Expand All @@ -705,7 +707,7 @@ static int process_checkfile(const struct hash_params *params,
* If we found no lines to check, return an error.
* (See https://pagure.io/hmaccalc/c/1afb99549816192eb8e6bc8101bc417c2ffa764c)
*/
return ret != 0 ? ret : !checked_any;
return ret != 0 ? ret : !(checked_any && !failed_any);

}

Expand Down

0 comments on commit 38a27c1

Please sign in to comment.