Re: [PATCH iproute2-next 3/7] misc: put help to stdout and usage to stderr
David Ahern <[email protected]>
| Newsgroups | org.kernel.vger.netdev |
|---|---|
| Message-ID | <[email protected]> |
On 8/7/26 9:42 AM, Stephen Hemminger wrote:
> diff --git a/misc/rtacct.c b/misc/rtacct.c
> index cd84b7f0..0e2c03af 100644
> --- a/misc/rtacct.c
> +++ b/misc/rtacct.c
> @@ -412,14 +412,13 @@ static int verify_forging(int fd)
> return -1;
> }
>
> -static void usage(void) __attribute__((noreturn));
> +static void usage(bool help) __attribute__((noreturn));
>
> -static void usage(void)
> +static void usage(bool help)
> {
> - fprintf(stderr,
> -"Usage: rtacct [ -h?vVzrnasd:t: ] [ ListOfRealms ]\n"
> - );
> - exit(-1);
> + fprintf(help ? stdout : stderr,
> + "Usage: rtacct [ -h?vVzrnasd:t: ] [ ListOfRealms ]\n");
> + exit(help ? 0 : 1);
> }
>
> int main(int argc, char *argv[])
> @@ -469,7 +468,7 @@ int main(int argc, char *argv[])
> case 'h':
> case '?':
> default:
> - usage();
> + usage(ch == 'h');
> }
> }
>
rtacct.c:415:19: error: unknown type name ‘bool’
415 | static void usage(bool help) __attribute__((noreturn));
| ^~~~
rtacct.c:29:1: note: ‘bool’ is defined in header ‘<stdbool.h>’; did you
forget to ‘#include <stdbool.h>’?
28 | #include "version.h"
+++ |+#include <stdbool.h>
29 |
rtacct.c:417:19: error: unknown type name ‘bool’
417 | static void usage(bool help)
| ^~~~
rtacct.c:417:19: note: ‘bool’ is defined in header ‘<stdbool.h>’; did
you forget to ‘#include <stdbool.h>’?
rtacct.c: In function ‘main’:
rtacct.c:471:25: warning: implicit declaration of function ‘usage’
[-Wimplicit-function-declaration]
471 | usage(ch == 'h');
| ^~~~~
make[1]: *** [Makefile:25: rtacct] Error 1
make: *** [Makefile:72: all] Error 2