Cygwin: utils: convert usage() to proper noreturn function throughout

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
This commit is contained in:
Corinna Vinschen
2020-08-07 13:29:43 +02:00
parent 9beb7b9771
commit e7fca6f867
23 changed files with 55 additions and 111 deletions

View File

@@ -10,16 +10,17 @@ details. */
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <getopt.h>
#include <sys/ioctl.h>
#include <cygwin/kd.h>
#include <cygwin/version.h>
static void
usage (void)
static void __attribute__ ((__noreturn__))
usage (FILE *stream)
{
fprintf (stderr, "Usage: %s [metabit|escprefix]\n"
fprintf (stream, "Usage: %s [metabit|escprefix]\n"
"\n"
"Get or set keyboard meta mode\n"
"\n"
@@ -32,6 +33,7 @@ usage (void)
" -h, --help This text\n"
" -V, --version Print program version and exit\n\n",
program_invocation_short_name);
exit (stream == stdout ? 0 : 1);
}
static void
@@ -87,8 +89,7 @@ main (int ac, char *av[])
switch (opt)
{
case 'h':
usage ();
return 0;
usage (stdout);
case 'V':
print_version ();
return 0;
@@ -105,10 +106,7 @@ main (int ac, char *av[])
|| !strcmp ("escprefix", av[1]))
param = 0x04;
else
{
usage ();
return 1;
}
usage (stderr);
if (ioctl (0, KDSKBMETA, param) < 0)
{
error ();