Skip to content

Commit e274001

Browse files
GGZ8delta512
andcommitted
Refactor the help/usage message for canplayer
Limit the error return value only to unknown options. If the utility is invoked with the help option '-h', display the usage message and exit successfully. Co-authored-by: Filip Valgimigli <filip.valgimigli@unimore.it> Signed-off-by: Filip Valgimigli <filip.valgimigli@unimore.it>
1 parent 185c14f commit e274001

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

canplayer.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ int main(int argc, char **argv)
279279
char *fret;
280280
unsigned long long sec, usec;
281281

282-
while ((opt = getopt(argc, argv, "I:l:tin:g:s:xv?")) != -1) {
282+
while ((opt = getopt(argc, argv, "I:l:tin:g:s:xvh")) != -1) {
283283
switch (opt) {
284284
case 'I':
285285
infile = fopen(optarg, "r");
@@ -334,10 +334,14 @@ int main(int argc, char **argv)
334334
verbose++;
335335
break;
336336

337-
case '?':
337+
case 'h':
338+
print_usage(basename(argv[0]));
339+
exit(EXIT_SUCCESS);
340+
break;
341+
338342
default:
339343
print_usage(basename(argv[0]));
340-
return 1;
344+
exit(EXIT_FAILURE);
341345
break;
342346
}
343347
}

0 commit comments

Comments
 (0)