From ccb98d37dee295ff34a220a52acbc41fc6c66f1c Mon Sep 17 00:00:00 2001 From: Bartosz Golaszewski Date: Fri, 6 Jan 2017 16:29:15 +0100 Subject: [PATCH] gpioget: move printing the help message to a separate function Signed-off-by: Bartosz Golaszewski --- gpioget.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) 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; -- 2.30.2