Skip to contentSkip to conversation

testdisplay: Allow getopt to print error messages

PATCH In review Thomas Wood 2 participants 2 messages Oct 10, 2013 – Oct 11, 2013

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 testdisplay: Allow getopt to print error messages

By not assigning opterr, getopt will print its own error message that includes information about whether an option is unknown or just requires an additional argument.

---
 tests/testdisplay.c | 2 --
 1 file changed, 2 deletions(-)
tests/testdisplay.c +0 -2
index 0fcce19..a0f43e9 100644
@@ -723,7 +723,6 @@ int main(int argc, char **argv)
 
 	enter_exec_path( argv );
 
-	opterr = 0;
 	while ((c = getopt(argc, argv, optstr)) != -1) {
 		switch (c) {
 		case '3':
@@ -771,7 +770,6 @@ int main(int argc, char **argv)
 			sscanf(optarg, "%d,%d", &specified_disp_id, &specified_mode_num);
 			break;
 		default:
-			fprintf(stderr, "unknown option %c\n", c);
 			/* fall through */
 		case 'h':
 			usage(argv[0]);
Signature · 1 line
1.8.3.1
#1 lore raw
Quoted 5 lines · Thomas Wood

By not assigning opterr, getopt will print its own error message that includes information about whether an option is unknown or just requires an additional argument.

Look good to me, pushed. Thanks for the patch.

Signature · 1 line
Damien