On Thu, Jul 25, 2024 at 01:09:24PM -0700, Andrii Nakryiko wrote:
On Thu, Jul 25, 2024 at 3:39 AM Tony Ambardar [off-list ref] wrote:
quoted
...
quoted
--- a/tools/testing/selftests/bpf/testing_helpers.c
+++ b/tools/testing/selftests/bpf/testing_helpers.c
@@ -227,7 +227,7 @@ int parse_test_list(const char *s,
if (!input)
return -ENOMEM;
- while ((test_spec = strtok_r(state ? NULL : input, ",", &state))) {
+ for (test_spec = strtok_r(input, ",", &state); test_spec; test_spec = strtok_r(NULL, ",", &state)) {
oh, this is so long and verbose, let's just add a counter and use that
to determine whether to pass NULL or input, ok?
...
quoted
- while ((next = strtok_r(state ? NULL : input, ",", &state))) {
+ for (next = strtok_r(input, ",", &state); next; next = strtok_r(NULL, ",", &state)) {
ditto, let's not duplicate strtok_r() calls
Sounds good. I'll update for v2 and thanks for the suggestion.
...