Commit f657fd21 authored by Joe Perches's avatar Joe Perches Committed by Greg Kroah-Hartman

dynamic_debug: Fix vpr_<foo> logging styles

vpr_info_dq should be a function and vpr_info should have
a do {} while (0)

Add missing newlines to pr_<level>s.

Miscellaneous neatening too.
braces, coalescing formats, alignments, etc...
Signed-off-by: default avatarJoe Perches <joe@perches.com>
Signed-off-by: default avatarJason Baron <jbaron@redhat.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent a8826eeb
...@@ -59,7 +59,7 @@ struct ddebug_iter { ...@@ -59,7 +59,7 @@ struct ddebug_iter {
static DEFINE_MUTEX(ddebug_lock); static DEFINE_MUTEX(ddebug_lock);
static LIST_HEAD(ddebug_tables); static LIST_HEAD(ddebug_tables);
static int verbose = 0; static int verbose;
module_param(verbose, int, 0644); module_param(verbose, int, 0644);
/* Return the path relative to source root */ /* Return the path relative to source root */
...@@ -101,23 +101,31 @@ static char *ddebug_describe_flags(struct _ddebug *dp, char *buf, ...@@ -101,23 +101,31 @@ static char *ddebug_describe_flags(struct _ddebug *dp, char *buf,
} }
#define vpr_info(fmt, ...) \ #define vpr_info(fmt, ...) \
if (verbose) do { pr_info(fmt, ##__VA_ARGS__); } while (0)
#define vpr_info_dq(q, msg) \
do { \ do { \
/* trim last char off format print */ \ if (verbose) \
vpr_info("%s: func=\"%s\" file=\"%s\" " \ pr_info(fmt, ##__VA_ARGS__); \
"module=\"%s\" format=\"%.*s\" " \
"lineno=%u-%u", \
msg, \
q->function ? q->function : "", \
q->filename ? q->filename : "", \
q->module ? q->module : "", \
(int)(q->format ? strlen(q->format) - 1 : 0), \
q->format ? q->format : "", \
q->first_lineno, q->last_lineno); \
} while (0) } while (0)
static void vpr_info_dq(const struct ddebug_query *query, const char *msg)
{
/* trim any trailing newlines */
int fmtlen = 0;
if (query->format) {
fmtlen = strlen(query->format);
while (fmtlen && query->format[fmtlen - 1] == '\n')
fmtlen--;
}
vpr_info("%s: func=\"%s\" file=\"%s\" module=\"%s\" format=\"%.*s\" lineno=%u-%u\n",
msg,
query->function ? query->function : "",
query->filename ? query->filename : "",
query->module ? query->module : "",
fmtlen, query->format ? query->format : "",
query->first_lineno, query->last_lineno);
}
/* /*
* Search the tables for _ddebug's which match the given `query' and * Search the tables for _ddebug's which match the given `query' and
* apply the `flags' and `mask' to them. Returns number of matching * apply the `flags' and `mask' to them. Returns number of matching
...@@ -141,7 +149,7 @@ static int ddebug_change(const struct ddebug_query *query, ...@@ -141,7 +149,7 @@ static int ddebug_change(const struct ddebug_query *query,
if (query->module && strcmp(query->module, dt->mod_name)) if (query->module && strcmp(query->module, dt->mod_name))
continue; continue;
for (i = 0 ; i < dt->num_ddebugs ; i++) { for (i = 0; i < dt->num_ddebugs; i++) {
struct _ddebug *dp = &dt->ddebugs[i]; struct _ddebug *dp = &dt->ddebugs[i];
/* match against the source filename */ /* match against the source filename */
...@@ -213,12 +221,12 @@ static int ddebug_tokenize(char *buf, char *words[], int maxwords) ...@@ -213,12 +221,12 @@ static int ddebug_tokenize(char *buf, char *words[], int maxwords)
/* find `end' of word, whitespace separated or quoted */ /* find `end' of word, whitespace separated or quoted */
if (*buf == '"' || *buf == '\'') { if (*buf == '"' || *buf == '\'') {
int quote = *buf++; int quote = *buf++;
for (end = buf ; *end && *end != quote ; end++) for (end = buf; *end && *end != quote; end++)
; ;
if (!*end) if (!*end)
return -EINVAL; /* unclosed quote */ return -EINVAL; /* unclosed quote */
} else { } else {
for (end = buf ; *end && !isspace(*end) ; end++) for (end = buf; *end && !isspace(*end); end++)
; ;
BUG_ON(end == buf); BUG_ON(end == buf);
} }
...@@ -235,7 +243,7 @@ static int ddebug_tokenize(char *buf, char *words[], int maxwords) ...@@ -235,7 +243,7 @@ static int ddebug_tokenize(char *buf, char *words[], int maxwords)
if (verbose) { if (verbose) {
int i; int i;
pr_info("split into words:"); pr_info("split into words:");
for (i = 0 ; i < nwords ; i++) for (i = 0; i < nwords; i++)
pr_cont(" \"%s\"", words[i]); pr_cont(" \"%s\"", words[i]);
pr_cont("\n"); pr_cont("\n");
} }
...@@ -288,9 +296,9 @@ static char *unescape(char *str) ...@@ -288,9 +296,9 @@ static char *unescape(char *str)
} else if (isodigit(in[1]) && } else if (isodigit(in[1]) &&
isodigit(in[2]) && isodigit(in[2]) &&
isodigit(in[3])) { isodigit(in[3])) {
*out++ = ((in[1] - '0')<<6) | *out++ = (((in[1] - '0') << 6) |
((in[2] - '0')<<3) | ((in[2] - '0') << 3) |
(in[3] - '0'); (in[3] - '0'));
in += 4; in += 4;
continue; continue;
} }
...@@ -308,7 +316,7 @@ static int check_set(const char **dest, char *src, char *name) ...@@ -308,7 +316,7 @@ static int check_set(const char **dest, char *src, char *name)
if (*dest) { if (*dest) {
rc = -EINVAL; rc = -EINVAL;
pr_err("match-spec:%s val:%s overridden by %s", pr_err("match-spec:%s val:%s overridden by %s\n",
name, *dest, src); name, *dest, src);
} }
*dest = src; *dest = src;
...@@ -345,17 +353,17 @@ static int ddebug_parse_query(char *words[], int nwords, ...@@ -345,17 +353,17 @@ static int ddebug_parse_query(char *words[], int nwords,
/* support $modname.dyndbg=<multiple queries> */ /* support $modname.dyndbg=<multiple queries> */
query->module = modname; query->module = modname;
for (i = 0 ; i < nwords ; i += 2) { for (i = 0; i < nwords; i += 2) {
if (!strcmp(words[i], "func")) if (!strcmp(words[i], "func")) {
rc = check_set(&query->function, words[i+1], "func"); rc = check_set(&query->function, words[i+1], "func");
else if (!strcmp(words[i], "file")) } else if (!strcmp(words[i], "file")) {
rc = check_set(&query->filename, words[i+1], "file"); rc = check_set(&query->filename, words[i+1], "file");
else if (!strcmp(words[i], "module")) } else if (!strcmp(words[i], "module")) {
rc = check_set(&query->module, words[i+1], "module"); rc = check_set(&query->module, words[i+1], "module");
else if (!strcmp(words[i], "format")) } else if (!strcmp(words[i], "format")) {
rc = check_set(&query->format, unescape(words[i+1]), rc = check_set(&query->format, unescape(words[i+1]),
"format"); "format");
else if (!strcmp(words[i], "line")) { } else if (!strcmp(words[i], "line")) {
char *first = words[i+1]; char *first = words[i+1];
char *last = strchr(first, '-'); char *last = strchr(first, '-');
if (query->first_lineno || query->last_lineno) { if (query->first_lineno || query->last_lineno) {
...@@ -410,7 +418,7 @@ static int ddebug_parse_flags(const char *str, unsigned int *flagsp, ...@@ -410,7 +418,7 @@ static int ddebug_parse_flags(const char *str, unsigned int *flagsp,
} }
vpr_info("op='%c'\n", op); vpr_info("op='%c'\n", op);
for ( ; *str ; ++str) { for (; *str ; ++str) {
for (i = ARRAY_SIZE(opt_array) - 1; i >= 0; i--) { for (i = ARRAY_SIZE(opt_array) - 1; i >= 0; i--) {
if (*str == opt_array[i].opt_char) { if (*str == opt_array[i].opt_char) {
flags |= opt_array[i].flag; flags |= opt_array[i].flag;
...@@ -459,7 +467,7 @@ static int ddebug_exec_query(char *query_string, const char *modname) ...@@ -459,7 +467,7 @@ static int ddebug_exec_query(char *query_string, const char *modname)
/* actually go and implement the change */ /* actually go and implement the change */
nfound = ddebug_change(&query, flags, mask); nfound = ddebug_change(&query, flags, mask);
vpr_info_dq((&query), (nfound) ? "applied" : "no-match"); vpr_info_dq(&query, nfound ? "applied" : "no-match");
return nfound; return nfound;
} }
...@@ -488,8 +496,9 @@ static int ddebug_exec_queries(char *query, const char *modname) ...@@ -488,8 +496,9 @@ static int ddebug_exec_queries(char *query, const char *modname)
if (rc < 0) { if (rc < 0) {
errs++; errs++;
exitcode = rc; exitcode = rc;
} else } else {
nfound += rc; nfound += rc;
}
i++; i++;
} }
vpr_info("processed %d queries, with %d matches, %d errs\n", vpr_info("processed %d queries, with %d matches, %d errs\n",
...@@ -845,7 +854,7 @@ static int ddebug_proc_open(struct inode *inode, struct file *file) ...@@ -845,7 +854,7 @@ static int ddebug_proc_open(struct inode *inode, struct file *file)
kfree(iter); kfree(iter);
return err; return err;
} }
((struct seq_file *) file->private_data)->private = iter; ((struct seq_file *)file->private_data)->private = iter;
return 0; return 0;
} }
...@@ -1002,8 +1011,7 @@ static int __init dynamic_debug_init(void) ...@@ -1002,8 +1011,7 @@ static int __init dynamic_debug_init(void)
int verbose_bytes = 0; int verbose_bytes = 0;
if (__start___verbose == __stop___verbose) { if (__start___verbose == __stop___verbose) {
pr_warn("_ddebug table is empty in a " pr_warn("_ddebug table is empty in a CONFIG_DYNAMIC_DEBUG build\n");
"CONFIG_DYNAMIC_DEBUG build");
return 1; return 1;
} }
iter = __start___verbose; iter = __start___verbose;
...@@ -1030,18 +1038,16 @@ static int __init dynamic_debug_init(void) ...@@ -1030,18 +1038,16 @@ static int __init dynamic_debug_init(void)
goto out_err; goto out_err;
ddebug_init_success = 1; ddebug_init_success = 1;
vpr_info("%d modules, %d entries and %d bytes in ddebug tables," vpr_info("%d modules, %d entries and %d bytes in ddebug tables, %d bytes in (readonly) verbose section\n",
" %d bytes in (readonly) verbose section\n", modct, entries, (int)(modct * sizeof(struct ddebug_table)),
modct, entries, (int)( modct * sizeof(struct ddebug_table)),
verbose_bytes + (int)(__stop___verbose - __start___verbose)); verbose_bytes + (int)(__stop___verbose - __start___verbose));
/* apply ddebug_query boot param, dont unload tables on err */ /* apply ddebug_query boot param, dont unload tables on err */
if (ddebug_setup_string[0] != '\0') { if (ddebug_setup_string[0] != '\0') {
pr_warn("ddebug_query param name is deprecated," pr_warn("ddebug_query param name is deprecated, change it to dyndbg\n");
" change it to dyndbg\n");
ret = ddebug_exec_queries(ddebug_setup_string, NULL); ret = ddebug_exec_queries(ddebug_setup_string, NULL);
if (ret < 0) if (ret < 0)
pr_warn("Invalid ddebug boot param %s", pr_warn("Invalid ddebug boot param %s\n",
ddebug_setup_string); ddebug_setup_string);
else else
pr_info("%d changes by ddebug_query\n", ret); pr_info("%d changes by ddebug_query\n", ret);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment