History log of /freebsd-current/lib/libutil/tests/expand_number_test.c
Revision Date Author Comments
# 1d386b48 16-Aug-2023 Warner Losh <imp@FreeBSD.org>

Remove $FreeBSD$: one-line .c pattern

Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/


# 6cc4a1c3 13-Jun-2023 Xin LI <delphij@FreeBSD.org>

Fix build with gcc12.


# 08300d84 12-Jun-2023 Xin LI <delphij@FreeBSD.org>

expand_number: Tighten check of unit.

The current code silently ignores characters after the unit as long
the unit themselves were recognized. This commit makes expand_number(3)
to fail with EINVAL if buf did not terminate after the unit character.

Historically, the function accepts and ignores "B" as a SI unit, this
behavior is preserved and e.g. KB, MB are still accepted as aliases of
K and M, document this behavior in the manual page.

While I am there, also write a few test cases to validate the behavior.

Reviewed-by: emaste
MFC-after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D40482