Code Review
/
vpp.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
VPP-1032: fix coverity warnings
[vpp.git]
/
src
/
vppinfra
/
format.c
diff --git
a/src/vppinfra/format.c
b/src/vppinfra/format.c
index
78e52e9
..
70292c0
100644
(file)
--- a/
src/vppinfra/format.c
+++ b/
src/vppinfra/format.c
@@
-62,6
+62,7
@@
#include <vppinfra/error.h>
#include <vppinfra/string.h>
#include <vppinfra/os.h> /* os_puts */
#include <vppinfra/error.h>
#include <vppinfra/string.h>
#include <vppinfra/os.h> /* os_puts */
+#include <vppinfra/math.h>
typedef struct
{
typedef struct
{
@@
-150,13
+151,13
@@
justify (u8 * s, format_info_t * fi, uword s_len_orig)
return s;
}
return s;
}
-static u8 *
-do_percent (u8 ** _s, u8 * fmt, va_list * va)
+static
const
u8 *
+do_percent (u8 ** _s,
const
u8 * fmt, va_list * va)
{
u8 *s = *_s;
uword c;
{
u8 *s = *_s;
uword c;
- u8 *f = fmt;
+
const
u8 *f = fmt;
format_info_t fi = {
.justify = '+',
format_info_t fi = {
.justify = '+',
@@
-385,7
+386,7
@@
done:
u8 *
va_format (u8 * s, const char *fmt, va_list * va)
{
u8 *
va_format (u8 * s, const char *fmt, va_list * va)
{
- u8 *f = (u8 *) fmt, *g;
+
const
u8 *f = (u8 *) fmt, *g;
u8 c;
g = f;
u8 c;
g = f;
@@
-708,8
+709,12
@@
format_float (u8 * s, f64 x, uword n_fraction_digits, uword output_style)
sign = 1;
}
sign = 1;
}
+ /* Check for not-a-number. */
+ if (isnan (x))
+ return format (s, "%cNaN", sign ? '-' : '+');
+
/* Check for infinity. */
/* Check for infinity. */
- if (
x == x / 2
)
+ if (
isinf (x)
)
return format (s, "%cinfinity", sign ? '-' : '+');
x = normalize (x, &expon, &prec);
return format (s, "%cinfinity", sign ? '-' : '+');
x = normalize (x, &expon, &prec);