Author: Adam <git@apiote.tk>
return exit status on errors
meowsum.c | 18 +++++++++++-------
diff --git a/meowsum.c b/meowsum.c index 48538d5bb12054c13fe01652ef2a8191137f3ab2..df5b7b67a0c583824ba9b045805023f0a56cbbae 100644 --- a/meowsum.c +++ b/meowsum.c @@ -142,8 +142,8 @@ return result; } bool sum_files(char *argv[], int start, int argc, int hash_size) { - char *hex_hash; meow_u128 *hash; + char *hex_hash; unsigned long size; for (int i = start; i < argc; ++i) { @@ -278,15 +278,19 @@ return 1; } if (mode == MODE_SUM) { - sum_files(argv, first_file_index, argc, hash_size); - } - if (mode == MODE_CHECK) { + bool sum_result = sum_files(argv, first_file_index, argc, hash_size); + if (!sum_result) { + return 1; + } + } else if (mode == MODE_CHECK) { bool check_result = check_files(argv, first_file_index, argc, quiet, strict_error); if (!check_result) { - exit_status = 1; + return 1; } + } else { + print_usage(); + return 1; } - - return exit_status; + return 0; }