From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Andrew Morton <akpm@linux-foundation.org>,
Rasmus Villemoes <linux@rasmusvillemoes.dk>,
linux-kernel@vger.kernel.org, Joe Perches <joe@perches.com>
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Subject: [PATCH v2 2/2] lib/vsprintf: factor out %pN[F] handler as netdev_bits()
Date: Tue, 29 Dec 2015 18:42:38 +0200 [thread overview]
Message-ID: <1451407358-7041-3-git-send-email-andriy.shevchenko@linux.intel.com> (raw)
In-Reply-To: <1451407358-7041-1-git-send-email-andriy.shevchenko@linux.intel.com>
Move switch case to the netdev_features_string() and rename it to
netdev_bits(). In the future we can extend it as needed.
Here we replace the fallback of %pN from '%p' with possible flags to sticter
'0x%p' without any flags variation.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
lib/vsprintf.c | 25 ++++++++++++++++---------
1 file changed, 16 insertions(+), 9 deletions(-)
diff --git a/lib/vsprintf.c b/lib/vsprintf.c
index 6946431..5c22317 100644
--- a/lib/vsprintf.c
+++ b/lib/vsprintf.c
@@ -1324,11 +1324,22 @@ char *uuid_string(char *buf, char *end, const u8 *addr,
return string(buf, end, uuid, spec);
}
-static
-char *netdev_feature_string(char *buf, char *end, const void *addr)
+static noinline_for_stack
+char *netdev_bits(char *buf, char *end, const void *addr, const char *fmt)
{
- unsigned long long num = *(const netdev_features_t *)addr;
- int size = sizeof(netdev_features_t);
+ unsigned long long num;
+ int size;
+
+ switch (fmt[1]) {
+ case 'F':
+ num = *(const netdev_features_t *)addr;
+ size = sizeof(netdev_features_t);
+ break;
+ default:
+ num = (unsigned long)addr;
+ size = sizeof(unsigned long);
+ break;
+ }
return special_hex_number(buf, end, num, size);
}
@@ -1671,11 +1682,7 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
break;
case 'N':
- switch (fmt[1]) {
- case 'F':
- return netdev_feature_string(buf, end, ptr);
- }
- break;
+ return netdev_bits(buf, end, ptr, fmt);
case 'a':
return address_val(buf, end, ptr, fmt);
case 'd':
--
2.6.4
prev parent reply other threads:[~2015-12-29 16:43 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-12-29 16:42 [PATCH v2 0/2] lib/vsprintf: introduce stricter rules for %p extensions Andy Shevchenko
2015-12-29 16:42 ` [PATCH v2 1/2] lib/vsprintf: refactor duplicate code to special_hex_number() Andy Shevchenko
2015-12-29 16:42 ` Andy Shevchenko [this message]
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=1451407358-7041-3-git-send-email-andriy.shevchenko@linux.intel.com \
--to=andriy.shevchenko@linux.intel.com \
--cc=akpm@linux-foundation.org \
--cc=joe@perches.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@rasmusvillemoes.dk \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox