[PATCH 57/65] dyndbg: simplify ddebug_find_valid_class
Jim Cromie
jim.cromie at gmail.com
Tue Oct 1 19:34:46 UTC 2024
This fn formerly returned the map which contained the class (thus
validating it), and as a side-effect set the class-id in an outvar.
But the caller didn't use the map (after checking its not null), only
the valid class-id. So simplify the fn to return the class-id of the
validated classname, or -ENOENT when the queried classname is not
found.
Signed-off-by: Jim Cromie <jim.cromie at gmail.com>
---
lib/dynamic_debug.c | 24 ++++++++----------------
1 file changed, 8 insertions(+), 16 deletions(-)
diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c
index eb9e53afc767..d62fa8dadf14 100644
--- a/lib/dynamic_debug.c
+++ b/lib/dynamic_debug.c
@@ -158,10 +158,7 @@ static void vpr_info_dq(const struct ddebug_query *query, const char *msg)
_dt->num_class_users); \
})
-#define __outvar /* filled by callee */
-static struct ddebug_class_map *ddebug_find_valid_class(struct ddebug_table const *dt,
- const char *class_string,
- __outvar int *class_id)
+static int ddebug_find_valid_class(struct ddebug_table const *dt, const char *class_string)
{
struct ddebug_class_map *map;
struct ddebug_class_user *cli;
@@ -170,22 +167,19 @@ static struct ddebug_class_map *ddebug_find_valid_class(struct ddebug_table cons
for (i = 0, map = dt->classes; i < dt->num_classes; i++, map++) {
idx = match_string(map->class_names, map->length, class_string);
if (idx >= 0) {
- *class_id = idx + map->base;
vpr_dt_info(dt, "good-class: %s.%s ", map->mod_name, class_string);
- return map;
+ return idx + map->base;
}
}
for (i = 0, cli = dt->class_users; i < dt->num_class_users; i++, cli++) {
idx = match_string(cli->map->class_names, cli->map->length, class_string);
if (idx >= 0) {
- *class_id = idx + cli->map->base;
vpr_dt_info(dt, "class-ref: %s.%s ",
cli->user_mod_name, class_string);
- return cli->map;
+ return idx + cli->map->base;
}
}
- *class_id = -ENOENT;
- return NULL;
+ return -ENOENT;
}
/*
@@ -194,16 +188,14 @@ static struct ddebug_class_map *ddebug_find_valid_class(struct ddebug_table cons
* callsites, normally the same as number of changes. If verbose,
* logs the changes. Takes ddebug_lock.
*/
-static int ddebug_change(const struct ddebug_query *query,
- struct flag_settings *modifiers)
+static int ddebug_change(const struct ddebug_query *query, struct flag_settings *modifiers)
{
int i;
struct ddebug_table *dt;
unsigned int newflags;
unsigned int nfound = 0;
struct flagsbuf fbuf, nbuf;
- struct ddebug_class_map *map = NULL;
- int __outvar valid_class;
+ int valid_class;
/* search for matching ddebugs */
mutex_lock(&ddebug_lock);
@@ -215,8 +207,8 @@ static int ddebug_change(const struct ddebug_query *query,
continue;
if (query->class_string) {
- map = ddebug_find_valid_class(dt, query->class_string, &valid_class);
- if (!map)
+ valid_class = ddebug_find_valid_class(dt, query->class_string);
+ if (valid_class < 0)
continue;
} else {
/* constrain query, do not touch class'd callsites */
--
2.46.2
More information about the Intel-gfx-trybot
mailing list