[PATCH v3 19/22] dyndbg: add skip_spaces_and_coma()

From: Łukasz Bartosik
Date: Fri Dec 22 2023 - 20:56:52 EST


From: Jim Cromie <jim.cromie@xxxxxxxxx>

The function skip_spaces_and_coma removes leading
spaces and coma. With this approach a user can
provide dynamic debug control commands in new format.
For example the following command (existing format)

modprobe test_dynamic_debug dyndbg="class D2_CORE +p"

can also be provided as (new format):

modprobe test_dynamic_debug dyndbg=class,D2_CORE,+p

Signed-off-by: Jim Cromie <jim.cromie@xxxxxxxxx>
Signed-off-by: Łukasz Bartosik <lb@xxxxxxxxxxxx>
---
lib/dynamic_debug.c | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c
index 70d9440193a8..48ce24c39457 100644
--- a/lib/dynamic_debug.c
+++ b/lib/dynamic_debug.c
@@ -618,6 +618,14 @@ static int ddebug_change(const struct ddebug_query *query,
return nfound;
}

+char *skip_spaces_and_coma(const char *str)
+{
+ str = skip_spaces(str);
+ if (*str == ',')
+ str = skip_spaces(++str);
+ return (char *)str;
+}
+
/*
* Split the buffer `buf' into space-separated words.
* Handles simple " and ' quoting, i.e. without nested,
@@ -631,8 +639,8 @@ static int ddebug_tokenize(char *buf, char *words[], int maxwords)
while (*buf) {
char *end;

- /* Skip leading whitespace */
- buf = skip_spaces(buf);
+ /* Skip leading whitespace and coma */
+ buf = skip_spaces_and_coma(buf);
if (!*buf)
break; /* oh, it was trailing whitespace */
if (*buf == '#')
@@ -959,7 +967,7 @@ static int ddebug_exec_queries(char *query, const char *modname)
if (split)
*split++ = '\0';

- query = skip_spaces(query);
+ query = skip_spaces_and_coma(query);
if (!query || !*query || *query == '#')
continue;

--
2.43.0.472.g3155946c3a-goog