diff options
| author | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2009-11-02 22:10:07 -0800 | 
|---|---|---|
| committer | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2009-11-02 22:10:07 -0800 | 
| commit | 7a53c7f56bbfc9b0ef892e68f5cfae3d902544d1 (patch) | |
| tree | 19dec256fc80ad06d631ece78b9eb68a457ce66b /lib/vsprintf.c | |
| parent | e57130698fe3dd2b7d617d90bbf86474473cb40c (diff) | |
| parent | 012abeea669ea49636cf952d13298bb68654146a (diff) | |
Merge commit 'v2.6.32-rc5' into for-linus
Diffstat (limited to 'lib/vsprintf.c')
| -rw-r--r-- | lib/vsprintf.c | 57 | 
1 files changed, 26 insertions, 31 deletions
diff --git a/lib/vsprintf.c b/lib/vsprintf.c index cb8a112030bb..33bed5e67a21 100644 --- a/lib/vsprintf.c +++ b/lib/vsprintf.c @@ -581,7 +581,7 @@ static char *symbol_string(char *buf, char *end, void *ptr,  	unsigned long value = (unsigned long) ptr;  #ifdef CONFIG_KALLSYMS  	char sym[KSYM_SYMBOL_LEN]; -	if (ext != 'f') +	if (ext != 'f' && ext != 's')  		sprint_symbol(sym, value);  	else  		kallsyms_lookup(value, NULL, NULL, NULL, sym); @@ -671,7 +671,7 @@ static char *ip4_string(char *p, const u8 *addr, bool leading_zeros)  	return p;  } -static char *ip6_compressed_string(char *p, const struct in6_addr *addr) +static char *ip6_compressed_string(char *p, const char *addr)  {  	int i;  	int j; @@ -683,7 +683,12 @@ static char *ip6_compressed_string(char *p, const struct in6_addr *addr)  	u8 hi;  	u8 lo;  	bool needcolon = false; -	bool useIPv4 = ipv6_addr_v4mapped(addr) || ipv6_addr_is_isatap(addr); +	bool useIPv4; +	struct in6_addr in6; + +	memcpy(&in6, addr, sizeof(struct in6_addr)); + +	useIPv4 = ipv6_addr_v4mapped(&in6) || ipv6_addr_is_isatap(&in6);  	memset(zerolength, 0, sizeof(zerolength)); @@ -695,7 +700,7 @@ static char *ip6_compressed_string(char *p, const struct in6_addr *addr)  	/* find position of longest 0 run */  	for (i = 0; i < range; i++) {  		for (j = i; j < range; j++) { -			if (addr->s6_addr16[j] != 0) +			if (in6.s6_addr16[j] != 0)  				break;  			zerolength[i]++;  		} @@ -722,7 +727,7 @@ static char *ip6_compressed_string(char *p, const struct in6_addr *addr)  			needcolon = false;  		}  		/* hex u16 without leading 0s */ -		word = ntohs(addr->s6_addr16[i]); +		word = ntohs(in6.s6_addr16[i]);  		hi = word >> 8;  		lo = word & 0xff;  		if (hi) { @@ -741,19 +746,19 @@ static char *ip6_compressed_string(char *p, const struct in6_addr *addr)  	if (useIPv4) {  		if (needcolon)  			*p++ = ':'; -		p = ip4_string(p, &addr->s6_addr[12], false); +		p = ip4_string(p, &in6.s6_addr[12], false);  	}  	*p = '\0';  	return p;  } -static char *ip6_string(char *p, const struct in6_addr *addr, const char *fmt) +static char *ip6_string(char *p, const char *addr, const char *fmt)  {  	int i;  	for (i = 0; i < 8; i++) { -		p = pack_hex_byte(p, addr->s6_addr[2 * i]); -		p = pack_hex_byte(p, addr->s6_addr[2 * i + 1]); +		p = pack_hex_byte(p, *addr++); +		p = pack_hex_byte(p, *addr++);  		if (fmt[0] == 'I' && i != 7)  			*p++ = ':';  	} @@ -768,9 +773,9 @@ static char *ip6_addr_string(char *buf, char *end, const u8 *addr,  	char ip6_addr[sizeof("xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:255.255.255.255")];  	if (fmt[0] == 'I' && fmt[2] == 'c') -		ip6_compressed_string(ip6_addr, (const struct in6_addr *)addr); +		ip6_compressed_string(ip6_addr, addr);  	else -		ip6_string(ip6_addr, (const struct in6_addr *)addr, fmt); +		ip6_string(ip6_addr, addr, fmt);  	return string(buf, end, ip6_addr, spec);  } @@ -794,7 +799,8 @@ static char *ip4_addr_string(char *buf, char *end, const u8 *addr,   *   * - 'F' For symbolic function descriptor pointers with offset   * - 'f' For simple symbolic function names without offset - * - 'S' For symbolic direct pointers + * - 'S' For symbolic direct pointers with offset + * - 's' For symbolic direct pointers without offset   * - 'R' For a struct resource pointer, it prints the range of   *       addresses (not the name nor the flags)   * - 'M' For a 6-byte MAC address, it prints the address in the @@ -822,6 +828,7 @@ static char *pointer(const char *fmt, char *buf, char *end, void *ptr,  	case 'F':  	case 'f':  		ptr = dereference_function_descriptor(ptr); +	case 's':  		/* Fallthrough */  	case 'S':  		return symbol_string(buf, end, ptr, spec, *fmt); @@ -1063,10 +1070,12 @@ qualifier:   * @args: Arguments for the format string   *   * This function follows C99 vsnprintf, but has some extensions: - * %pS output the name of a text symbol + * %pS output the name of a text symbol with offset + * %ps output the name of a text symbol without offset   * %pF output the name of a function pointer with its offset   * %pf output the name of a function pointer without its offset   * %pR output the address range in a struct resource + * %n is ignored   *   * The return value is the number of characters which would   * be generated for the given input, excluding the trailing @@ -1088,13 +1097,8 @@ int vsnprintf(char *buf, size_t size, const char *fmt, va_list args)  	/* Reject out-of-range values early.  Large positive sizes are  	   used for unknown buffer sizes. */ -	if (unlikely((int) size < 0)) { -		/* There can be only one.. */ -		static char warn = 1; -		WARN_ON(warn); -		warn = 0; +	if (WARN_ON_ONCE((int) size < 0))  		return 0; -	}  	str = buf;  	end = buf + size; @@ -1522,11 +1526,7 @@ EXPORT_SYMBOL_GPL(vbin_printf);   * a binary buffer that generated by vbin_printf.   *   * The format follows C99 vsnprintf, but has some extensions: - * %pS output the name of a text symbol - * %pF output the name of a function pointer with its offset - * %pf output the name of a function pointer without its offset - * %pR output the address range in a struct resource - * %n is ignored + *  see vsnprintf comment for details.   *   * The return value is the number of characters which would   * be generated for the given input, excluding the trailing @@ -1544,13 +1544,8 @@ int bstr_printf(char *buf, size_t size, const char *fmt, const u32 *bin_buf)  	struct printf_spec spec = {0}; -	if (unlikely((int) size < 0)) { -		/* There can be only one.. */ -		static char warn = 1; -		WARN_ON(warn); -		warn = 0; +	if (WARN_ON_ONCE((int) size < 0))  		return 0; -	}  	str = buf;  	end = buf + size; @@ -1776,7 +1771,7 @@ int vsscanf(const char * buf, const char * fmt, va_list args)  		 * advance both strings to next white space  		 */  		if (*fmt == '*') { -			while (!isspace(*fmt) && *fmt) +			while (!isspace(*fmt) && *fmt != '%' && *fmt)  				fmt++;  			while (!isspace(*str) && *str)  				str++;  | 
