From: Bartosz Golaszewski Date: Fri, 6 Jan 2017 15:29:15 +0000 (+0100) Subject: gpioget: move printing the help message to a separate function X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=ccb98d37dee295ff34a220a52acbc41fc6c66f1c;p=qemu-gpiodev%2Flibgpiod.git gpioget: move printing the help message to a separate function Signed-off-by: Bartosz Golaszewski --- diff --git a/gpioget.c b/gpioget.c index 7f09e7b..f93daf3 100644 --- a/gpioget.c +++ b/gpioget.c @@ -23,6 +23,16 @@ static const struct option longopts[] = { static const char *const shortopts = "hl"; +static void print_help(void) +{ + printf("Usage: %s [CHIP NAME/NUMBER] [LINE OFFSET] \n", + get_progname()); + printf("List all GPIO chips\n"); + printf("Options:\n"); + printf(" -h, --help:\t\tdisplay this message and exit\n"); + printf(" -l, --active-low:\tset the line active state to low\n"); +} + int main(int argc, char **argv) { bool active_low = false; @@ -39,12 +49,7 @@ int main(int argc, char **argv) switch (optc) { case 'h': - printf("Usage: %s [CHIP NAME/NUMBER] [LINE OFFSET] \n", - get_progname()); - printf("List all GPIO chips\n"); - printf("Options:\n"); - printf(" -h, --help:\t\tdisplay this message and exit\n"); - printf(" -l, --active-low:\tset the line active state to low\n"); + print_help(); exit(EXIT_SUCCESS); case 'l': active_low = true;