gt: Addjust coding style to be more kernel-like
authorKrzysztof Opasiak <k.opasiak@samsung.com>
Tue, 29 Jul 2014 11:37:06 +0000 (13:37 +0200)
committerKrzysztof Opasiak <k.opasiak@samsung.com>
Tue, 29 Jul 2014 11:38:06 +0000 (13:38 +0200)
Change-Id: I034c485bd4fc58079e40f6e673a92b6bf30b052a
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
source/base/src/command.c
source/base/src/executable_command.c
source/base/src/parser.c
source/udc/src/udc.c

index 4d0162c..456e0c3 100644 (file)
@@ -41,16 +41,13 @@ void command_parse(const Command *cmd, int argc, const char **argv,
        bool found = false;
 
        // If there is nothing more to parse it's error
-       if (argc == 0)
-       {
+       if (argc == 0) {
                executable_command_set(exec, cmd->printHelp, data, NULL);
                return;
        }
 
-       while (next->parse)
-       {
-               if (name_matches(next->name, *argv))
-               {
+       while (next->parse) {
+               if (name_matches(next->name, *argv)) {
                        found = true;
                        break;
                }
@@ -58,14 +55,10 @@ void command_parse(const Command *cmd, int argc, const char **argv,
        }
 
        if (found)
-       {
                // We've found a suitable child so let's go deeper
-               next->parse(next, argc - next->distance, argv + next->distance, exec,
-                               data);
-       }
+               next->parse(next, argc - next->distance, argv + next->distance,
+                           exec, data);
        else
-       {
                // We haven't found any suitable child so let's print help
                executable_command_set(exec, cmd->printHelp, data, NULL);
-       }
 }
index f79222f..3e80d41 100644 (file)
 #include "executable_command.h"
 
 void executable_command_set(ExecutableCommand *to_set, ExecutableFunc exec,
-               void *data, CleanupFunc destructor)
+                           void *data, CleanupFunc destructor)
 {
-       if (to_set)
-       {
+       if (to_set) {
                to_set->exec = exec;
                to_set->data = data;
                to_set->destructor = destructor;
@@ -36,10 +35,8 @@ void executable_command_set(ExecutableCommand *to_set, ExecutableFunc exec,
 
 void executable_command_clean(ExecutableCommand *to_clean)
 {
-       if (to_clean)
-       {
-               if (to_clean->destructor)
-               {
+       if (to_clean) {
+               if (to_clean->destructor) {
                        to_clean->destructor(to_clean->data);
                }
                to_clean->exec = NULL;
index 6b1cd99..41f57b6 100644 (file)
@@ -37,31 +37,32 @@ int gt_global_help(void *data)
 
 static inline const Command *gt_get_command_root_children(const Command *cmd)
 {
-       static Command commands[] =
-       {
-       { "udc", NEXT, udc_parse, NULL, udc_help_func },
-       { "settings", NEXT, command_parse, gt_settings_get_children, gt_settings_help },
-       { "config", NEXT, command_parse, gt_config_get_children, gt_config_help },
-       { "func", NEXT, command_parse, gt_func_get_children, gt_func_help },
-       { NULL, AGAIN, command_parse, get_gadget_children, gt_global_help },
-       { NULL, AGAIN, NULL, NULL, NULL } };
+       static Command commands[] = {
+               { "udc", NEXT, udc_parse, NULL, udc_help_func },
+               { "settings", NEXT, command_parse, gt_settings_get_children, gt_settings_help },
+               { "config", NEXT, command_parse, gt_config_get_children, gt_config_help },
+               { "func", NEXT, command_parse, gt_func_get_children, gt_func_help },
+               { NULL, AGAIN, command_parse, get_gadget_children, gt_global_help },
+               { NULL, AGAIN, NULL, NULL, NULL }
+       };
 
        return commands;
 }
 
 static inline const Command *gt_get_command_root(const Command *cmd)
 {
-       static Command tool_names[] =
-       {
-       { NULL, NEXT, command_parse, gt_get_command_root_children, gt_global_help },
-       { NULL, AGAIN, NULL, NULL, NULL } };
+       static Command tool_names[] = {
+               { NULL, NEXT, command_parse, gt_get_command_root_children, gt_global_help },
+               { NULL, AGAIN, NULL, NULL, NULL }
+       };
        return tool_names;
 }
 
 void gt_parse_commands(int argc, const char **argv, ExecutableCommand *exec)
 {
-       static Command command_pre_root =
-       { NULL, AGAIN, command_parse, gt_get_command_root, gt_global_help };
+       static Command command_pre_root = {
+               NULL, AGAIN, command_parse, gt_get_command_root, gt_global_help
+       };
 
        command_pre_root.parse(&command_pre_root, argc, argv, exec, NULL);
 }
index c60481d..52cebac 100644 (file)
@@ -33,11 +33,10 @@ int udc_help_func(void *data)
 void udc_parse(const Command *cmd, int argc, const char **argv,
                ExecutableCommand *exec, void * data)
 {
-       if(argc == 0) {
-               // udc should be run run without args
+       if(argc == 0)
+               // udc should be run without args
                executable_command_set(exec, udc_func, data, NULL);
-       } else {
+       else
                // Wrong syntax for udc command, let's print help
                executable_command_set(exec, cmd->printHelp, data, NULL);
-       }
 }