lkml.org 
[lkml]   [2013]   [Oct]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 2/2] vsprintf: Just some neatening
Date
Remove a few coding style nits:

o Leading spaces for tabs
o case indentation depth
o else and brace locations
o logical continuation placement

Several checkpatch bleats still exist,
mostly not worth changing.

Signed-off-by: Joe Perches <joe@perches.com>
---
lib/vsprintf.c | 83 +++++++++++++++++++++++++++++-----------------------------
1 file changed, 42 insertions(+), 41 deletions(-)

diff --git a/lib/vsprintf.c b/lib/vsprintf.c
index ce55f52..dbc945b 100644
--- a/lib/vsprintf.c
+++ b/lib/vsprintf.c
@@ -266,10 +266,10 @@ void put_dec_full4(char *buf, unsigned q)
static
unsigned put_dec_helper4(char *buf, unsigned x)
{
- uint32_t q = (x * (uint64_t)0x346DC5D7) >> 43;
+ uint32_t q = (x * (uint64_t)0x346DC5D7) >> 43;

- put_dec_full4(buf, x - q * 10000);
- return q;
+ put_dec_full4(buf, x - q * 10000);
+ return q;
}

/* Based on code by Douglas W. Jones found at
@@ -561,11 +561,11 @@ char *dentry_name(char *buf, char *end, const struct dentry *d, struct printf_sp
int i, n;

switch (fmt[1]) {
- case '2': case '3': case '4':
- depth = fmt[1] - '0';
- break;
- default:
- depth = 1;
+ case '2': case '3': case '4':
+ depth = fmt[1] - '0';
+ break;
+ default:
+ depth = 1;
}

rcu_read_lock();
@@ -939,11 +939,11 @@ char *ip6_compressed_string(char *p, const char *addr)
else
*p++ = hex_asc_lo(hi);
p = hex_byte_pack(p, lo);
- }
- else if (lo > 0x0f)
+ } else if (lo > 0x0f) {
p = hex_byte_pack(p, lo);
- else
+ } else {
*p++ = hex_asc_lo(lo);
+ }
needcolon = true;
}

@@ -1268,10 +1268,6 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
* 6: 000102...0f
*/
switch (fmt[1]) {
- case '6':
- return ip6_addr_string(buf, end, ptr, spec, fmt);
- case '4':
- return ip4_addr_string(buf, end, ptr, spec, fmt);
case 'S': {
const union {
struct sockaddr raw;
@@ -1281,26 +1277,33 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,

switch (sa->raw.sa_family) {
case AF_INET:
- return ip4_addr_string_sa(buf, end, &sa->v4, spec, fmt);
+ return ip4_addr_string_sa(buf, end, &sa->v4,
+ spec, fmt);
case AF_INET6:
- return ip6_addr_string_sa(buf, end, &sa->v6, spec, fmt);
+ return ip6_addr_string_sa(buf, end, &sa->v6,
+ spec, fmt);
default:
- return string(buf, end, "(invalid address)", spec);
- }}
+ return string(buf, end, "(invalid address)",
+ spec);
+ }
+ }
+ case '6':
+ return ip6_addr_string(buf, end, ptr, spec, fmt);
+ case '4':
+ return ip4_addr_string(buf, end, ptr, spec, fmt);
}
break;
case 'U':
return uuid_string(buf, end, ptr, spec, fmt);
- case 'V':
- {
- va_list va;
+ case 'V': {
+ va_list va;

- va_copy(va, *((struct va_format *)ptr)->va);
- buf += vsnprintf(buf, end > buf ? end - buf : 0,
- ((struct va_format *)ptr)->fmt, va);
- va_end(va);
- return buf;
- }
+ va_copy(va, *((struct va_format *)ptr)->va);
+ buf += vsnprintf(buf, end > buf ? end - buf : 0,
+ ((struct va_format *)ptr)->fmt, va);
+ va_end(va);
+ return buf;
+ }
case 'K': /* see: Documentation/sysctl/kernel.txt */
switch (kptr_restrict) {
case 0: /* None (default) */
@@ -1400,7 +1403,7 @@ int format_decode(const char *fmt, struct printf_spec *spec)
/* By default */
spec->type = FORMAT_TYPE_NONE;

- for (; *fmt ; ++fmt) {
+ for (; *fmt; ++fmt) {
if (*fmt == '%')
break;
}
@@ -1433,9 +1436,9 @@ int format_decode(const char *fmt, struct printf_spec *spec)
/* get field width */
spec->field_width = -1;

- if (isdigit(*fmt))
+ if (isdigit(*fmt)) {
spec->field_width = skip_atoi(&fmt);
- else if (*fmt == '*') {
+ } else if (*fmt == '*') {
/* it's the next argument */
spec->type = FORMAT_TYPE_WIDTH;
return ++fmt - start;
@@ -1521,9 +1524,9 @@ qualifier:
return fmt - start;
}

- if (spec->qualifier == 'L')
+ if (spec->qualifier == 'L') {
spec->type = FORMAT_TYPE_LONG_LONG;
- else if (spec->qualifier == 'l') {
+ } else if (spec->qualifier == 'l') {
if (spec->flags & SIGN)
spec->type = FORMAT_TYPE_LONG;
else
@@ -1654,7 +1657,6 @@ int vsnprintf(char *buf, size_t size, const char *fmt, va_list args)
if (str < end)
*str = ' ';
++str;
-
}
}
c = (unsigned char) va_arg(args, int);
@@ -1760,7 +1762,6 @@ int vsnprintf(char *buf, size_t size, const char *fmt, va_list args)

/* the trailing null byte doesn't count towards the total */
return str-buf;
-
}
EXPORT_SYMBOL(vsnprintf);

@@ -1966,7 +1967,7 @@ do { \
size_t len;

if ((unsigned long)save_str > (unsigned long)-PAGE_SIZE
- || (unsigned long)save_str < PAGE_SIZE)
+ || (unsigned long)save_str < PAGE_SIZE)
save_str = "(null)";
len = strlen(save_str) + 1;
if (str + len < end)
@@ -2392,11 +2393,11 @@ int vsscanf(const char *buf, const char *fmt, va_list args)
if (is_sign && digit == '-')
digit = *(str + 1);

- if (!digit
- || (base == 16 && !isxdigit(digit))
- || (base == 10 && !isdigit(digit))
- || (base == 8 && (!isdigit(digit) || digit > '7'))
- || (base == 0 && !isdigit(digit)))
+ if (!digit ||
+ (base == 16 && !isxdigit(digit)) ||
+ (base == 10 && !isdigit(digit)) ||
+ (base == 8 && (!isdigit(digit) || digit > '7')) ||
+ (base == 0 && !isdigit(digit)))
break;

if (is_sign)
--
1.8.1.2.459.gbcd45b4.dirty


\
 
 \ /
  Last update: 2013-10-11 07:41    [W:0.050 / U:0.128 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site