From 8fe5a1f199984d6efe0bd0a898b2f3a94d700f1c Mon Sep 17 00:00:00 2001
From: Hsuan Ting Chen <roccochen@google.com>
Date: Mon, 9 Sep 2024 17:23:37 +0800
Subject: util/ifdtool: Exit with failure on unrecognized flags

ifdtool will exit with success while encountering an unrecognized flag.
For example, -g is a newly introduced flag, when we want to call it with
an older version of ifdtool, we will get the return value 0 and cause
confusion.

This patch change the exit status for unrecognized flags and doesn't
change the exit status for -h and -?.

BUG=b:362983041
BRANCH=none
TEST=futility update --servo --image /var/tmp/image.bin --quirks
     unlock_csme on the servo host with old ifdtool

Signed-off-by: Hsuan Ting Chen <roccochen@google.com>
Change-Id: I046ad7ec790cda41a98a1de5cd730d32f65a9067
Reviewed-on: https://review.coreboot.org/c/coreboot/+/84260
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Subrata Banik <subratabanik@google.com>
---
 util/ifdtool/ifdtool.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/util/ifdtool/ifdtool.c b/util/ifdtool/ifdtool.c
index 32b2081d93..5993bfc99b 100644
--- a/util/ifdtool/ifdtool.c
+++ b/util/ifdtool/ifdtool.c
@@ -2514,10 +2514,13 @@ int main(int argc, char *argv[])
 			break;
 		case 'h':
 		case '?':
-		default:
 			print_usage(argv[0]);
 			exit(EXIT_SUCCESS);
 			break;
+		default:
+			print_usage(argv[0]);
+			exit(EXIT_FAILURE);
+			break;
 		}
 	}
 
-- 
cgit v1.2.3