diff mbox series

[2/3] scripts: mkhash fix return code handling

Message ID 20200717034332.3726979-2-mail@aparcar.org
State Superseded
Headers show
Series [1/3] scripts: mkhash show -n option in usage | expand

Commit Message

Paul Spooren July 17, 2020, 3:43 a.m. UTC
If hashing a file fails mkhash shouldn't just silently fail. Now check
after each call of `hash_file()` the return and exit early in case of
errors. The return value which was previously ignored and would always
return 0.

Signed-off-by: Paul Spooren <mail@aparcar.org>
---
 scripts/mkhash.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/scripts/mkhash.c b/scripts/mkhash.c
index e26ca3a350..96f92e42b5 100644
--- a/scripts/mkhash.c
+++ b/scripts/mkhash.c
@@ -797,7 +797,7 @@  int main(int argc, char **argv)
 {
 	struct hash_type *t;
 	const char *progname = argv[0];
-	int i, ch;
+	int i, ch, hash_return;
 	bool add_filename = false;
 
 	while ((ch = getopt(argc, argv, "n")) != -1) {
@@ -824,7 +824,8 @@  int main(int argc, char **argv)
 		return hash_file(t, NULL, add_filename);
 
 	for (i = 0; i < argc - 1; i++)
-		hash_file(t, argv[1 + i], add_filename);
+		if ((hash_return = hash_file(t, argv[1 + i], add_filename)))
+			return hash_return;
 
 	return 0;
 }