On Wed, 7 May 2025 16:22:11 +0100 Anatoly Burakov <anatoly.bura...@intel.com> wrote:
> +NUMERIC_TYPES = { > + "UINT8": "uint8_t", > + "UINT16": "uint16_t", > + "UINT32": "uint32_t", > + "UINT64": "uint64_t", > + "INT8": "int8_t", > + "INT16": "int16_t", > + "INT32": "int32_t", > + "INT64": "int64_t", > + "FLOAT_SINGLE": "float", > + "FLOAT_DOUBLE": "double", > +} > Is it really worth having both single and double versions. Seems like unnecessary complexity at this point. > @@ -291,6 +302,25 @@ cmdline_parse_num(cmdline_parse_token_hdr_t *tk, const > char *srcbuf, void *res, > return -1; > } > return ret; > + /* float parsing */ > + } else if (nd.type >= RTE_FLOAT_SINGLE && nd.type <= RTE_FLOAT_DOUBLE) { > + char *end; > + double dres = strtod(srcbuf, &end); > + > + if (end == srcbuf || !cmdline_isendoftoken(*end) || isinf(dres)) > + return -1; > + > + /* we parsed something, now let's ensure it fits */ > + if (nd.type == RTE_FLOAT_SINGLE) { > + float flt = (float)dres; > + if (isinf(flt)) > + return -1; > + if (res) *(float *)res = flt; > + return end-srcbuf; > + } else if (nd.type == RTE_FLOAT_DOUBLE) { > + if (res) *(double *)res = dres; > + return end-srcbuf; Space around - please