Commit Graph

11 Commits

Author SHA1 Message Date
Donald Sharp
d9dfbab71c lib: va_end must be called
According to the man page a va_start must be followed by
a va_end before the end of the function.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-05-22 10:52:54 -04:00
David Lamparter
47a3a82770 *: manual SPDX License ID conversions
The files converted in this commit either had some random misspelling or
formatting weirdness that made them escape automated replacement, or
have a particularly "weird" licensing setup (e.g. dual-licensed.)

This also marks a bunch of "public domain" files as SPDX License "NONE".

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2023-02-09 14:09:07 +01:00
David Lamparter
c84e518709 *: no-warn pragmas for non-const format strings
We do use non-constant/literal format strings in a few places for more
or less valid reasons;  put `ignored "-Wformat-nonliteral"` around those
so we can have the warning enabled for everywhere else.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2023-01-27 12:01:20 +01:00
David Lamparter
54929fd38a *: use semicolon after printfrr_ext_autoreg_{p,d}
Mostly to make clang-format not format these to peak ugly.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2022-01-14 13:33:57 +01:00
David Lamparter
bb12115e0b lib: add %pFB extension to print struct fbuf *
Useful to insert output from another bprintfrr() call.

Signed-off-by: David Lamparter <equinox@diac24.net>
2021-03-30 22:32:59 +02:00
David Lamparter
9c4380daee lib: add %pVA recursive printfrr
Analogous to Linux kernel `%pV` (but our mechanism expects 2 specifier
chars and `%pVA` is clearer anyway.)

Signed-off-by: David Lamparter <equinox@diac24.net>
2021-03-30 22:32:59 +02:00
David Lamparter
3ea7943059 lib: put printfrr extension args into struct
... for easier extensibility.  Add width, # and - flags while at it.

Signed-off-by: David Lamparter <equinox@diac24.net>
2021-03-30 22:32:55 +02:00
David Lamparter
212e04e5a7 lib: rework printfrr extensions to output directly
Allowing printfrr extensions to directly write to the output buffer has
a few advantages:
- there is no arbitrary length limit imposed (previously 64)
- the output doesn't need to be copied another time
- the extension can directly use bprintfrr() to put together pieces

The downside is that the theoretical length (regardless of available
buffer space) must be computed correctly.

Extended unit tests to test these paths a bit more thoroughly.

Signed-off-by: David Lamparter <equinox@diac24.net>
2021-03-27 16:56:55 +01:00
Donald Sharp
adc62ec8b7 lib: va_copy must have a va_end to free memory
All va_copy() calls must have a va_end() call.
Caught by Coverity

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-10-25 07:01:59 -04:00
David Lamparter
bf4d3d8021 lib/printf: add extension support
Inspired by the Linux kernel, this allows us to do %pI4 and similar
things.

Signed-off-by: David Lamparter <equinox@diac24.net>
2019-06-03 16:45:01 +02:00
David Lamparter
5c25bd87b5 lib/printf: integrate
Signed-off-by: David Lamparter <equinox@diac24.net>
2019-06-03 16:44:51 +02:00