To avoid redundant calls to the token-generating function and provide it with helpful context, a temporary fixed-size array allocated on the stack of cmdline_parse() and cmdline_complete() keeps the address of preceding tokens for the command instance being processed (cmdline_parse_inst_t). Like the static tokens array in cmdline_parse_inst_t, it must be NULL-terminated, however this is not properly enforced as it is initialized once at the beginning of each function and a NULL terminator is never appended once replaced with generated tokens. When several commands rely on dynamic tokens, subsequent ones inherit an already initialized array whose tokens are not regenerated, which causes various issues such as mixed and repeated tokens from the first command. Enforcing NULL termination of the dynamic tokens array and reinitializing its first entry at each iteration solves these issues. Doing so is also less expensive than a full memset() at each iteration. Fixes: 4fffc05a2b2c ("cmdline: support dynamic tokens") Cc: stable@dpdk.org Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com> Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com> Acked-by: Olivier Matz <olivier.matz@6wind.com>
DPDK is a set of libraries and drivers for fast packet processing. It supports many processor architectures and both FreeBSD and Linux. The DPDK uses the Open Source BSD license for the core libraries and drivers. The kernel components are GPLv2 licensed. Please check the doc directory for release notes, API documentation, and sample application information. For questions and usage discussions, subscribe to: users@dpdk.org Report bugs and issues to the development mailing list: dev@dpdk.org
Description
Languages
C
99.1%
Meson
0.5%
Python
0.2%
Shell
0.1%