gpioget: move printing the help message to a separate function
authorBartosz Golaszewski <bartekgola@gmail.com>
Fri, 6 Jan 2017 15:29:15 +0000 (16:29 +0100)
committerBartosz Golaszewski <bartekgola@gmail.com>
Fri, 6 Jan 2017 15:29:15 +0000 (16:29 +0100)
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
gpioget.c

index 7f09e7b7d3120bb7478a4f055576ef63b3072885..f93daf36a9e92899d60462c723e72d068a531fdf 100644 (file)
--- 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] <options>\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] <options>\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;