On Wed, 27 Aug 2025 07:18:37 -0400
Khadem Ullah <[email protected]> wrote:
>
> +static int
> +validate_input_color_table_entries(char *str)
> +{
> + char *token = strtok_r(str, PARSE_DELIMITER, &str);
> + for (int i = 0; token != NULL; i++) {
> + if (i > ((MAX_DSCP_TABLE_ENTRIES + MAX_VLAN_TABLE_ENTRIES) - 1))
> + return -1;
> + token = strtok_r(str, PARSE_DELIMITER, &str);
> + }
> + return 0;
> +}
The loop doesn't look right, it is looking form next deliminator at
the start of the list? Normally strtok_r is used with a different pointer
as the "saveptr".
From man page.
The strtok_r() function is a reentrant version of strtok(). The
saveptr argument is a
pointer to a char * variable that is used internally by strtok_r() in
order to maintain con‐
text between successive calls that parse the same string.
On the first call to strtok_r(), str should point to the string to be
parsed, and the value
of *saveptr is ignored (but see VERSIONS). In subsequent calls, str
should be NULL, and
saveptr (and the buffer that it points to) should be unchanged since the
previous call.