summaryrefslogtreecommitdiff
path: root/py/pfenv.c
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2015-01-16 17:47:07 +0000
committerDamien George <damien.p.george@gmail.com>2015-01-16 17:47:07 +0000
commit963a5a3e82ded7ee75adae72ae7cb14796fa150e (patch)
tree78402c85b98c1c8f1889d7af7dc6f4828a8f55a5 /py/pfenv.c
parentf12ea7c7ed1ef97ee48c4356dbbc808cc2bdee4a (diff)
py, unix: Allow to compile with -Wsign-compare.
See issue #699.
Diffstat (limited to 'py/pfenv.c')
-rw-r--r--py/pfenv.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/py/pfenv.c b/py/pfenv.c
index 698f3b16c..f608a1175 100644
--- a/py/pfenv.c
+++ b/py/pfenv.c
@@ -341,12 +341,15 @@ int pfenv_print_float(const pfenv_t *pfenv, mp_float_t f, char fmt, int flags, c
*fmt_s = '\0';
len = snprintf(buf, sizeof(buf), fmt_buf, prec, f);
+ if (len < 0) {
+ len = 0;
+ }
#else
#error Unknown MICROPY FLOAT IMPL
#endif
char *s = buf;
- if ((flags & PF_FLAG_ADD_PERCENT) && (len + 1) < sizeof(buf)) {
+ if ((flags & PF_FLAG_ADD_PERCENT) && (size_t)(len + 1) < sizeof(buf)) {
buf[len++] = '%';
buf[len] = '\0';
}