Skip to content

Commit

Permalink
sys/config: Fix floating point support
Browse files Browse the repository at this point in the history
When CONFIG_FLOAT_SUPPORT was added ony conf_value_from_str()
was changed, not also conf_str_from_value() has conditional
compilation code.

Signed-off-by: Jerzy Kasenberg <jerzy.kasenberg@codecoup.pl>
  • Loading branch information
kasjer committed May 7, 2024
1 parent 6066004 commit 4552586
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions sys/config/src/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,9 @@ conf_str_from_value(enum conf_type type, void *vp, char *buf, int buf_len)
{
int64_t val;
uint64_t uval;
#if MYNEWT_VAL(CONFIG_FLOAT_SUPPORT)
float fval;
#endif

if (type == CONF_STRING) {
return vp;
Expand Down Expand Up @@ -309,10 +311,12 @@ conf_str_from_value(enum conf_type type, void *vp, char *buf, int buf_len)
}
snprintf(buf, buf_len, "%" PRIu64, uval);
return buf;
#if MYNEWT_VAL(CONFIG_FLOAT_SUPPORT)
case CONF_FLOAT:
fval = *(float *)vp;
snprintf(buf, buf_len, "%f", fval);
return buf;
#endif
default:
return NULL;
}
Expand Down

0 comments on commit 4552586

Please sign in to comment.