summaryrefslogtreecommitdiff
path: root/lib/printf
AgeCommit message (Collapse)Author
2022-01-14*: use semicolon after printfrr_ext_autoreg_{p,d}David Lamparter
Mostly to make clang-format not format these to peak ugly. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2021-03-31Merge pull request #8350 from opensourcerouting/printfrr-revampMark Stapp
lib: `printfrr()` care package
2021-03-30lib: add `%pFB` extension to print struct fbuf *David Lamparter
Useful to insert output from another bprintfrr() call. Signed-off-by: David Lamparter <equinox@diac24.net>
2021-03-30lib: add `%pVA` recursive printfrrDavid Lamparter
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-30lib: allow discerning unspec width in printfrr extDavid Lamparter
With 0 currently the default value for the width specifier, it's not possible to discern that from a %*p where 0 was passed as the length parameter. Use -1 to allow for that. Signed-off-by: David Lamparter <equinox@diac24.net>
2021-03-30lib: put printfrr extension args into structDavid Lamparter
... for easier extensibility. Add width, # and - flags while at it. Signed-off-by: David Lamparter <equinox@diac24.net>
2021-03-27lib: record output positions in printfrrDavid Lamparter
This replaces `%n` with a safe, out-of-band option that simply records the start and end offset of the output produced for each `%...` specifier. The old `%n` code is removed. Signed-off-by: David Lamparter <equinox@diac24.net>
2021-03-27lib: rework printfrr extensions to output directlyDavid Lamparter
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-23lib: enlarge the local buffer for printfrr extension tokensMark Stapp
Make the local buffer offered to printfrr extension tokens bigger; existing size wasn't quite enough for some of the more elaborate struct prefix types. Signed-off-by: Mark Stapp <mjs@voltanet.io>
2021-02-01lib/printf: disable `%n` specifierDavid Lamparter
We don't use `%n` anywhere, so the only purpose it serves is enabling exploits. (I thought about this initially when adding printfrr, but I wasn't sure we don't use `%n` anywhere, and thought I'll check later, and then just forgot it...) Signed-off-by: David Lamparter <equinox@diac24.net>
2020-03-08*: Replace `sizeof something` to sizeof(something)Donatas Abraitis
Satisfy checkpatch.pl requirements (check for sizeof without parenthesis) Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-02-09*: Remove parenthesis on return for constantsDonatas Abraitis
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2019-10-25lib: va_copy must have a va_end to free memoryDonald Sharp
All va_copy() calls must have a va_end() call. Caught by Coverity Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-09-30*: strip trailing whitespaceQuentin Young
Some of it has snuck by CI Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2019-06-07lib: Include proper headerDonald Sharp
bcopy is being used in the new printf code. Let's actually include the proper header for it. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-06-03lib/printf: ditch reallocarrayDavid Lamparter
reallocarray() is walled behind stupid feature macros on various platforms and doesn't quite gain us much in that particular use case. Signed-off-by: David Lamparter <equinox@diac24.net>
2019-06-03lib/printf: add extension supportDavid Lamparter
Inspired by the Linux kernel, this allows us to do %pI4 and similar things. Signed-off-by: David Lamparter <equinox@diac24.net>
2019-06-03lib/printf: fix some random warningsDavid Lamparter
Signed-off-by: David Lamparter <equinox@diac24.net>
2019-06-03lib/printf: integrateDavid Lamparter
Signed-off-by: David Lamparter <equinox@diac24.net>
2019-06-03lib/printf: rename & private __find_argumentsDavid Lamparter
These are internal to printf(), and symbols starting with __ are reserved for the compiler/libc. Signed-off-by: David Lamparter <equinox@diac24.net>
2019-06-03lib/printf: disable wchar_t supportDavid Lamparter
... we just don't use wchar_t in FRR, no point in having this enabled. Signed-off-by: David Lamparter <equinox@diac24.net>
2019-06-03lib/printf: add %Ld/%Lu for int64_t/uint64_tDavid Lamparter
[u]int64_t is the only type in the intX_t family that needs special-casing for printf since the calling convention may differ between 32-bit and 64-bit systems. Adding the L specifier allows us to eschew the gnarly-looking PRIu64. Signed-off-by: David Lamparter <equinox@diac24.net>
2019-06-03lib/printf: use system printf for floatsDavid Lamparter
We're not libc, we can just fall back to snprintf() to avoid all this low-level float mangling. Signed-off-by: David Lamparter <equinox@diac24.net>
2019-06-03lib/printf: cut down to sizeDavid Lamparter
remove various FreeBSD specific bits, as well as the entirety of locale support. Signed-off-by: David Lamparter <equinox@diac24.net>
2019-06-03lib: import FreeBSD's printfDavid Lamparter
... from current SVN HEAD (not that it has been touched in the past 2 years ...) Signed-off-by: David Lamparter <equinox@diac24.net>