Code Review
/
vpp.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
vppinfra: fix vppinfra test code build
[vpp.git]
/
src
/
vppinfra
/
format.c
diff --git
a/src/vppinfra/format.c
b/src/vppinfra/format.c
index
999b093
..
cb6cb45
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
{
@@
-138,13
+139,13
@@
justify (u8 * s, format_info_t * fi, uword s_len_orig)
if (n_left > 0)
{
vec_insert (s, n_left, i0);
if (n_left > 0)
{
vec_insert (s, n_left, i0);
- memset (s + i0, fi->pad_char, n_left);
+
clib_
memset (s + i0, fi->pad_char, n_left);
l1 = vec_len (s);
}
if (n_right > 0)
{
vec_resize (s, n_right);
l1 = vec_len (s);
}
if (n_right > 0)
{
vec_resize (s, n_right);
- memset (s + l1, fi->pad_char, n_right);
+
clib_
memset (s + l1, fi->pad_char, n_right);
}
}
return s;
}
}
return s;
@@
-411,6
+412,11
@@
va_format (u8 * s, const char *fmt, va_list * va)
if (f > g)
vec_add (s, g, f - g);
if (f > g)
vec_add (s, g, f - g);
+#ifdef __COVERITY__
+ if (s == 0)
+ return (u8 *) "liar liar pants on fire s can't be zero!";
+#endif
+
return s;
}
return s;
}
@@
-421,6
+427,10
@@
format (u8 * s, const char *fmt, ...)
va_start (va, fmt);
s = va_format (s, fmt, &va);
va_end (va);
va_start (va, fmt);
s = va_format (s, fmt, &va);
va_end (va);
+#ifdef __COVERITY__
+ if (s == 0)
+ return (u8 *) "liar liar pants on fire s can't be zero!";
+#endif
return s;
}
return s;
}
@@
-462,6
+472,17
@@
fformat (FILE * f, char *fmt, ...)
}
#ifdef CLIB_UNIX
}
#ifdef CLIB_UNIX
+void
+fformat_append_cr (FILE * ofp, const char *fmt, ...)
+{
+ va_list va;
+
+ va_start (va, fmt);
+ (void) va_fformat (ofp, (char *) fmt, &va);
+ va_end (va);
+ fformat (ofp, "\n");
+}
+
word
fdformat (int fd, char *fmt, ...)
{
word
fdformat (int fd, char *fmt, ...)
{
@@
-708,8
+729,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);