[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAO+b5-o1vZLResL9LzquZw5qu50evzfGAXNQ8fU0dVZZ5iX6+Q@mail.gmail.com>
Date: Tue, 26 Jul 2011 09:37:32 +0200
From: Bart Van Assche <bvanassche@....org>
To: Jim Cromie <jim.cromie@...il.com>
Cc: jbaron@...hat.com, joe@...ches.com, gregkh@...e.de,
linux-kernel@...r.kernel.org, gnb@...h.org
Subject: Re: [PATCH 18/25] dynamic_debug: describe_flags with '=[pmflta_]*'
On Mon, Jul 25, 2011 at 11:42 PM, Jim Cromie <jim.cromie@...il.com> wrote:
> Change describe_flags() to emit '=[pmflta_]+' for current callsite
> flags, or just '=_' when they're disabled. Having '=' in output
> allows a more selective grep expression, in contrast '-' may appear
> in filenames, line-ranges, and format-strings. '=' also has better
> mnemonics, saying; "the current setting are equal to <flags>".
>
> The default allows grep "=_" <dbgfs>/dynamic_debug/control
> to see disabled callsites while avoiding the many occurrences of " = "
> seen in format strings.
>
> Signed-off-by: Jim Cromie <jim.cromie@...il.com>
> ---
> lib/dynamic_debug.c | 6 ++++--
> 1 files changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c
> index 396ffb4..37f9748 100644
> --- a/lib/dynamic_debug.c
> +++ b/lib/dynamic_debug.c
> @@ -92,6 +92,7 @@ static struct { unsigned flag:8; char opt_char; } opt_array[] = {
> { _DPRINTK_FLAGS_INCL_LINENO, 'l' },
> { _DPRINTK_FLAGS_INCL_TID, 't' },
> { _DPRINTK_FLAGS_APPEND, 'a' },
> + { _DPRINTK_FLAGS_DEFAULT, '_' },
> };
>
> /* format a string into buf[] which describes the _ddebug's flags */
> @@ -102,11 +103,12 @@ static char *ddebug_describe_flags(struct _ddebug *dp, char *buf,
> int i;
>
> BUG_ON(maxlen < 4);
> + *p++ = '=';
> for (i = 0; i < ARRAY_SIZE(opt_array); ++i)
> if (dp->flags & opt_array[i].flag)
> *p++ = opt_array[i].opt_char;
> - if (p == buf)
> - *p++ = '-';
> + if (*(p-1) == '=')
> + *p++ = '_';
> *p = '\0';
>
> return buf;
The "BUG_ON(maxlen < 4)" tests whether a buffer overflow can occur
before starting to write in the buffer. Since the above code affects
the number of characters that can be written in the output buffer,
shouldn't that statement be updated or replaced ?
Bart.
--
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