Fix style issues in config-parser.c
This commit is contained in:
parent
8ac1d52240
commit
299f6d1e10
@ -37,7 +37,8 @@
|
||||
* If the pointer is invalid, the function using this macro will return with
|
||||
* CONFIG_PARSER_PARAM_ERR
|
||||
*/
|
||||
#define config_parser_check_handle(handle) do { if (!(handle) || \
|
||||
#define config_parser_check_handle(handle) do { \
|
||||
if (!(handle) || \
|
||||
((struct config_parser *)(handle))->magic != CONFIG_PARSER_MAGIC) \
|
||||
return CONFIG_PARSER_PARAM_ERR; \
|
||||
} while (0)
|
||||
@ -92,17 +93,17 @@ static int parse_value(struct config_parser_entry *entry, char *value_start_toke
|
||||
if (value_start_token[0] != '-') {
|
||||
/* Try parsing as ul */
|
||||
entry->value.uint_val = strtoul(value_start_token, &endptr, 0);
|
||||
if (endptr == value_start_token) {
|
||||
if (endptr == value_start_token)
|
||||
return -1;
|
||||
}
|
||||
|
||||
entry->type = CONFIG_PARSER_TYPE_UINT;
|
||||
goto exit;
|
||||
} else {
|
||||
/* Try parsing as int */
|
||||
entry->value.int_val = strtod(value_start_token, &endptr);
|
||||
if (endptr == value_start_token) {
|
||||
if (endptr == value_start_token)
|
||||
return -1;
|
||||
}
|
||||
|
||||
entry->type = CONFIG_PARSER_TYPE_INT;
|
||||
}
|
||||
|
||||
@ -110,14 +111,16 @@ exit:
|
||||
return 0;
|
||||
}
|
||||
|
||||
enum config_parser_ret config_parser_get_line(config_parser_handle_t handle, struct config_parser_entry *entry, bool force_float)
|
||||
enum config_parser_ret config_parser_get_line(config_parser_handle_t handle, struct config_parser_entry *entry,
|
||||
bool force_float)
|
||||
{
|
||||
struct config_parser *p;
|
||||
config_parser_check_handle(handle);
|
||||
p = CONFIG_PARSER(handle);
|
||||
char *token;
|
||||
int token_round = 0;
|
||||
|
||||
config_parser_check_handle(handle);
|
||||
p = CONFIG_PARSER(handle);
|
||||
|
||||
if (!entry)
|
||||
return CONFIG_PARSER_PARAM_ERR;
|
||||
|
||||
@ -131,7 +134,6 @@ enum config_parser_ret config_parser_get_line(config_parser_handle_t handle, str
|
||||
if (token[0] == '#') {
|
||||
if (token_round == 0)
|
||||
return CONFIG_PARSER_LINE_COMMENT;
|
||||
else
|
||||
break;
|
||||
}
|
||||
|
||||
@ -140,9 +142,8 @@ enum config_parser_ret config_parser_get_line(config_parser_handle_t handle, str
|
||||
entry->name = token;
|
||||
break;
|
||||
case 1: /* = Symbol */
|
||||
if (strcmp(token, "=")) {
|
||||
if (strcmp(token, "="))
|
||||
return CONFIG_PARSER_LINE_MALFORM;
|
||||
}
|
||||
break;
|
||||
case 2: /* VALUE */
|
||||
if (parse_value(entry, token))
|
||||
@ -172,6 +173,7 @@ enum config_parser_ret config_parser_reset_to_start(config_parser_handle_t handl
|
||||
{
|
||||
FRESULT res;
|
||||
struct config_parser *p;
|
||||
|
||||
config_parser_check_handle(handle);
|
||||
p = CONFIG_PARSER(handle);
|
||||
|
||||
@ -194,6 +196,7 @@ enum config_parser_ret config_parser_close_file(config_parser_handle_t handle)
|
||||
{
|
||||
struct config_parser *p;
|
||||
FRESULT res;
|
||||
|
||||
config_parser_check_handle(handle);
|
||||
p = CONFIG_PARSER(handle);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user