On 9/30/2026 12:36 AM, Stephen Hemminger wrote: > Almost every driver parses numeric device arguments with its own > code, and most get some part of it wrong: atoi() does not detect > invalid input, errno is checked without being cleared, the end > pointer is ignored, the value is truncated before it is range > checked, or base 0 turns a leading zero into octal. > > This series adds range checked converters and ready made > rte_kvargs_process() handlers to librte_kvargs, then converts the drivers. > > Library (patches 1 to 3) > ------------------------ > > rte_kvargs_to_uint/to_int/to_hex convert with an explicit range > > rte_kvargs_handle_u8/u16/u32/u64 store into a typed variable > rte_kvargs_handle_i8/i16/i32/i64 > rte_kvargs_handle_uint/int/long/ulong/size > > rte_kvargs_handle_bool 1/y/yes/on/true and negatives, > bare key means true > rte_kvargs_handle_socket_id -1 (SOCKET_ID_ANY) through > RTE_MAX_NUMA_NODES - 1 > rte_kvargs_handle_hex32/hex64 bare hex mask, 0x optional
The argparse also provide such convert functions int rte_argparse_parse_type(const char *str, enum rte_argparse_value_type val_type, void *val); Can these be merged into one? > > Values are decimal or 0x hexadecimal, no octal, no negative value for > an unsigned type, no trailing garbage. > The handlers log key, value, and expected range on failure. > Unit tests cover all of them. > > The new api's are marked experimental for 26.11.

