Skip to content

Commit bf3952d

Browse files
committed
Code cleanup
1 parent 749fbf4 commit bf3952d

File tree

5 files changed

+10
-9
lines changed

5 files changed

+10
-9
lines changed

.ofwcatalog/CHANGELOG.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Changelog
22

3-
## [v2.2.3](https://github.com/akopachov/flipper-zero_authenticator/releases/tag/v2.2.3) - 19 Jun 2023
3+
## [v2.2.3](https://github.com/akopachov/flipper-zero_authenticator/releases/tag/v2.2.3) - 10 Jul 2023
44

55
* Refactoring [#162](https://github.com/akopachov/flipper-zero_authenticator/issues/158)
66
* Updated repo to match [OFW catalog](https://github.com/flipperdevices/flipper-application-catalog/) requirements

cli/cli_helpers.h

+1-4
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,7 @@ extern const char* TOTP_CLI_COLOR_INFO;
2222
#define TOTP_CLI_PRINTF(format, ...) printf(format, ##__VA_ARGS__)
2323

2424
#define TOTP_CLI_PRINTF_COLORFUL(color, format, ...) \
25-
printf("\e[%s", color); \
26-
printf(format, ##__VA_ARGS__); \
27-
printf("\e[0m"); \
28-
fflush(stdout)
25+
TOTP_CLI_PRINTF("\e[%s" format "\e[0m", color, ##__VA_ARGS__)
2926

3027
#define TOTP_CLI_PRINTF_ERROR(format, ...) \
3128
TOTP_CLI_PRINTF_COLORFUL(TOTP_CLI_COLOR_ERROR, format, ##__VA_ARGS__)

cli/commands/add/add.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ void totp_cli_command_add_docopt_options() {
110110
TOTP_CLI_PRINTF(" " DOCOPT_OPTION(
111111
TOTP_CLI_COMMAND_ARG_DIGITS_PREFIX,
112112
DOCOPT_ARGUMENT(
113-
TOTP_CLI_COMMAND_ARG_DIGITS)) " Number of digits to generate, one of: 5, 6, 8 " DOCOPT_DEFAULT("6") "\r\n");
113+
TOTP_CLI_COMMAND_ARG_DIGITS)) " Number of digits to generate, one of: %" PRIu8 ", %" PRIu8 ", %" PRIu8 " " DOCOPT_DEFAULT("%" PRIu8) "\r\n", TotpFiveDigitsCount, TotpSixDigitsCount, TotpEightDigitsCount, TotpSixDigitsCount);
114114

115115
TOTP_CLI_PRINTF(" " DOCOPT_OPTION(
116116
TOTP_CLI_COMMAND_ARG_SECRET_ENCODING_PREFIX,
@@ -123,7 +123,7 @@ void totp_cli_command_add_docopt_options() {
123123
TOTP_CLI_PRINTF(" " DOCOPT_OPTION(
124124
TOTP_CLI_COMMAND_ARG_DURATION_PREFIX,
125125
DOCOPT_ARGUMENT(
126-
TOTP_CLI_COMMAND_ARG_DURATION)) " Token lifetime duration in seconds, between: 15 and 255 " DOCOPT_DEFAULT("30") "\r\n");
126+
TOTP_CLI_COMMAND_ARG_DURATION)) " Token lifetime duration in seconds, between: %" PRIu8 " and %" PRIu8 " " DOCOPT_DEFAULT("%" PRIu8) "\r\n", TOTP_TOKEN_DURATION_MIN, TOTP_TOKEN_DURATION_MAX, TOTP_TOKEN_DURATION_DEFAULT);
127127
TOTP_CLI_PRINTF(" " DOCOPT_SWITCH(
128128
TOTP_CLI_COMMAND_ARG_UNSECURE_PREFIX) " Show console user input as-is without masking\r\n");
129129
TOTP_CLI_PRINTF(" " DOCOPT_OPTION(

types/token_info.c

+4-1
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,13 @@ bool token_info_set_digits_from_int(TokenInfo* token_info, uint8_t digits) {
8585
}
8686

8787
bool token_info_set_duration_from_int(TokenInfo* token_info, uint8_t duration) {
88-
if(duration >= 15) {
88+
#pragma GCC diagnostic push
89+
#pragma GCC diagnostic ignored "-Wtype-limits"
90+
if(duration >= TOTP_TOKEN_DURATION_MIN && duration <= TOTP_TOKEN_DURATION_MAX) {
8991
token_info->duration = duration;
9092
return true;
9193
}
94+
#pragma GCC diagnostic pop
9295

9396
return false;
9497
}

types/token_info.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,13 @@
55
#include <furi/core/string.h>
66

77
#define TOTP_TOKEN_DURATION_DEFAULT (30)
8+
#define TOTP_TOKEN_DURATION_MIN (15)
9+
#define TOTP_TOKEN_DURATION_MAX UINT8_MAX
810

911
#define TOTP_TOKEN_ALGO_SHA1_NAME "sha1"
1012
#define TOTP_TOKEN_ALGO_STEAM_NAME "steam"
1113
#define TOTP_TOKEN_ALGO_SHA256_NAME "sha256"
1214
#define TOTP_TOKEN_ALGO_SHA512_NAME "sha512"
13-
#define TOTP_TOKEN_MAX_LENGTH (255)
1415

1516
#define PLAIN_TOKEN_ENCODING_BASE32_NAME "base32"
1617
#define PLAIN_TOKEN_ENCODING_BASE64_NAME "base64"

0 commit comments

Comments
 (0)