Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0 |
Ingo Molnar | 0780060 | 2009-04-20 15:00:56 +0200 | [diff] [blame] | 2 | /* |
Namhyung Kim | 5f9273d | 2011-12-13 22:52:03 +0900 | [diff] [blame] | 3 | * usage.c |
| 4 | * |
| 5 | * Various reporting routines. |
| 6 | * Originally copied from GIT source. |
Ingo Molnar | 0780060 | 2009-04-20 15:00:56 +0200 | [diff] [blame] | 7 | * |
| 8 | * Copyright (C) Linus Torvalds, 2005 |
| 9 | */ |
| 10 | #include "util.h" |
Arnaldo Carvalho de Melo | 215a0d3 | 2019-07-04 11:21:24 -0300 | [diff] [blame] | 11 | #include <stdio.h> |
| 12 | #include <stdlib.h> |
| 13 | #include <linux/compiler.h> |
Ingo Molnar | 0780060 | 2009-04-20 15:00:56 +0200 | [diff] [blame] | 14 | |
Arnaldo Carvalho de Melo | 6c34664 | 2017-06-16 11:39:15 -0300 | [diff] [blame] | 15 | static __noreturn void usage_builtin(const char *err) |
Ingo Molnar | 0780060 | 2009-04-20 15:00:56 +0200 | [diff] [blame] | 16 | { |
Ingo Molnar | 716c69f | 2009-06-07 17:31:52 +0200 | [diff] [blame] | 17 | fprintf(stderr, "\n Usage: %s\n", err); |
Ingo Molnar | 0780060 | 2009-04-20 15:00:56 +0200 | [diff] [blame] | 18 | exit(129); |
| 19 | } |
| 20 | |
Ingo Molnar | 0780060 | 2009-04-20 15:00:56 +0200 | [diff] [blame] | 21 | /* If we are in a dlopen()ed .so write to a global variable would segfault |
| 22 | * (ugh), so keep things static. */ |
Arnaldo Carvalho de Melo | 6c34664 | 2017-06-16 11:39:15 -0300 | [diff] [blame] | 23 | static void (*usage_routine)(const char *err) __noreturn = usage_builtin; |
Namhyung Kim | 2690c73 | 2015-10-20 00:23:49 +0900 | [diff] [blame] | 24 | |
Ingo Molnar | 0780060 | 2009-04-20 15:00:56 +0200 | [diff] [blame] | 25 | void usage(const char *err) |
| 26 | { |
| 27 | usage_routine(err); |
| 28 | } |