[PATCH v12 2/3] cmdline: add floating point support

Stephen Hemminger stephen at networkplumber.org
Sun Apr 5 18:22:25 CEST 2026


On Thu, 26 Feb 2026 16:44:49 +0000
Anatoly Burakov <anatoly.burakov at intel.com> wrote:

> Add support for parsing floating point numbers in cmdline library, as well
> as unit tests for the new functionality. Use C library for parsing.
> 
> Signed-off-by: Anatoly Burakov <anatoly.burakov at intel.com>
> ---


Some things AI spotted that I missed.

[PATCH v12 2/3] cmdline: add floating point support
Error: In float_valid_strs[], the entry {"-2E308", HUGE_VAL} has the wrong sign 
— it should be {"-2E308", -HUGE_VAL}. 
The preceding entry {"-2e308", -HUGE_VAL} has the correct sign. This is a copy-paste bug.

Warning: In cmdline_parse_num(), the float write path uses 
if (res && write_float(num_data.type, res, dres)) without the < 0 comparison,
while the integer path uses if (res && write_num(num_data.type, res, uintres) < 0). 
The bare truthiness check happens to work because -1 is truthy in C,
but it's inconsistent and fragile — if write_float ever returns a positive error code, this breaks. 
Should be write_float(...) < 0 to match write_num.


More information about the dev mailing list