@@ -56,8 +56,8 @@ cmpDeviceName (const void * const a, const void * const b)
5656/* ========================================================================== *
5757 * Show usage
5858 * ========================================================================== */
59- void
60- usage (const char * const string )
59+ int
60+ usage (void )
6161{
6262 int line ;
6363 const char * const text [] =
@@ -73,15 +73,12 @@ usage (const char * const string)
7373 NULL /* Last element should be NULL */
7474 };
7575
76- if (string )
77- {
78- say (mode , MSG_I , string );
79- }
80-
8176 for (line = 0 ; text [line ]; ++ line )
8277 {
8378 say (mode , MSG_I , text [line ]);
8479 }
80+
81+ return 1 ;
8582}
8683
8784/* ========================================================================== *
@@ -445,7 +442,7 @@ del (void)
445442
446443 for (index = 0 ; devices [index ]; ++ index )
447444 {
448- say (mode , MSG_I , "[%3d] %s\n " , index + 1 , devices [index ]-> name );
445+ say (mode , MSG_I , "[%3d] %s" , index + 1 , devices [index ]-> name );
449446
450447 if (!(strncmp (UNKNOWNSTR , devices [index ]-> name , UNKNOWNSTRLEN )))
451448 {
@@ -591,7 +588,7 @@ main (const int argc, const char * const * const argv)
591588
592589 if (argc != 2 )
593590 {
594- usage (NULL );
591+ usage ();
595592 exit (1 );
596593 }
597594
@@ -611,7 +608,7 @@ main (const int argc, const char * const * const argv)
611608 }
612609 if (status )
613610 {
614- exit ( 0 ) ;
611+ goto CLEAN ;
615612 }
616613
617614 if (-1 == (status = attempt ("^del(ete)?$" , action , del )))
@@ -621,13 +618,18 @@ main (const int argc, const char * const * const argv)
621618 }
622619 if (status )
623620 {
624- exit ( 0 ) ;
621+ goto CLEAN ;
625622 }
626623
627- usage (NULL );
624+ if (-1 == (status = attempt ("^h(elp)?$" , action , usage )))
625+ {
626+ say (mode , MSG_E , "attempt failed\n" );
627+ exit (1 );
628+ }
628629
630+ CLEAN :
629631 free (action );
630632
631- return 0 ;
633+ return status ;
632634}
633635
0 commit comments