diff --git a/scenes/token_menu/totp_scene_token_menu.c b/scenes/token_menu/totp_scene_token_menu.c index c53d21e06de..22c37dc2c62 100644 --- a/scenes/token_menu/totp_scene_token_menu.c +++ b/scenes/token_menu/totp_scene_token_menu.c @@ -139,7 +139,8 @@ bool totp_scene_token_menu_handle_event(PluginEvent* const event, PluginState* p dialog_message_show(plugin_state->dialogs, message); dialog_message_free(message); if(dialog_result == DialogMessageButtonRight) { - ListNode* list_node = list_element_at(plugin_state->tokens_list, scene_state->current_token_index); + ListNode* list_node = list_element_at( + plugin_state->tokens_list, scene_state->current_token_index); TokenInfo* tokenInfo = list_node->data; token_info_free(tokenInfo); diff --git a/services/cli/cli.c b/services/cli/cli.c index c7d05488c83..0630b5de4a2 100644 --- a/services/cli/cli.c +++ b/services/cli/cli.c @@ -12,7 +12,9 @@ #define TOTP_CLI_COMMAND_HELP "help" static void totp_cli_print_unknown_command(FuriString* unknown_command) { - TOTP_CLI_PRINTF("Command \"%s\" is unknown. Use \"help\" command to get list of available commands.", furi_string_get_cstr(unknown_command)); + TOTP_CLI_PRINTF( + "Command \"%s\" is unknown. Use \"help\" command to get list of available commands.", + furi_string_get_cstr(unknown_command)); } static void totp_cli_print_help() { @@ -27,7 +29,7 @@ static void totp_cli_print_help() { } static void totp_cli_handler(Cli* cli, FuriString* args, void* context) { - PluginState* plugin_state = (PluginState* )context; + PluginState* plugin_state = (PluginState*)context; FuriString* cmd = furi_string_alloc(); @@ -52,7 +54,8 @@ static void totp_cli_handler(Cli* cli, FuriString* args, void* context) { void totp_cli_register_command_handler(PluginState* plugin_state) { Cli* cli = furi_record_open(RECORD_CLI); - cli_add_command(cli, TOTP_CLI_COMMAND_NAME, CliCommandFlagParallelSafe, totp_cli_handler, plugin_state); + cli_add_command( + cli, TOTP_CLI_COMMAND_NAME, CliCommandFlagParallelSafe, totp_cli_handler, plugin_state); furi_record_close(RECORD_CLI); } diff --git a/services/cli/cli_common_helpers.c b/services/cli/cli_common_helpers.c index 1282e458a5c..abfe70e8b94 100644 --- a/services/cli/cli_common_helpers.c +++ b/services/cli/cli_common_helpers.c @@ -2,21 +2,23 @@ #include void totp_cli_print_invalid_arguments() { - TOTP_CLI_PRINTF("Invalid command arguments. use \"help\" command to get list of available commands"); + TOTP_CLI_PRINTF( + "Invalid command arguments. use \"help\" command to get list of available commands"); } bool totp_cli_ensure_authenticated(PluginState* plugin_state, Cli* cli) { - if (plugin_state->current_scene == TotpSceneAuthentication) { + if(plugin_state->current_scene == TotpSceneAuthentication) { TOTP_CLI_PRINTF("Pleases enter PIN on your flipper device\r\n"); - - while (plugin_state->current_scene == TotpSceneAuthentication && !cli_cmd_interrupt_received(cli)) { + + while(plugin_state->current_scene == TotpSceneAuthentication && + !cli_cmd_interrupt_received(cli)) { furi_delay_tick(0); } TOTP_CLI_PRINTF("\033[A\33[2K\r"); fflush(stdout); - if (plugin_state->current_scene == TotpSceneAuthentication) { + if(plugin_state->current_scene == TotpSceneAuthentication) { return false; } } diff --git a/services/cli/cli_common_helpers.h b/services/cli/cli_common_helpers.h index ddf686da29c..aa36a626de6 100644 --- a/services/cli/cli_common_helpers.h +++ b/services/cli/cli_common_helpers.h @@ -7,10 +7,10 @@ #define TOTP_CLI_OPTIONAL_PARAM(param) "[" param "]" #define TOTP_CLI_OPTIONAL_PARAM_MARK "[OPTIONAL]" -#define TOTP_CLI_PRINTF(format, ...) \ - _Pragma(STRINGIFY(GCC diagnostic push)); \ +#define TOTP_CLI_PRINTF(format, ...) \ + _Pragma(STRINGIFY(GCC diagnostic push)); \ _Pragma(STRINGIFY(GCC diagnostic ignored "-Wdouble-promotion")); \ - printf(format, ##__VA_ARGS__); \ + printf(format, ##__VA_ARGS__); \ _Pragma(STRINGIFY(GCC diagnostic pop)); void totp_cli_print_invalid_arguments(); diff --git a/services/cli/commands/add/add.c b/services/cli/commands/add/add.c index 98e7d212691..ee85ba5cff0 100644 --- a/services/cli/commands/add/add.c +++ b/services/cli/commands/add/add.c @@ -31,13 +31,13 @@ static bool token_info_set_algo_from_str(TokenInfo* token_info, FuriString* str) if(furi_string_cmpi_str(str, TOTP_CONFIG_TOKEN_ALGO_SHA1_NAME) == 0) { token_info->algo = SHA1; return true; - } - + } + if(furi_string_cmpi_str(str, TOTP_CONFIG_TOKEN_ALGO_SHA256_NAME) == 0) { token_info->algo = SHA256; return true; - } - + } + if(furi_string_cmpi_str(str, TOTP_CONFIG_TOKEN_ALGO_SHA512_NAME) == 0) { token_info->algo = SHA512; return true; @@ -47,11 +47,21 @@ static bool token_info_set_algo_from_str(TokenInfo* token_info, FuriString* str) } void totp_cli_command_add_print_help() { - TOTP_CLI_PRINTF("\t" TOTP_CLI_COMMAND_ADD " " TOTP_CLI_ARG(TOTP_CLI_COMMAND_ADD_ARG_NAME) " " TOTP_CLI_OPTIONAL_PARAM(TOTP_CLI_COMMAND_ADD_ARG_ALGO_PREFIX " " TOTP_CLI_ARG(TOTP_CLI_COMMAND_ADD_ARG_ALGO)) " " TOTP_CLI_OPTIONAL_PARAM(TOTP_CLI_COMMAND_ADD_ARG_DIGITS_PREFIX " " TOTP_CLI_ARG(TOTP_CLI_COMMAND_ADD_ARG_DIGITS)) " " TOTP_CLI_OPTIONAL_PARAM(TOTP_CLI_COMMAND_ADD_ARG_UNSECURE_PREFIX) " - add new token\r\n"); + TOTP_CLI_PRINTF("\t" TOTP_CLI_COMMAND_ADD " " TOTP_CLI_ARG(TOTP_CLI_COMMAND_ADD_ARG_NAME) " " TOTP_CLI_OPTIONAL_PARAM( + TOTP_CLI_COMMAND_ADD_ARG_ALGO_PREFIX " " TOTP_CLI_ARG( + TOTP_CLI_COMMAND_ADD_ARG_ALGO)) " " TOTP_CLI_OPTIONAL_PARAM(TOTP_CLI_COMMAND_ADD_ARG_DIGITS_PREFIX + " " TOTP_CLI_ARG( + TOTP_CLI_COMMAND_ADD_ARG_DIGITS)) " " TOTP_CLI_OPTIONAL_PARAM(TOTP_CLI_COMMAND_ADD_ARG_UNSECURE_PREFIX) " - add new token\r\n"); TOTP_CLI_PRINTF("\t\t" TOTP_CLI_ARG(TOTP_CLI_COMMAND_ADD_ARG_NAME) " - token name\r\n"); - TOTP_CLI_PRINTF("\t\t" TOTP_CLI_ARG(TOTP_CLI_COMMAND_ADD_ARG_ALGO) " - " TOTP_CLI_OPTIONAL_PARAM_MARK " token hashing algorithm, could be one of: sha1, sha256, sha512; default: sha1\r\n"); - TOTP_CLI_PRINTF("\t\t" TOTP_CLI_ARG(TOTP_CLI_COMMAND_ADD_ARG_DIGITS) " - " TOTP_CLI_OPTIONAL_PARAM_MARK " number of digits to generate, one of: 6, 8; default: 6\r\n"); - TOTP_CLI_PRINTF("\t\t" TOTP_CLI_COMMAND_ADD_ARG_UNSECURE_PREFIX " - " TOTP_CLI_OPTIONAL_PARAM_MARK " to show console user input as-is without masking; default: show masked\r\n\r\n"); + TOTP_CLI_PRINTF("\t\t" TOTP_CLI_ARG( + TOTP_CLI_COMMAND_ADD_ARG_ALGO) " - " TOTP_CLI_OPTIONAL_PARAM_MARK + " token hashing algorithm, could be one of: sha1, sha256, sha512; default: sha1\r\n"); + TOTP_CLI_PRINTF("\t\t" TOTP_CLI_ARG( + TOTP_CLI_COMMAND_ADD_ARG_DIGITS) " - " TOTP_CLI_OPTIONAL_PARAM_MARK + " number of digits to generate, one of: 6, 8; default: 6\r\n"); + TOTP_CLI_PRINTF( + "\t\t" TOTP_CLI_COMMAND_ADD_ARG_UNSECURE_PREFIX " - " TOTP_CLI_OPTIONAL_PARAM_MARK + " to show console user input as-is without masking; default: show masked\r\n\r\n"); } void totp_cli_command_add_handle(PluginState* plugin_state, FuriString* args, Cli* cli) { @@ -61,7 +71,7 @@ void totp_cli_command_add_handle(PluginState* plugin_state, FuriString* args, Cl TokenInfo* token_info = token_info_alloc(); // Reading token name - if (!args_read_probably_quoted_string_and_trim(args, temp_str)) { + if(!args_read_probably_quoted_string_and_trim(args, temp_str)) { totp_cli_print_invalid_arguments(); furi_string_free(temp_str); token_info_free(token_info); @@ -74,30 +84,39 @@ void totp_cli_command_add_handle(PluginState* plugin_state, FuriString* args, Cl // Read optional arguments bool mask_user_input = true; - while (args_read_string_and_trim(args, temp_str)) { + while(args_read_string_and_trim(args, temp_str)) { bool parsed = false; - if (furi_string_cmpi_str(temp_str, TOTP_CLI_COMMAND_ADD_ARG_ALGO_PREFIX) == 0) { - if (!args_read_string_and_trim(args, temp_str)) { - TOTP_CLI_PRINTF("Missed value for argument \"" TOTP_CLI_COMMAND_ADD_ARG_ALGO_PREFIX "\"\r\n"); - } else if (!token_info_set_algo_from_str(token_info, temp_str)) { - TOTP_CLI_PRINTF("\"%s\" is incorrect value for argument \"" TOTP_CLI_COMMAND_ADD_ARG_ALGO_PREFIX "\"\r\n", furi_string_get_cstr(temp_str)); + if(furi_string_cmpi_str(temp_str, TOTP_CLI_COMMAND_ADD_ARG_ALGO_PREFIX) == 0) { + if(!args_read_string_and_trim(args, temp_str)) { + TOTP_CLI_PRINTF("Missed value for argument \"" TOTP_CLI_COMMAND_ADD_ARG_ALGO_PREFIX + "\"\r\n"); + } else if(!token_info_set_algo_from_str(token_info, temp_str)) { + TOTP_CLI_PRINTF( + "\"%s\" is incorrect value for argument \"" TOTP_CLI_COMMAND_ADD_ARG_ALGO_PREFIX + "\"\r\n", + furi_string_get_cstr(temp_str)); } else { parsed = true; } - } else if (furi_string_cmpi_str(temp_str, TOTP_CLI_COMMAND_ADD_ARG_DIGITS_PREFIX) == 0) { - if (!args_read_string_and_trim(args, temp_str)) { - TOTP_CLI_PRINTF("Missed value for argument \"" TOTP_CLI_COMMAND_ADD_ARG_DIGITS_PREFIX "\"\r\n"); - } else if (!token_info_set_digits_from_str(token_info, temp_str)) { - TOTP_CLI_PRINTF("\"%s\" is incorrect value for argument \"" TOTP_CLI_COMMAND_ADD_ARG_DIGITS_PREFIX "\"\r\n", furi_string_get_cstr(temp_str)); + } else if(furi_string_cmpi_str(temp_str, TOTP_CLI_COMMAND_ADD_ARG_DIGITS_PREFIX) == 0) { + if(!args_read_string_and_trim(args, temp_str)) { + TOTP_CLI_PRINTF( + "Missed value for argument \"" TOTP_CLI_COMMAND_ADD_ARG_DIGITS_PREFIX + "\"\r\n"); + } else if(!token_info_set_digits_from_str(token_info, temp_str)) { + TOTP_CLI_PRINTF( + "\"%s\" is incorrect value for argument \"" TOTP_CLI_COMMAND_ADD_ARG_DIGITS_PREFIX + "\"\r\n", + furi_string_get_cstr(temp_str)); } else { parsed = true; } - } else if (furi_string_cmpi_str(temp_str, TOTP_CLI_COMMAND_ADD_ARG_UNSECURE_PREFIX) == 0) { + } else if(furi_string_cmpi_str(temp_str, TOTP_CLI_COMMAND_ADD_ARG_UNSECURE_PREFIX) == 0) { mask_user_input = false; parsed = true; } - if (!parsed) { + if(!parsed) { totp_cli_print_invalid_arguments(); furi_string_free(temp_str); token_info_free(token_info); @@ -111,7 +130,7 @@ void totp_cli_command_add_handle(PluginState* plugin_state, FuriString* args, Cl uint8_t c; while(cli_read(cli, &c, 1) == 1) { - if (c == CliSymbolAsciiEsc) { + if(c == CliSymbolAsciiEsc) { uint8_t c2; cli_read_timeout(cli, &c2, 1, 0); cli_read_timeout(cli, &c2, 1, 0); @@ -121,22 +140,21 @@ void totp_cli_command_add_handle(PluginState* plugin_state, FuriString* args, Cl token_info_free(token_info); return; } else if((c >= '0' && c <= '9') || (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')) { - if (mask_user_input) { + if(mask_user_input) { putc('*', stdout); } else { putc(c, stdout); } fflush(stdout); furi_string_push_back(temp_str, c); - } else if (c == CliSymbolAsciiBackspace || c == CliSymbolAsciiDel) { + } else if(c == CliSymbolAsciiBackspace || c == CliSymbolAsciiDel) { size_t temp_str_size = furi_string_size(temp_str); - if (temp_str_size > 0) { + if(temp_str_size > 0) { TOTP_CLI_PRINTF("\b \b"); fflush(stdout); furi_string_left(temp_str, temp_str_size - 1); } - } - else if(c == CliSymbolAsciiCR) { + } else if(c == CliSymbolAsciiCR) { cli_nl(); break; } @@ -144,13 +162,13 @@ void totp_cli_command_add_handle(PluginState* plugin_state, FuriString* args, Cl temp_cstr = furi_string_get_cstr(temp_str); - if (!totp_cli_ensure_authenticated(plugin_state, cli)) { + if(!totp_cli_ensure_authenticated(plugin_state, cli)) { furi_string_free(temp_str); token_info_free(token_info); return; } - if (!token_info_set_secret(token_info, temp_cstr, strlen(temp_cstr), plugin_state->iv)) { + if(!token_info_set_secret(token_info, temp_cstr, strlen(temp_cstr), plugin_state->iv)) { TOTP_CLI_PRINTF("Token secret seems to be invalid and can not be parsed\r\n"); furi_string_free(temp_str); token_info_free(token_info); @@ -161,7 +179,7 @@ void totp_cli_command_add_handle(PluginState* plugin_state, FuriString* args, Cl furi_string_free(temp_str); bool load_generate_token_scene = false; - if (plugin_state->current_scene == TotpSceneGenerateToken) { + if(plugin_state->current_scene == TotpSceneGenerateToken) { totp_scene_director_activate_scene(plugin_state, TotpSceneNone, NULL); load_generate_token_scene = true; } @@ -174,7 +192,7 @@ void totp_cli_command_add_handle(PluginState* plugin_state, FuriString* args, Cl plugin_state->tokens_count++; totp_config_file_save_new_token(token_info); - if (load_generate_token_scene) { + if(load_generate_token_scene) { totp_scene_director_activate_scene(plugin_state, TotpSceneGenerateToken, NULL); } diff --git a/services/cli/commands/delete/delete.c b/services/cli/commands/delete/delete.c index 1c9a39f58f4..9bc18a66bb6 100644 --- a/services/cli/commands/delete/delete.c +++ b/services/cli/commands/delete/delete.c @@ -12,22 +12,29 @@ #define TOTP_CLI_COMMAND_DELETE_ARG_FORCE_SUFFIX "-f" void totp_cli_command_delete_print_help() { - TOTP_CLI_PRINTF("\t" TOTP_CLI_COMMAND_DELETE " " TOTP_CLI_ARG(TOTP_CLI_COMMAND_DELETE_ARG_INDEX) " " TOTP_CLI_OPTIONAL_PARAM(TOTP_CLI_COMMAND_DELETE_ARG_FORCE_SUFFIX) " - delete token\r\n"); - TOTP_CLI_PRINTF("\t\t" TOTP_CLI_ARG(TOTP_CLI_COMMAND_DELETE_ARG_INDEX) " - token index in the list\r\n"); - TOTP_CLI_PRINTF("\t\t" TOTP_CLI_COMMAND_DELETE_ARG_FORCE_SUFFIX " - " TOTP_CLI_OPTIONAL_PARAM_MARK " force command to do not ask user for interactive confirmation\r\n\r\n"); + TOTP_CLI_PRINTF( + "\t" TOTP_CLI_COMMAND_DELETE + " " TOTP_CLI_ARG(TOTP_CLI_COMMAND_DELETE_ARG_INDEX) " " TOTP_CLI_OPTIONAL_PARAM( + TOTP_CLI_COMMAND_DELETE_ARG_FORCE_SUFFIX) " - delete token\r\n"); + TOTP_CLI_PRINTF( + "\t\t" TOTP_CLI_ARG(TOTP_CLI_COMMAND_DELETE_ARG_INDEX) " - token index in the list\r\n"); + TOTP_CLI_PRINTF("\t\t" TOTP_CLI_COMMAND_DELETE_ARG_FORCE_SUFFIX + " - " TOTP_CLI_OPTIONAL_PARAM_MARK + " force command to do not ask user for interactive confirmation\r\n\r\n"); } void totp_cli_command_delete_handle(PluginState* plugin_state, FuriString* args, Cli* cli) { int token_number; - if (!args_read_int_and_trim(args, &token_number) || token_number <= 0 || token_number > plugin_state->tokens_count) { + if(!args_read_int_and_trim(args, &token_number) || token_number <= 0 || + token_number > plugin_state->tokens_count) { totp_cli_print_invalid_arguments(); return; } FuriString* temp_str = furi_string_alloc(); bool confirm_needed = true; - if (args_read_string_and_trim(args, temp_str)) { - if (furi_string_cmpi_str(temp_str, TOTP_CLI_COMMAND_DELETE_ARG_FORCE_SUFFIX) == 0) { + if(args_read_string_and_trim(args, temp_str)) { + if(furi_string_cmpi_str(temp_str, TOTP_CLI_COMMAND_DELETE_ARG_FORCE_SUFFIX) == 0) { confirm_needed = false; } else { TOTP_CLI_PRINTF("Unknown argument \"%s\"\r\n", furi_string_get_cstr(temp_str)); @@ -38,7 +45,7 @@ void totp_cli_command_delete_handle(PluginState* plugin_state, FuriString* args, } furi_string_free(temp_str); - if (!totp_cli_ensure_authenticated(plugin_state, cli)) { + if(!totp_cli_ensure_authenticated(plugin_state, cli)) { return; } @@ -47,40 +54,39 @@ void totp_cli_command_delete_handle(PluginState* plugin_state, FuriString* args, TokenInfo* token_info = list_node->data; bool confirmed = !confirm_needed; - if (confirm_needed) { + if(confirm_needed) { TOTP_CLI_PRINTF("WARNING!\r\n"); - TOTP_CLI_PRINTF("TOKEN \"%s\" WILL BE PERMANENTLY DELETED WITHOUT ABILITY TO RECOVER IT.\r\n", token_info->name); + TOTP_CLI_PRINTF( + "TOKEN \"%s\" WILL BE PERMANENTLY DELETED WITHOUT ABILITY TO RECOVER IT.\r\n", + token_info->name); TOTP_CLI_PRINTF("Confirm? [y/n]\r\n"); fflush(stdout); char user_pick; do { user_pick = tolower(cli_getc(cli)); - } while (user_pick != 'y' && - user_pick != 'n' && - user_pick != CliSymbolAsciiCR && - user_pick != CliSymbolAsciiETX && - user_pick != CliSymbolAsciiEsc); + } while(user_pick != 'y' && user_pick != 'n' && user_pick != CliSymbolAsciiCR && + user_pick != CliSymbolAsciiETX && user_pick != CliSymbolAsciiEsc); confirmed = user_pick == 'y' || user_pick == CliSymbolAsciiCR; } - if (confirmed) { - if (!totp_cli_ensure_authenticated(plugin_state, cli)) { + if(confirmed) { + if(!totp_cli_ensure_authenticated(plugin_state, cli)) { return; } bool activate_generate_token_scene = false; - if (plugin_state->current_scene != TotpSceneAuthentication) { + if(plugin_state->current_scene != TotpSceneAuthentication) { totp_scene_director_activate_scene(plugin_state, TotpSceneNone, NULL); activate_generate_token_scene = true; } - + plugin_state->tokens_list = list_remove(plugin_state->tokens_list, list_node); plugin_state->tokens_count--; totp_full_save_config_file(plugin_state); - - if (activate_generate_token_scene) { + + if(activate_generate_token_scene) { totp_scene_director_activate_scene(plugin_state, TotpSceneGenerateToken, NULL); } diff --git a/services/cli/commands/list/list.c b/services/cli/commands/list/list.c index 8938b426d37..cb6a0401ce5 100644 --- a/services/cli/commands/list/list.c +++ b/services/cli/commands/list/list.c @@ -34,11 +34,11 @@ void totp_cli_command_list_print_help() { } void totp_cli_command_list_handle(PluginState* plugin_state, Cli* cli) { - if (!totp_cli_ensure_authenticated(plugin_state, cli)) { + if(!totp_cli_ensure_authenticated(plugin_state, cli)) { return; } - if (plugin_state->tokens_list == NULL) { + if(plugin_state->tokens_list == NULL) { TOTP_CLI_PRINTF("There are no tokens"); return; } @@ -50,9 +50,14 @@ void totp_cli_command_list_handle(PluginState* plugin_state, Cli* cli) { TOTP_CLI_PRINTF("+-----+-----------------------------+--------+--------+\r\n"); uint16_t index = 1; while(node != NULL) { - TokenInfo* token_info = (TokenInfo* )node->data; + TokenInfo* token_info = (TokenInfo*)node->data; token_info_get_digits_count(token_info); - TOTP_CLI_PRINTF("| %-3" PRIu16 " | %-27.27s | %-6s | %-6" PRIu8 " |\r\n", index, token_info->name, get_algo_as_cstr(token_info->algo), get_digits_as_int(token_info->digits)); + TOTP_CLI_PRINTF( + "| %-3" PRIu16 " | %-27.27s | %-6s | %-6" PRIu8 " |\r\n", + index, + token_info->name, + get_algo_as_cstr(token_info->algo), + get_digits_as_int(token_info->digits)); node = node->next; index++; } diff --git a/services/cli/commands/timezone/timezone.c b/services/cli/commands/timezone/timezone.c index b7154bbd35d..9534f0eab5f 100644 --- a/services/cli/commands/timezone/timezone.c +++ b/services/cli/commands/timezone/timezone.c @@ -7,26 +7,29 @@ #define TOTP_CLI_COMMAND_TIMEZONE_ARG_TIMEZONE "TIMEZONE" void totp_cli_command_timezone_print_help() { - TOTP_CLI_PRINTF("\t" TOTP_CLI_COMMAND_TIMEZONE " " TOTP_CLI_OPTIONAL_PARAM(TOTP_CLI_ARG(TOTP_CLI_COMMAND_TIMEZONE_ARG_TIMEZONE)) "\r\n"); - TOTP_CLI_PRINTF("\t\t" TOTP_CLI_ARG(TOTP_CLI_COMMAND_TIMEZONE_ARG_TIMEZONE) " - " TOTP_CLI_OPTIONAL_PARAM_MARK " timezone offset in hours to be set, if not provided then current timezone offset will be printed\r\n\r\n"); + TOTP_CLI_PRINTF("\t" TOTP_CLI_COMMAND_TIMEZONE " " TOTP_CLI_OPTIONAL_PARAM( + TOTP_CLI_ARG(TOTP_CLI_COMMAND_TIMEZONE_ARG_TIMEZONE)) "\r\n"); + TOTP_CLI_PRINTF("\t\t" TOTP_CLI_ARG( + TOTP_CLI_COMMAND_TIMEZONE_ARG_TIMEZONE) " - " TOTP_CLI_OPTIONAL_PARAM_MARK + " timezone offset in hours to be set, if not provided then current timezone offset will be printed\r\n\r\n"); } void totp_cli_command_timezone_handle(PluginState* plugin_state, FuriString* args, Cli* cli) { - if (!totp_cli_ensure_authenticated(plugin_state, cli)) { + if(!totp_cli_ensure_authenticated(plugin_state, cli)) { return; } FuriString* temp_str = furi_string_alloc(); - if (args_read_string_and_trim(args, temp_str)) { + if(args_read_string_and_trim(args, temp_str)) { float tz = strtof(furi_string_get_cstr(temp_str), NULL); - if (tz >= -12.75f && tz <= 12.75f) { + if(tz >= -12.75f && tz <= 12.75f) { plugin_state->timezone_offset = tz; totp_config_file_update_timezone_offset(tz); TOTP_CLI_PRINTF("Timezone is set to %f\r\n", tz); - if (plugin_state->current_scene == TotpSceneGenerateToken) { + if(plugin_state->current_scene == TotpSceneGenerateToken) { totp_scene_director_activate_scene(plugin_state, TotpSceneNone, NULL); totp_scene_director_activate_scene(plugin_state, TotpSceneGenerateToken, NULL); - } else if (plugin_state->current_scene == TotpSceneAppSettings) { + } else if(plugin_state->current_scene == TotpSceneAppSettings) { totp_scene_director_activate_scene(plugin_state, TotpSceneNone, NULL); totp_scene_director_activate_scene(plugin_state, TotpSceneAppSettings, NULL); } diff --git a/services/list/list.c b/services/list/list.c index 408ceff22c9..3a33179805d 100644 --- a/services/list/list.c +++ b/services/list/list.c @@ -44,7 +44,7 @@ ListNode* list_element_at(ListNode* head, uint16_t index) { } ListNode* list_remove(ListNode* head, ListNode* ep) { - if (head == NULL) { + if(head == NULL) { return NULL; }