]> git.ipfire.org Git - thirdparty/lldpd.git/commitdiff
lib: fix parsing of "11542."
authorVincent Bernat <bernat@luffy.cx>
Wed, 24 Jul 2013 22:39:39 +0000 (00:39 +0200)
committerVincent Bernat <bernat@luffy.cx>
Wed, 24 Jul 2013 22:39:39 +0000 (00:39 +0200)
The case was correctly handled but clz() does not handle 0 as its
argument.

src/lib/fixedpoint.c

index 5588b8f4a1d92a289f0ad015956db3a620884e75..7c99eef9f456af0e058e75f0310f5740c4f1fc97 100644 (file)
@@ -76,8 +76,8 @@ fp_strtofp(const char *repr, char **end,
                while (e2++ != endptr) precision *= 10;
                result.fraction.value <<= fltbits;
                result.fraction.value /= precision;
-               result.fraction.precision = sizeof(precision) * 8 -
-                   __builtin_clzll(precision - 1);
+               result.fraction.precision = (precision == 1)?1:
+                   (sizeof(precision) * 8 - __builtin_clzll(precision - 1));
                if (result.fraction.precision > fltbits)
                        result.fraction.precision = fltbits;
        }