summaryrefslogtreecommitdiff
path: root/lib/printf
AgeCommit message (Collapse)Author
2025-04-08lib: fix -Wshadow warnings in the lib modulesMark Stapp
Fix various "shadow" warnings in lib. Signed-off-by: Mark Stapp <mjs@cisco.com>
2024-03-10lib/printf: update READMEDavid Lamparter
Make a note that `%w[f](8|16|32|64)d` was picked up. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2024-03-10lib/printf: Implement N2680.Dag-Erling Smørgrav
This adds specific width length modifiers in the form of wN and wfN (where N is 8, 16, 32, or 64) which allow printing intN_t and int_fastN_t without resorting to casts or PRI macros. Reviewed by: imp, emaste Differential Revision: https://reviews.freebsd.org/D41725 FRR changes only include printf(), scanf/strtol are not locally implemented in FRR. Also added "(void) 0" to empty "else ..." to avoid a compiler warning. Signed-off-by: David Lamparter <equinox@opensourcerouting.org> (cherry picked from FreeBSD commit bce0bef3c6abab92c7ac8cc23b7cc632a382721e)
2023-10-12build: add -Wimplicit-fallthroughIgor Ryzhov
Also: - replace all /* fallthrough */ comments with portable fallthrough; pseudo keyword to accomodate both gcc and clang - add missing break; statements as required by older versions of gcc - cleanup some code to remove unnecessary fallthrough Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2023-09-20lib: random make-coverity-happy nitsDavid Lamparter
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2023-09-03lib/printf: update READMEDavid Lamparter
Make a note that `%b` was picked up. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2023-09-03lib/printf: Implement N2630.Dag-Erling Smørgrav
This adds formatted input/output of binary integer numbers to the printf(), scanf(), and strtol() families, including their wide-character counterparts. Reviewed by: imp, emaste Differential Revision: https://reviews.freebsd.org/D41511 FRR changes only include printf(), scanf/strtol are not locally implemented in FRR. Signed-off-by: David Lamparter <equinox@opensourcerouting.org> (cherry picked from FreeBSD commit d9dc1603d6e48cca84cad3ebe859129131b8387c)
2023-09-03lib/printf: Remove $FreeBSD$: two-line .h patternWarner Losh
Remove /^\s*\*\n \*\s+\$FreeBSD\$$\n/ Signed-off-by: David Lamparter <equinox@opensourcerouting.org> (cherry picked from FreeBSD commit b3e7694832e81d7a904a10f525f8797b753bf0d3)
2023-09-03lib/printf: drop "All rights reserved" from Foundation copyrightsEd Maste
This has already been done for most files that have the Foundation as the only listed copyright holder. Do it now for files that list multiple copyright holders, but have the Foundation copyright in its own section. Sponsored by: The FreeBSD Foundation Signed-off-by: David Lamparter <equinox@opensourcerouting.org> (cherry picked from FreeBSD commit 5b5fa75acff11d871d0c90045f8c1a58fed85365)
2023-05-22lib: va_end must be calledDonald Sharp
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-02-09*: manual SPDX License ID conversionsDavid Lamparter
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-01-27*: no-warn pragmas for non-const format stringsDavid Lamparter
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>
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>