lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1311630170-26057-12-git-send-email-jim.cromie@gmail.com>
Date:	Mon, 25 Jul 2011 15:42:36 -0600
From:	Jim Cromie <jim.cromie@...il.com>
To:	jbaron@...hat.com
Cc:	bvanassche@....org, joe@...ches.com, gregkh@...e.de,
	linux-kernel@...r.kernel.org, gnb@...h.org,
	Jim Cromie <jim.cromie@...il.com>
Subject: [PATCH 11/25] dynamic_debug: factor show_ddebug_query out of ddebug_parse_query

Factor show_ddebug_query out of ddebug_parse_query.  Also change
the printed labels to agree with the query-spec keywords accepted in
the control file; file, func.  Pass "" when string is null,
to avoid "(null)" output from sprintf.

Code uses sprintf into a large buffer, kallocd and freed from
ddebug_exec_queries.  function has 1 caller now, will add more later.
Will also reuse the buffer and function for show_pending_query().
This is in lieu of char *p=kasprintf; free(p) everywhere the
function will be used.  TBD.

Signed-off-by: Jim Cromie <jim.cromie@...il.com>
---
 lib/dynamic_debug.c |   30 ++++++++++++++++++++++++------
 1 files changed, 24 insertions(+), 6 deletions(-)

diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c
index 1ced79e..5774a6f 100644
--- a/lib/dynamic_debug.c
+++ b/lib/dynamic_debug.c
@@ -96,6 +96,21 @@ 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)
+{
+	char *p = kasprintf(GFP_KERNEL,
+			"func=\"%s\" file=\"%s\" "
+			"module=\"%s\" format=\"%s\" lineno=%u-%u",
+			q->function ? q->function : "",
+			q->filename ? q->filename : "",
+			q->module ? q->module : "",
+			q->format ? q->format : "",
+			q->first_lineno, q->last_lineno);
+	return p;
+}
+
 /*
  * Search the tables for _ddebug's which match the given
  * `query' and apply the `flags' and `mask' to them.  Tells
@@ -307,6 +322,7 @@ static int ddebug_parse_query(char *words[], int nwords,
 			       struct ddebug_query *query)
 {
 	unsigned int i;
+	char *qstr;
 
 	/* check we have an even number of words */
 	if (nwords % 2 != 0)
@@ -342,12 +358,9 @@ static int ddebug_parse_query(char *words[], int nwords,
 			return -EINVAL;
 		}
 	}
-
-	pr_debug("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);
+	qstr = show_ddebug_query(query);
+	pr_debug("parsed %s\n", qstr);
+	kfree(qstr);
 
 	return 0;
 }
@@ -435,6 +448,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) {
 		split = strpbrk(query, ";\n");
 		if (split)
@@ -452,6 +469,7 @@ static int ddebug_exec_queries(char *query)
 		}
 		i++;
 	}
+	kfree(prbuf_query);
 	pr_debug("processed %d queries, with %d errs\n", i, errs);
 
 	return exitcode;
-- 
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

Powered by Openwall GNU/*/Linux Powered by OpenVZ