From: Krzysztof Opasiak Date: Tue, 29 Jul 2014 11:37:06 +0000 (+0200) Subject: gt: Addjust coding style to be more kernel-like X-Git-Tag: accepted/tizen/3.0/common/20161114.110810~121 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=dec204f84c624747acc53f944919eef45d405f7f;p=platform%2Fupstream%2Fgt.git gt: Addjust coding style to be more kernel-like Change-Id: I034c485bd4fc58079e40f6e673a92b6bf30b052a Signed-off-by: Krzysztof Opasiak --- diff --git a/source/base/src/command.c b/source/base/src/command.c index 4d0162c..456e0c3 100644 --- a/source/base/src/command.c +++ b/source/base/src/command.c @@ -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); - } } diff --git a/source/base/src/executable_command.c b/source/base/src/executable_command.c index f79222f..3e80d41 100644 --- a/source/base/src/executable_command.c +++ b/source/base/src/executable_command.c @@ -24,10 +24,9 @@ #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; diff --git a/source/base/src/parser.c b/source/base/src/parser.c index 6b1cd99..41f57b6 100644 --- a/source/base/src/parser.c +++ b/source/base/src/parser.c @@ -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); } diff --git a/source/udc/src/udc.c b/source/udc/src/udc.c index c60481d..52cebac 100644 --- a/source/udc/src/udc.c +++ b/source/udc/src/udc.c @@ -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); - } }