From 3dd6424f34706f1bc62fd9b80c09f067b26e99bc Mon Sep 17 00:00:00 2001 From: borisbstyle Date: Sat, 30 Apr 2016 12:54:15 +0200 Subject: [PATCH] Revert "Fixed a bug which caused printing of floats larger than 100 in the CLI to crash" This reverts commit 6ce8fe3c0fa7725e77d6ea61557bcec65d6cdb34. --- src/main/common/typeconversion.c | 5 ----- src/main/common/typeconversion.h | 10 ---------- src/main/io/serial_cli.c | 2 +- 3 files changed, 1 insertion(+), 16 deletions(-) diff --git a/src/main/common/typeconversion.c b/src/main/common/typeconversion.c index 3a3730fd56..4e3f8b4c2e 100644 --- a/src/main/common/typeconversion.c +++ b/src/main/common/typeconversion.c @@ -144,11 +144,6 @@ char *itoa(int i, char *a, int base) #endif -/* Note: the floatString must be at least 13 bytes long to cover all cases. - * This includes up to 10 digits (32 bit ints can hold numbers up to 10 - * digits long) + the decimal point + negative sign or space + null - * terminator. - */ char *ftoa(float x, char *floatString) { int32_t value; diff --git a/src/main/common/typeconversion.h b/src/main/common/typeconversion.h index f2811d65ba..62b437875b 100644 --- a/src/main/common/typeconversion.h +++ b/src/main/common/typeconversion.h @@ -21,17 +21,7 @@ void li2a(long num, char *bf); void ui2a(unsigned int num, unsigned int base, int uc, char *bf); void i2a(int num, char *bf); char a2i(char ch, const char **src, int base, int *nump); - -/* Simple conversion of a float to a string. Will display completely - * inaccurate results for floats larger than about 2.15E6 (2^31 / 1000) - * (same thing for negative values < -2.15E6). - * Will always display 3 decimals, so anything smaller than 1E-3 will - * not be displayed. - * The floatString will be filled in with the result and will be - * returned. It must be at least 13 bytes in length to cover all cases! - */ char *ftoa(float x, char *floatString); - float fastA2F(const char *p); #ifndef HAVE_ITOA_FUNCTION diff --git a/src/main/io/serial_cli.c b/src/main/io/serial_cli.c index 2f837ed9ef..d3a7e79c20 100644 --- a/src/main/io/serial_cli.c +++ b/src/main/io/serial_cli.c @@ -2448,7 +2448,7 @@ static void cliWrite(uint8_t ch) static void cliPrintVar(const clivalue_t *var, uint32_t full) { int32_t value = 0; - char buf[13]; + char buf[8]; void *ptr = var->ptr; if ((var->type & VALUE_SECTION_MASK) == PROFILE_VALUE) {