All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Jan Beulich <JBeulich@suse.com>
Cc: xen-devel <xen-devel@lists.xenproject.org>, Keir Fraser <keir@xen.org>
Subject: Re: [PATCH 3/7] common/vsprintf: Add %ps and %pS format specifier support
Date: Tue, 5 Nov 2013 10:57:20 +0000	[thread overview]
Message-ID: <5278CF10.5020706@citrix.com> (raw)
In-Reply-To: <5278D93F02000078000FF731@nat28.tlf.novell.com>

On 05/11/13 10:40, Jan Beulich wrote:
>>>> On 04.11.13 at 22:30, Andrew Cooper <andrew.cooper3@citrix.com> wrote:
>> -static char *pointer(char *str, char *end,
>> +static char *pointer(char *str, char *end, const char **fmt_ptr,
>>                       unsigned long val, int field_width, int precision,
>>                       int flags)
>>  {
>> -    if ( field_width == -1 )
>> +    const char *fmt = *fmt_ptr, *s;
>> +
>> +    /*
>> +     * Custom %p suffixes, compatible with Linux.
>> +     * See XEN_ROOT/docs/misc/printk-formats.txt
>> +     */
>> +    switch ( fmt[1] )
>>      {
>> -        field_width = 2 * sizeof(void *);
>> -        flags |= ZEROPAD;
>> +    case 's': /* Symbol name */
>> +    case 'S': /* Symbol name with offset and size */
>> +    {
>> +        unsigned long sym_size, sym_offset;
>> +        char namebuf[KSYM_NAME_LEN+1];
>> +
>> +        /* Advance fmt pointer, as we have consumed 's' or 'S'.  Leave fmt
>> +         * along for consistency. */
> I'm not sure what the second sentence is supposed to tell me, even
> after s/along/alone/. Also - coding style (multi-line comment), no
> matter that other coding style aspects are being done matching the
> rest of the file rather than ./CODING_STYLE.

It was left over from a previous iteration which I thought I had
purged.  It has been now.

>
>> +        (*fmt_ptr)++;
> ++*fmt_ptr allows avoiding the parentheses.
>
>> +
>> +        s = symbols_lookup(val, &sym_size, &sym_offset, namebuf);
>> +
>> +        /* If the symbol is not found, fall back to printing the address */
>> +        if ( !s )
>> +            goto regular_pointer;
> Rather than using "goto" here, I'd suggest using "break" and
> handling the "normal" pointer case outside of the switch.
>
> Also I'm inclined to suggest that plain symbols be printed as
> symbols only when sym_offset is zero (otherwise confusion arises
> as to whether a pointer was an exact match).
>
>> +
>> +        /* Print symbol name */
>> +        str = string(str, end, s, -1, -1, 0);
>> +
>> +        if ( fmt[1] == 'S' )
>> +        {
>> +            /* Print '+0x<offset>/0x<len>' */
>> +            str = string(str, end, "+0x", -1, -1, 0);
>> +            str = number(str, end, sym_offset, 16, -1, -1, 0);
> I'd further suggest to pass SPECIAL here and avoid explicitly
> printing 0x (thus allowing at least zero to be printed as plain
> "0").
>
> Similarly passing SIGN|PLUS here would allow you to drop
> the explicit issuing of "+".
>
>> +            str = string(str, end, "/0x", -1, -1, 0);
>> +            str = number(str, end, sym_size, 16, -1, -1, 0);
> Same here then, even though sym_size should rarely end up
> being zero.
>
> Jan
>

Ok for all other points.

~Andrew

  reply	other threads:[~2013-11-05 10:57 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-04 21:30 [PATCH v2 0/7] Printk symbol specifier Andrew Cooper
2013-11-04 21:30 ` [PATCH 1/7] common/vsprintf: Refactor string() out of vsnprintf() Andrew Cooper
2013-11-04 21:30 ` [PATCH 2/7] common/vsprintf: Refactor pointer() " Andrew Cooper
2013-11-05 10:21   ` Jan Beulich
2013-11-05 10:25     ` Andrew Cooper
2013-11-04 21:30 ` [PATCH 3/7] common/vsprintf: Add %ps and %pS format specifier support Andrew Cooper
2013-11-05 10:39   ` Ian Campbell
2013-11-05 10:43     ` Andrew Cooper
2013-11-05 10:40   ` Jan Beulich
2013-11-05 10:57     ` Andrew Cooper [this message]
2013-11-04 21:30 ` [PATCH 4/7] x86: Replace print_symbol() with new %ps/%pS format Andrew Cooper
2013-11-05 10:47   ` Jan Beulich
2013-11-05 10:52     ` Andrew Cooper
2013-11-05 11:14       ` Jan Beulich
2013-11-05 11:16         ` Andrew Cooper
2013-11-04 21:30 ` [PATCH 5/7] arm: " Andrew Cooper
2013-11-04 21:30 ` [PATCH 6/7] common/symbols: Remove print_symbol() and associated infrastructure Andrew Cooper
2013-11-04 21:30 ` [PATCH 7/7] Test harness for new printk formatting Andrew Cooper

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5278CF10.5020706@citrix.com \
    --to=andrew.cooper3@citrix.com \
    --cc=JBeulich@suse.com \
    --cc=keir@xen.org \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.