[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1310370416-6322-9-git-send-email-jim.cromie@gmail.com>
Date: Mon, 11 Jul 2011 01:46:43 -0600
From: Jim Cromie <jim.cromie@...il.com>
To: jbaron@...hat.com
Cc: linux-kernel@...r.kernel.org, bvanassche@....org, joe@...ches.com,
gregkh@...e.de, gnb@...h.org, Jim Cromie <jim.cromie@...il.com>
Subject: [PATCH 08/21] dynamic_debug: factor show_ddebug_query out of ddebug_parse_query
Will reuse for show_pending_query too. Alloc and free
print buffer space inside ddebug_exec_queries, instead of
a permanent static allocation.
Signed-off-by: Jim Cromie <jim.cromie@...il.com>
---
lib/dynamic_debug.c | 24 +++++++++++++++++++-----
1 files changed, 19 insertions(+), 5 deletions(-)
diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c
index de2a679..81268e2 100644
--- a/lib/dynamic_debug.c
+++ b/lib/dynamic_debug.c
@@ -96,6 +96,19 @@ static char *ddebug_describe_flags(struct _ddebug *dp, char *buf,
return buf;
}
+static char *prbuf_query;
+
+static char *show_ddebug_query(const struct ddebug_query *q)
+{
+ sprintf(prbuf_query,
+ "q->function=\"%s\" q->filename=\"%s\" "
+ "q->module=\"%s\" q->format=\"%s\" q->lineno=%u-%u",
+ q->function, q->filename, q->module, q->format,
+ q->first_lineno, q->last_lineno);
+
+ return prbuf_query;
+}
+
/*
* Search the tables for _ddebug's which match the given
* `query' and apply the `flags' and `mask' to them. Tells
@@ -344,11 +357,7 @@ static int ddebug_parse_query(char *words[], int nwords,
}
if (verbose)
- pr_info("q->function=\"%s\" q->filename=\"%s\" "
- "q->module=\"%s\" q->format=\"%s\" q->lineno=%u-%u\n",
- query->function, query->filename,
- query->module, query->format, query->first_lineno,
- query->last_lineno);
+ pr_info("parsed %s\n", show_ddebug_query(query));
return 0;
}
@@ -440,6 +449,10 @@ static int ddebug_exec_queries(char *query)
char *split;
int i, errs = 0, exitcode = 0, rc;
+ prbuf_query = kmalloc(1024, GFP_KERNEL);
+ if (prbuf_query == NULL)
+ return -ENOMEM;
+
for (i = 0; query; query = split, i++) {
split = strchr(query, ';');
if (split)
@@ -454,6 +467,7 @@ static int ddebug_exec_queries(char *query)
exitcode = rc;
}
}
+ kfree(prbuf_query);
if (verbose)
pr_info("processed %d queries, with %d errs\n", i, errs);
--
1.7.4.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists