linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC][PATCH 1/5] lib: add unpack_hex_byte()
@ 2011-09-16 12:50 Mimi Zohar
  2011-09-16 12:50 ` [RFC][PATCH 2/5] lib: add error checking to hex2bin Mimi Zohar
                   ` (5 more replies)
  0 siblings, 6 replies; 31+ messages in thread
From: Mimi Zohar @ 2011-09-16 12:50 UTC (permalink / raw)
  To: linux-security-module
  Cc: Mimi Zohar, Andy Shevchenko, Tetsuo Handa, David Safford,
	Nicholas A. Bellinger, target-devel, linux-kernel

Since converting 2 ascii hex digits into a byte with error checks
is commonly used, we can replace multiple hex_to_bin() calls with
a single call to unpack_hex_byte().

Changelog:
- Error checking added based on Tetsuo Handa's patch.
- Moved the hex2bin code here, making it into a static inline function.
  (Andy Shevchenko's request.)

Signed-off-by: Mimi Zohar <zohar@linux.vnet.ibm.com>
---
 include/linux/kernel.h |   21 +++++++++++++++++++++
 1 files changed, 21 insertions(+), 0 deletions(-)

diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index 46ac9a5..d8ea13b 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -385,6 +385,27 @@ extern int hex_to_bin(char ch);
 extern void hex2bin(u8 *dst, const char *src, size_t count);
 
 /*
+ * unpack_hex_byte - convert 2 asii hex digits into a byte
+ * @byte: binary result
+ * @buf: ascii hexadecimal byte string
+ */
+static inline bool unpack_hex_byte(u8 *byte, const char *buf)
+{
+	int hi, lo;
+
+	hi = hex_to_bin(buf[0]);
+	if (hi < 0)
+		return false;
+
+	lo = hex_to_bin(buf[1]);
+	if (lo < 0)
+		return false;
+
+	*byte = (hi << 4) | lo;
+	return true;
+}
+
+/*
  * General tracing related utility functions - trace_printk(),
  * tracing_on/tracing_off and tracing_start()/tracing_stop
  *
-- 
1.7.3.4


^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [RFC][PATCH 2/5] lib: add error checking to hex2bin
  2011-09-16 12:50 [RFC][PATCH 1/5] lib: add unpack_hex_byte() Mimi Zohar
@ 2011-09-16 12:50 ` Mimi Zohar
  2011-09-16 13:13   ` Andy Shevchenko
  2011-09-19 21:20   ` Andrew Morton
  2011-09-16 12:50 ` [RFC][PATCH 3/5] trusted-keys: check hex2bin result Mimi Zohar
                   ` (4 subsequent siblings)
  5 siblings, 2 replies; 31+ messages in thread
From: Mimi Zohar @ 2011-09-16 12:50 UTC (permalink / raw)
  To: linux-security-module
  Cc: Mimi Zohar, Andy Shevchenko, Tetsuo Handa, David Safford,
	Nicholas A. Bellinger, target-devel, linux-kernel

hex2bin converts a hexadecimal string to its binary representation.
The original version of hex2bin did not do any error checking.  This
patch adds error checking and returns the result.

Changelog:
- use the new unpack_hex_byte()
- add __must_check compiler option (Andy Shevchenko's suggestion)
- change function API to return error checking result
  (based on Tetsuo Handa's initial patch)

Signed-off-by: Mimi Zohar <zohar@linux.vnet.ibm.com>
---
 include/linux/kernel.h |    2 +-
 lib/hexdump.c          |   11 +++++++----
 2 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index d8ea13b..3021e64 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -382,7 +382,7 @@ static inline char *pack_hex_byte(char *buf, u8 byte)
 }
 
 extern int hex_to_bin(char ch);
-extern void hex2bin(u8 *dst, const char *src, size_t count);
+extern bool __must_check hex2bin(u8 *dst, const char *src, size_t count);
 
 /*
  * unpack_hex_byte - convert 2 asii hex digits into a byte
diff --git a/lib/hexdump.c b/lib/hexdump.c
index f5fe6ba..7711095 100644
--- a/lib/hexdump.c
+++ b/lib/hexdump.c
@@ -38,14 +38,17 @@ EXPORT_SYMBOL(hex_to_bin);
  * @dst: binary result
  * @src: ascii hexadecimal string
  * @count: result length
+ *
+ * Returns true on success, false in case of bad input.
  */
-void hex2bin(u8 *dst, const char *src, size_t count)
+bool hex2bin(u8 *dst, const char *src, size_t count)
 {
 	while (count--) {
-		*dst = hex_to_bin(*src++) << 4;
-		*dst += hex_to_bin(*src++);
-		dst++;
+		if (!unpack_hex_byte(dst++, src))
+			return false;
+		src += 2;
 	}
+	return true;
 }
 EXPORT_SYMBOL(hex2bin);
 
-- 
1.7.3.4


^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [RFC][PATCH 3/5] trusted-keys: check hex2bin result
  2011-09-16 12:50 [RFC][PATCH 1/5] lib: add unpack_hex_byte() Mimi Zohar
  2011-09-16 12:50 ` [RFC][PATCH 2/5] lib: add error checking to hex2bin Mimi Zohar
@ 2011-09-16 12:50 ` Mimi Zohar
  2011-09-16 12:50 ` [RFC][PATCH 4/5] encrypted-keys: " Mimi Zohar
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 31+ messages in thread
From: Mimi Zohar @ 2011-09-16 12:50 UTC (permalink / raw)
  To: linux-security-module
  Cc: Tetsuo Handa, Andy Shevchenko, Tetsuo Handa, David Safford,
	Nicholas A. Bellinger, target-devel, linux-kernel, Mimi Zohar

From: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>

For each hex2bin call in trusted keys, check that the ascii hex string is
valid.  On failure, return -EINVAL.

Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Signed-off-by: Mimi Zohar <zohar@linux.vnet.ibm.com>
---
 security/keys/trusted.c |   15 +++++++++++----
 1 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/security/keys/trusted.c b/security/keys/trusted.c
index 0c33e2e..9b847e1 100644
--- a/security/keys/trusted.c
+++ b/security/keys/trusted.c
@@ -779,7 +779,9 @@ static int getoptions(char *c, struct trusted_key_payload *pay,
 			opt->pcrinfo_len = strlen(args[0].from) / 2;
 			if (opt->pcrinfo_len > MAX_PCRINFO_SIZE)
 				return -EINVAL;
-			hex2bin(opt->pcrinfo, args[0].from, opt->pcrinfo_len);
+			if (!hex2bin(opt->pcrinfo, args[0].from,
+				     opt->pcrinfo_len))
+				return -EINVAL;
 			break;
 		case Opt_keyhandle:
 			res = strict_strtoul(args[0].from, 16, &handle);
@@ -791,12 +793,16 @@ static int getoptions(char *c, struct trusted_key_payload *pay,
 		case Opt_keyauth:
 			if (strlen(args[0].from) != 2 * SHA1_DIGEST_SIZE)
 				return -EINVAL;
-			hex2bin(opt->keyauth, args[0].from, SHA1_DIGEST_SIZE);
+			if (!hex2bin(opt->keyauth, args[0].from,
+				     SHA1_DIGEST_SIZE))
+				return -EINVAL;
 			break;
 		case Opt_blobauth:
 			if (strlen(args[0].from) != 2 * SHA1_DIGEST_SIZE)
 				return -EINVAL;
-			hex2bin(opt->blobauth, args[0].from, SHA1_DIGEST_SIZE);
+			if (!hex2bin(opt->blobauth, args[0].from,
+				     SHA1_DIGEST_SIZE))
+				return -EINVAL;
 			break;
 		case Opt_migratable:
 			if (*args[0].from == '0')
@@ -860,7 +866,8 @@ static int datablob_parse(char *datablob, struct trusted_key_payload *p,
 		p->blob_len = strlen(c) / 2;
 		if (p->blob_len > MAX_BLOB_SIZE)
 			return -EINVAL;
-		hex2bin(p->blob, c, p->blob_len);
+		if (!hex2bin(p->blob, c, p->blob_len))
+			return -EINVAL;
 		ret = getoptions(datablob, p, o);
 		if (ret < 0)
 			return ret;
-- 
1.7.3.4


^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [RFC][PATCH 4/5] encrypted-keys: check hex2bin result
  2011-09-16 12:50 [RFC][PATCH 1/5] lib: add unpack_hex_byte() Mimi Zohar
  2011-09-16 12:50 ` [RFC][PATCH 2/5] lib: add error checking to hex2bin Mimi Zohar
  2011-09-16 12:50 ` [RFC][PATCH 3/5] trusted-keys: check hex2bin result Mimi Zohar
@ 2011-09-16 12:50 ` Mimi Zohar
  2011-09-16 12:50 ` [RFC][PATCH 5/5] target: " Mimi Zohar
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 31+ messages in thread
From: Mimi Zohar @ 2011-09-16 12:50 UTC (permalink / raw)
  To: linux-security-module
  Cc: Tetsuo Handa, Andy Shevchenko, Tetsuo Handa, David Safford,
	Nicholas A. Bellinger, target-devel, linux-kernel, Mimi Zohar

From: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>

For each hex2bin call in encrypted keys, check that the ascii hex string
is valid.  On failure, return -EINVAL.

Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Signed-off-by: Mimi Zohar <zohar@linux.vnet.ibm.com>
---
 security/keys/encrypted-keys/encrypted.c |   11 ++++++++---
 1 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/security/keys/encrypted-keys/encrypted.c b/security/keys/encrypted-keys/encrypted.c
index 3f57795..cd654d9 100644
--- a/security/keys/encrypted-keys/encrypted.c
+++ b/security/keys/encrypted-keys/encrypted.c
@@ -667,11 +667,16 @@ static int encrypted_key_decrypt(struct encrypted_key_payload *epayload,
 		return -EINVAL;
 
 	hex_encoded_data = hex_encoded_iv + (2 * ivsize) + 2;
-	hex2bin(epayload->iv, hex_encoded_iv, ivsize);
-	hex2bin(epayload->encrypted_data, hex_encoded_data, encrypted_datalen);
+	if (!hex2bin(epayload->iv, hex_encoded_iv, ivsize))
+		return -EINVAL;
+	if (!hex2bin(epayload->encrypted_data, hex_encoded_data,
+		     encrypted_datalen))
+		return -EINVAL;
 
 	hmac = epayload->format + epayload->datablob_len;
-	hex2bin(hmac, hex_encoded_data + (encrypted_datalen * 2), HASH_SIZE);
+	if (!hex2bin(hmac, hex_encoded_data + (encrypted_datalen * 2),
+		     HASH_SIZE))
+		return -EINVAL;
 
 	mkey = request_master_key(epayload, &master_key, &master_keylen);
 	if (IS_ERR(mkey))
-- 
1.7.3.4


^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [RFC][PATCH 5/5] target: check hex2bin result
  2011-09-16 12:50 [RFC][PATCH 1/5] lib: add unpack_hex_byte() Mimi Zohar
                   ` (2 preceding siblings ...)
  2011-09-16 12:50 ` [RFC][PATCH 4/5] encrypted-keys: " Mimi Zohar
@ 2011-09-16 12:50 ` Mimi Zohar
  2011-09-16 14:07   ` Tetsuo Handa
  2011-09-16 13:11 ` [RFC][PATCH 1/5] lib: add unpack_hex_byte() Andy Shevchenko
  2011-09-19 21:19 ` Andrew Morton
  5 siblings, 1 reply; 31+ messages in thread
From: Mimi Zohar @ 2011-09-16 12:50 UTC (permalink / raw)
  To: linux-security-module
  Cc: Mimi Zohar, Andy Shevchenko, Tetsuo Handa, David Safford,
	Nicholas A. Bellinger, target-devel, linux-kernel

Now that hex2bin does error checking, on error add debugging error msg.

Signed-off-by: Mimi Zohar <zohar@linux.vnet.ibm.com>
---
 drivers/target/target_core_cdb.c        |    5 ++++-
 drivers/target/target_core_fabric_lib.c |   11 +++++++++--
 2 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/drivers/target/target_core_cdb.c b/drivers/target/target_core_cdb.c
index 8ae09a1..004f6b1 100644
--- a/drivers/target/target_core_cdb.c
+++ b/drivers/target/target_core_cdb.c
@@ -167,6 +167,7 @@ target_emulate_evpd_83(struct se_cmd *cmd, unsigned char *buf)
 	u32 prod_len;
 	u32 unit_serial_len, off = 0;
 	u16 len = 0, id_len;
+	bool ret;
 
 	off = 4;
 
@@ -215,7 +216,9 @@ target_emulate_evpd_83(struct se_cmd *cmd, unsigned char *buf)
 	 * VENDOR_SPECIFIC_IDENTIFIER_EXTENTION
 	 */
 	buf[off++] |= hex_to_bin(dev->se_sub_dev->t10_wwn.unit_serial[0]);
-	hex2bin(&buf[off], &dev->se_sub_dev->t10_wwn.unit_serial[1], 12);
+	ret = hex2bin(&buf[off], &dev->se_sub_dev->t10_wwn.unit_serial[1], 12);
+	if (!ret)
+		pr_debug("unit_serial: invalid hex string\n");
 
 	len = 20;
 	off = (len + 4);
diff --git a/drivers/target/target_core_fabric_lib.c b/drivers/target/target_core_fabric_lib.c
index c4ea3a9..aa31452 100644
--- a/drivers/target/target_core_fabric_lib.c
+++ b/drivers/target/target_core_fabric_lib.c
@@ -63,6 +63,7 @@ u32 sas_get_pr_transport_id(
 	unsigned char *buf)
 {
 	unsigned char *ptr;
+	bool ret;
 
 	/*
 	 * Set PROTOCOL IDENTIFIER to 6h for SAS
@@ -74,7 +75,9 @@ u32 sas_get_pr_transport_id(
 	 */
 	ptr = &se_nacl->initiatorname[4]; /* Skip over 'naa. prefix */
 
-	hex2bin(&buf[4], ptr, 8);
+	ret = hex2bin(&buf[4], ptr, 8);
+	if (!ret)
+		pr_debug("sas transport_id: invalid hex string\n");
 
 	/*
 	 * The SAS Transport ID is a hardcoded 24-byte length
@@ -158,6 +161,8 @@ u32 fc_get_pr_transport_id(
 	unsigned char *ptr;
 	int i;
 	u32 off = 8;
+	bool ret;
+
 	/*
 	 * PROTOCOL IDENTIFIER is 0h for FCP-2
 	 *
@@ -174,7 +179,9 @@ u32 fc_get_pr_transport_id(
 			i++;
 			continue;
 		}
-		hex2bin(&buf[off++], &ptr[i], 1);
+		ret = unpack_hex_byte(&buf[off++], &ptr[i]);
+		if (!ret)
+			pr_debug("fc transport_id: invalid hex string\n");
 		i += 2;
 	}
 	/*
-- 
1.7.3.4


^ permalink raw reply related	[flat|nested] 31+ messages in thread

* Re: [RFC][PATCH 1/5] lib: add unpack_hex_byte()
  2011-09-16 12:50 [RFC][PATCH 1/5] lib: add unpack_hex_byte() Mimi Zohar
                   ` (3 preceding siblings ...)
  2011-09-16 12:50 ` [RFC][PATCH 5/5] target: " Mimi Zohar
@ 2011-09-16 13:11 ` Andy Shevchenko
  2011-09-19 21:19 ` Andrew Morton
  5 siblings, 0 replies; 31+ messages in thread
From: Andy Shevchenko @ 2011-09-16 13:11 UTC (permalink / raw)
  To: Mimi Zohar
  Cc: linux-security-module, Tetsuo Handa, David Safford,
	Nicholas A. Bellinger, target-devel, linux-kernel

On Fri, Sep 16, 2011 at 3:50 PM, Mimi Zohar <zohar@linux.vnet.ibm.com> wrote:
> Since converting 2 ascii hex digits into a byte with error checks
> is commonly used, we can replace multiple hex_to_bin() calls with
> a single call to unpack_hex_byte().
>
> Changelog:
> - Error checking added based on Tetsuo Handa's patch.
> - Moved the hex2bin code here, making it into a static inline function.
>  (Andy Shevchenko's request.)
>
> Signed-off-by: Mimi Zohar <zohar@linux.vnet.ibm.com>
> ---
>  include/linux/kernel.h |   21 +++++++++++++++++++++
>  1 files changed, 21 insertions(+), 0 deletions(-)
>
> diff --git a/include/linux/kernel.h b/include/linux/kernel.h
> index 46ac9a5..d8ea13b 100644
> --- a/include/linux/kernel.h
> +++ b/include/linux/kernel.h
> @@ -385,6 +385,27 @@ extern int hex_to_bin(char ch);
>  extern void hex2bin(u8 *dst, const char *src, size_t count);
>
>  /*
> + * unpack_hex_byte - convert 2 asii hex digits into a byte
> + * @byte: binary result
> + * @buf: ascii hexadecimal byte string
> + */
> +static inline bool unpack_hex_byte(u8 *byte, const char *buf)
> +{
> +       int hi, lo;
> +
> +       hi = hex_to_bin(buf[0]);
> +       if (hi < 0)
> +               return false;
> +
> +       lo = hex_to_bin(buf[1]);
> +       if (lo < 0)
> +               return false;
> +
> +       *byte = (hi << 4) | lo;
> +       return true;
> +}
> +
> +/*
>  * General tracing related utility functions - trace_printk(),
>  * tracing_on/tracing_off and tracing_start()/tracing_stop
>  *

Acked-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

-- 
With Best Regards,
Andy Shevchenko

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [RFC][PATCH 2/5] lib: add error checking to hex2bin
  2011-09-16 12:50 ` [RFC][PATCH 2/5] lib: add error checking to hex2bin Mimi Zohar
@ 2011-09-16 13:13   ` Andy Shevchenko
  2011-09-19 21:20   ` Andrew Morton
  1 sibling, 0 replies; 31+ messages in thread
From: Andy Shevchenko @ 2011-09-16 13:13 UTC (permalink / raw)
  To: Mimi Zohar
  Cc: linux-security-module, Tetsuo Handa, David Safford,
	Nicholas A. Bellinger, target-devel, linux-kernel

On Fri, Sep 16, 2011 at 3:50 PM, Mimi Zohar <zohar@linux.vnet.ibm.com> wrote:
> hex2bin converts a hexadecimal string to its binary representation.
> The original version of hex2bin did not do any error checking.  This
> patch adds error checking and returns the result.
>
> Changelog:
> - use the new unpack_hex_byte()
> - add __must_check compiler option (Andy Shevchenko's suggestion)
> - change function API to return error checking result
>  (based on Tetsuo Handa's initial patch)
>
> Signed-off-by: Mimi Zohar <zohar@linux.vnet.ibm.com>
> ---
>  include/linux/kernel.h |    2 +-
>  lib/hexdump.c          |   11 +++++++----
>  2 files changed, 8 insertions(+), 5 deletions(-)
>
> diff --git a/include/linux/kernel.h b/include/linux/kernel.h
> index d8ea13b..3021e64 100644
> --- a/include/linux/kernel.h
> +++ b/include/linux/kernel.h
> @@ -382,7 +382,7 @@ static inline char *pack_hex_byte(char *buf, u8 byte)
>  }
>
>  extern int hex_to_bin(char ch);
> -extern void hex2bin(u8 *dst, const char *src, size_t count);
> +extern bool __must_check hex2bin(u8 *dst, const char *src, size_t count);
>
>  /*
>  * unpack_hex_byte - convert 2 asii hex digits into a byte
> diff --git a/lib/hexdump.c b/lib/hexdump.c
> index f5fe6ba..7711095 100644
> --- a/lib/hexdump.c
> +++ b/lib/hexdump.c
> @@ -38,14 +38,17 @@ EXPORT_SYMBOL(hex_to_bin);
>  * @dst: binary result
>  * @src: ascii hexadecimal string
>  * @count: result length
> + *
> + * Returns true on success, false in case of bad input.
>  */
> -void hex2bin(u8 *dst, const char *src, size_t count)
> +bool hex2bin(u8 *dst, const char *src, size_t count)
>  {
>        while (count--) {
> -               *dst = hex_to_bin(*src++) << 4;
> -               *dst += hex_to_bin(*src++);
> -               dst++;
> +               if (!unpack_hex_byte(dst++, src))
> +                       return false;
> +               src += 2;
>        }
> +       return true;
>  }
>  EXPORT_SYMBOL(hex2bin);
>

Acked-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

-- 
With Best Regards,
Andy Shevchenko

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [RFC][PATCH 5/5] target: check hex2bin result
  2011-09-16 12:50 ` [RFC][PATCH 5/5] target: " Mimi Zohar
@ 2011-09-16 14:07   ` Tetsuo Handa
  2011-09-16 20:21     ` Nicholas A. Bellinger
  0 siblings, 1 reply; 31+ messages in thread
From: Tetsuo Handa @ 2011-09-16 14:07 UTC (permalink / raw)
  To: nab; +Cc: zohar, andy.shevchenko, safford, target-devel, linux-kernel

Mimi Zohar wrote:
> Now that hex2bin does error checking, on error add debugging error msg.

We are waiting for response from Nicholas, aren't we?
Quotuing from http://www.spinics.net/linux/fedora/linux-security-module/msg11570.html :
| I was assuming that, by adding error check, hex2bin() will leave the buffer
| uninitialized in case of bad input because hex2bin() user in Linux 3.0 can
| return errors. Now you are a new user of hex2bin() but your code cannot return
| errors. Nicholas, how do you want to handle bad input?

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [RFC][PATCH 5/5] target: check hex2bin result
  2011-09-16 14:07   ` Tetsuo Handa
@ 2011-09-16 20:21     ` Nicholas A. Bellinger
  2011-09-19 11:19       ` Mimi Zohar
  0 siblings, 1 reply; 31+ messages in thread
From: Nicholas A. Bellinger @ 2011-09-16 20:21 UTC (permalink / raw)
  To: Tetsuo Handa; +Cc: zohar, andy.shevchenko, safford, target-devel, linux-kernel

On Fri, 2011-09-16 at 23:07 +0900, Tetsuo Handa wrote:
> Mimi Zohar wrote:
> > Now that hex2bin does error checking, on error add debugging error msg.
> 
> We are waiting for response from Nicholas, aren't we?
> Quotuing from http://www.spinics.net/linux/fedora/linux-security-module/msg11570.html :
> | I was assuming that, by adding error check, hex2bin() will leave the buffer
> | uninitialized in case of bad input because hex2bin() user in Linux 3.0 can
> | return errors. Now you are a new user of hex2bin() but your code cannot return
> | errors. Nicholas, how do you want to handle bad input?

Hi Folks,

There is another patch queued for v3.1-final to ensure that non hex
characters are skipped in target_emulate_evpd_83() when building the NAA
IEEE Registered Extended designator.

[PATCH-v2] target: Skip non hex characters for VPD=0x83 NAA IEEE Registered Extended
http://www.spinics.net/lists/target-devel/msg00607.html

Other than dropping this part from Mimi's patch, the two other warning
messages on conversion failure are OK in target_core_fabric_lib.c code.

I'm happy to queue a modified version of this one for v3.2.

--nab





^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [RFC][PATCH 5/5] target: check hex2bin result
  2011-09-16 20:21     ` Nicholas A. Bellinger
@ 2011-09-19 11:19       ` Mimi Zohar
  0 siblings, 0 replies; 31+ messages in thread
From: Mimi Zohar @ 2011-09-19 11:19 UTC (permalink / raw)
  To: Nicholas A. Bellinger
  Cc: Tetsuo Handa, andy.shevchenko, safford, target-devel, linux-kernel

On Fri, 2011-09-16 at 13:21 -0700, Nicholas A. Bellinger wrote: 
> On Fri, 2011-09-16 at 23:07 +0900, Tetsuo Handa wrote:
> > Mimi Zohar wrote:
> > > Now that hex2bin does error checking, on error add debugging error msg.
> > 
> > We are waiting for response from Nicholas, aren't we?
> > Quotuing from http://www.spinics.net/linux/fedora/linux-security-module/msg11570.html :
> > | I was assuming that, by adding error check, hex2bin() will leave the buffer
> > | uninitialized in case of bad input because hex2bin() user in Linux 3.0 can
> > | return errors. Now you are a new user of hex2bin() but your code cannot return
> > | errors. Nicholas, how do you want to handle bad input?
> 
> Hi Folks,
> 
> There is another patch queued for v3.1-final to ensure that non hex
> characters are skipped in target_emulate_evpd_83() when building the NAA
> IEEE Registered Extended designator.
> 
> [PATCH-v2] target: Skip non hex characters for VPD=0x83 NAA IEEE Registered Extended
> http://www.spinics.net/lists/target-devel/msg00607.html

Yes, I see.  Nice to have linux-next back.

> Other than dropping this part from Mimi's patch, the two other warning
> messages on conversion failure are OK in target_core_fabric_lib.c code.
> 
> I'm happy to queue a modified version of this one for v3.2.
> 
> --nab

thanks!

Mimi 


^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [RFC][PATCH 1/5] lib: add unpack_hex_byte()
  2011-09-16 12:50 [RFC][PATCH 1/5] lib: add unpack_hex_byte() Mimi Zohar
                   ` (4 preceding siblings ...)
  2011-09-16 13:11 ` [RFC][PATCH 1/5] lib: add unpack_hex_byte() Andy Shevchenko
@ 2011-09-19 21:19 ` Andrew Morton
  2011-09-19 22:35   ` Mimi Zohar
  5 siblings, 1 reply; 31+ messages in thread
From: Andrew Morton @ 2011-09-19 21:19 UTC (permalink / raw)
  To: Mimi Zohar
  Cc: linux-security-module, Andy Shevchenko, Tetsuo Handa,
	David Safford, Nicholas A. Bellinger, target-devel, linux-kernel,
	Andrew Morton

On Fri, 16 Sep 2011 08:50:26 -0400
Mimi Zohar <zohar@linux.vnet.ibm.com> wrote:

> Since converting 2 ascii hex digits into a byte with error checks
> is commonly used, we can replace multiple hex_to_bin() calls with
> a single call to unpack_hex_byte().
> 
> Changelog:
> - Error checking added based on Tetsuo Handa's patch.
> - Moved the hex2bin code here, making it into a static inline function.
>   (Andy Shevchenko's request.)

Why, on earth?  Not for performance reasons - the code is already quite
inefficient.

> Signed-off-by: Mimi Zohar <zohar@linux.vnet.ibm.com>
> ---
>  include/linux/kernel.h |   21 +++++++++++++++++++++
>  1 files changed, 21 insertions(+), 0 deletions(-)
> 
> diff --git a/include/linux/kernel.h b/include/linux/kernel.h
> index 46ac9a5..d8ea13b 100644
> --- a/include/linux/kernel.h
> +++ b/include/linux/kernel.h
> @@ -385,6 +385,27 @@ extern int hex_to_bin(char ch);
>  extern void hex2bin(u8 *dst, const char *src, size_t count);
>  
>  /*
> + * unpack_hex_byte - convert 2 asii hex digits into a byte
> + * @byte: binary result
> + * @buf: ascii hexadecimal byte string
> + */
> +static inline bool unpack_hex_byte(u8 *byte, const char *buf)
> +{
> +	int hi, lo;
> +
> +	hi = hex_to_bin(buf[0]);
> +	if (hi < 0)
> +		return false;
> +
> +	lo = hex_to_bin(buf[1]);
> +	if (lo < 0)
> +		return false;
> +
> +	*byte = (hi << 4) | lo;
> +	return true;
> +}

Putting the return value into *byte is inefficient too - it forces the
compiler to place the return value into addressible storage (ie: into a
stack temporary).  Maybe the compiler can avoid doing that if the code
is inlined, but the code shouldn't be inlined :(

The return value is undocumented.

Why not copy the hex2bin return value semantics rather than creating a
new scheme?  Returning "bool false" in response to an error is very
unconventional and unexpected.  Kernel code returns a negative value on
error.

Wouldn't it be better to fix hex2bin() so that it returns -1 on error? 
Then the above function becomes a one-liner:

	return hex2bin(dst, src, 2);

Finally, the name is poor.  It starts with "unpack_", so it belongs to
the "unpack" subsystem.  There's no such thing.  Something like
hex_byte_to_bin() would be better.



^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [RFC][PATCH 2/5] lib: add error checking to hex2bin
  2011-09-16 12:50 ` [RFC][PATCH 2/5] lib: add error checking to hex2bin Mimi Zohar
  2011-09-16 13:13   ` Andy Shevchenko
@ 2011-09-19 21:20   ` Andrew Morton
  1 sibling, 0 replies; 31+ messages in thread
From: Andrew Morton @ 2011-09-19 21:20 UTC (permalink / raw)
  To: Mimi Zohar
  Cc: linux-security-module, Andy Shevchenko, Tetsuo Handa,
	David Safford, Nicholas A. Bellinger, target-devel, linux-kernel,
	Andrew Morton

On Fri, 16 Sep 2011 08:50:27 -0400
Mimi Zohar <zohar@linux.vnet.ibm.com> wrote:

> --- a/lib/hexdump.c
> +++ b/lib/hexdump.c
> @@ -38,14 +38,17 @@ EXPORT_SYMBOL(hex_to_bin);
>   * @dst: binary result
>   * @src: ascii hexadecimal string
>   * @count: result length
> + *
> + * Returns true on success, false in case of bad input.
>   */
> -void hex2bin(u8 *dst, const char *src, size_t count)
> +bool hex2bin(u8 *dst, const char *src, size_t count)
>  {
>  	while (count--) {
> -		*dst = hex_to_bin(*src++) << 4;
> -		*dst += hex_to_bin(*src++);
> -		dst++;
> +		if (!unpack_hex_byte(dst++, src))
> +			return false;
> +		src += 2;
>  	}
> +	return true;
>  }
>  EXPORT_SYMBOL(hex2bin);

Again, this is very unconventional for kernel code, and it's for no good
reason.  Please, stick with 0/-1 unless there's a good reason to diverge
from that.

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [RFC][PATCH 1/5] lib: add unpack_hex_byte()
  2011-09-19 21:19 ` Andrew Morton
@ 2011-09-19 22:35   ` Mimi Zohar
  2011-09-19 22:38     ` Andrew Morton
  0 siblings, 1 reply; 31+ messages in thread
From: Mimi Zohar @ 2011-09-19 22:35 UTC (permalink / raw)
  To: Andrew Morton
  Cc: linux-security-module, Andy Shevchenko, Tetsuo Handa,
	David Safford, Nicholas A. Bellinger, target-devel, linux-kernel,
	Andrew Morton

On Mon, 2011-09-19 at 14:19 -0700, Andrew Morton wrote:
> On Fri, 16 Sep 2011 08:50:26 -0400
> Mimi Zohar <zohar@linux.vnet.ibm.com> wrote:
> 
> > Since converting 2 ascii hex digits into a byte with error checks
> > is commonly used, we can replace multiple hex_to_bin() calls with
> > a single call to unpack_hex_byte().
> > 
> > Changelog:
> > - Error checking added based on Tetsuo Handa's patch.
> > - Moved the hex2bin code here, making it into a static inline function.
> >   (Andy Shevchenko's request.)
> 
> Why, on earth?  Not for performance reasons - the code is already quite
> inefficient.
> 
> > Signed-off-by: Mimi Zohar <zohar@linux.vnet.ibm.com>
> > ---
> >  include/linux/kernel.h |   21 +++++++++++++++++++++
> >  1 files changed, 21 insertions(+), 0 deletions(-)
> > 
> > diff --git a/include/linux/kernel.h b/include/linux/kernel.h
> > index 46ac9a5..d8ea13b 100644
> > --- a/include/linux/kernel.h
> > +++ b/include/linux/kernel.h
> > @@ -385,6 +385,27 @@ extern int hex_to_bin(char ch);
> >  extern void hex2bin(u8 *dst, const char *src, size_t count);
> >  
> >  /*
> > + * unpack_hex_byte - convert 2 asii hex digits into a byte
> > + * @byte: binary result
> > + * @buf: ascii hexadecimal byte string
> > + */
> > +static inline bool unpack_hex_byte(u8 *byte, const char *buf)
> > +{
> > +	int hi, lo;
> > +
> > +	hi = hex_to_bin(buf[0]);
> > +	if (hi < 0)
> > +		return false;
> > +
> > +	lo = hex_to_bin(buf[1]);
> > +	if (lo < 0)
> > +		return false;
> > +
> > +	*byte = (hi << 4) | lo;
> > +	return true;
> > +}
> 
> Putting the return value into *byte is inefficient too - it forces the
> compiler to place the return value into addressible storage (ie: into a
> stack temporary).  Maybe the compiler can avoid doing that if the code
> is inlined, but the code shouldn't be inlined :(

> The return value is undocumented.

Ok, will update.

> Why not copy the hex2bin return value semantics rather than creating a
> new scheme?  Returning "bool false" in response to an error is very
> unconventional and unexpected.  Kernel code returns a negative value on
> error.

ok

> Wouldn't it be better to fix hex2bin() so that it returns -1 on error?

Yes, that was the original idea, but in order to return a result, it
needs to validate the input.  The above code, or something similar,
needs to exist somewhere, either in the new function or in hex2bin().
Would something like this be any better?

int hex2bin(u8 *dst, const char *src, size_t count)
{
	while (count--) {
                int hi = hex_to_bin(*src++);
                int lo = hex_to_bin(*src++);

                if ((hi < 0) || (lo < 0))
                        return -1;

                *dst++ = (hi << 4) | lo;
        }
	return 0;
}


> Then the above function becomes a one-liner:
> 
> 	return hex2bin(dst, src, 2);

Why bother?  With something like this, there isn't a need for the new
function.  :-)

> Finally, the name is poor.  It starts with "unpack_", so it belongs to
> the "unpack" subsystem.  There's no such thing.  Something like
> hex_byte_to_bin() would be better.

agreed.  It was suppose to parallel the existing pack_hex_byte().

Mimi


^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [RFC][PATCH 1/5] lib: add unpack_hex_byte()
  2011-09-19 22:35   ` Mimi Zohar
@ 2011-09-19 22:38     ` Andrew Morton
  2011-09-20  6:04       ` Andy Shevchenko
  0 siblings, 1 reply; 31+ messages in thread
From: Andrew Morton @ 2011-09-19 22:38 UTC (permalink / raw)
  To: Mimi Zohar
  Cc: linux-security-module, Andy Shevchenko, Tetsuo Handa,
	David Safford, Nicholas A. Bellinger, target-devel, linux-kernel,
	Andrew Morton

On Mon, 19 Sep 2011 18:35:08 -0400
Mimi Zohar <zohar@linux.vnet.ibm.com> wrote:

> > Wouldn't it be better to fix hex2bin() so that it returns -1 on error?
> 
> Yes, that was the original idea, but in order to return a result, it
> needs to validate the input.  The above code, or something similar,
> needs to exist somewhere, either in the new function or in hex2bin().
> Would something like this be any better?
> 
> int hex2bin(u8 *dst, const char *src, size_t count)
> {
> 	while (count--) {
>                 int hi = hex_to_bin(*src++);
>                 int lo = hex_to_bin(*src++);
> 
>                 if ((hi < 0) || (lo < 0))
>                         return -1;
> 
>                 *dst++ = (hi << 4) | lo;
>         }
> 	return 0;
> }
> 
> 
> > Then the above function becomes a one-liner:
> > 
> > 	return hex2bin(dst, src, 2);
> 
> Why bother?  With something like this, there isn't a need for the new
> function.  :-)

OK.

> > Finally, the name is poor.  It starts with "unpack_", so it belongs to
> > the "unpack" subsystem.  There's no such thing.  Something like
> > hex_byte_to_bin() would be better.
> 
> agreed.  It was suppose to parallel the existing pack_hex_byte().

hex_byte_pack() :)

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [RFC][PATCH 1/5] lib: add unpack_hex_byte()
  2011-09-19 22:38     ` Andrew Morton
@ 2011-09-20  6:04       ` Andy Shevchenko
  2011-09-20  6:26         ` Andrew Morton
  0 siblings, 1 reply; 31+ messages in thread
From: Andy Shevchenko @ 2011-09-20  6:04 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Mimi Zohar, linux-security-module, Tetsuo Handa, David Safford,
	Nicholas A. Bellinger, target-devel, linux-kernel, Andrew Morton

On Tue, Sep 20, 2011 at 1:38 AM, Andrew Morton <akpm@google.com> wrote:
>> > Finally, the name is poor.  It starts with "unpack_", so it belongs to
>> > the "unpack" subsystem.  There's no such thing.  Something like
>> > hex_byte_to_bin() would be better.
>>
>> agreed.  It was suppose to parallel the existing pack_hex_byte().
>
> hex_byte_pack() :)
Have you just proposed to do mass rename of pack_hex_byte() to the
hex_byte_pack()?

-- 
With Best Regards,
Andy Shevchenko

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [RFC][PATCH 1/5] lib: add unpack_hex_byte()
  2011-09-20  6:04       ` Andy Shevchenko
@ 2011-09-20  6:26         ` Andrew Morton
  2011-09-23 10:47           ` [PATCH 1/2] kernel.h: rename pack_hex_byte to hex_pack_byte Andy Shevchenko
  0 siblings, 1 reply; 31+ messages in thread
From: Andrew Morton @ 2011-09-20  6:26 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Mimi Zohar, linux-security-module, Tetsuo Handa, David Safford,
	Nicholas A. Bellinger, target-devel, linux-kernel, Andrew Morton

On Tue, 20 Sep 2011 09:04:00 +0300 Andy Shevchenko <andy.shevchenko@gmail.com> wrote:

> On Tue, Sep 20, 2011 at 1:38 AM, Andrew Morton <akpm@google.com> wrote:
> >> > Finally, the name is poor. __It starts with "unpack_", so it belongs to
> >> > the "unpack" subsystem. __There's no such thing. __Something like
> >> > hex_byte_to_bin() would be better.
> >>
> >> agreed. __It was suppose to parallel the existing pack_hex_byte().
> >
> > hex_byte_pack() :)
> Have you just proposed to do mass rename of pack_hex_byte() to the
> hex_byte_pack()?

It's very minor, but I suppose we should, if someone feels like it.

We should retain a

char * __deprecated pack_hex_byte(char *buf, u8 byte)
{
	return hex_byte_pack(buf, byte);
}

for a few cycles to minimise harm to out-of-tree code.

^ permalink raw reply	[flat|nested] 31+ messages in thread

* [PATCH 1/2] kernel.h: rename pack_hex_byte to hex_pack_byte
  2011-09-20  6:26         ` Andrew Morton
@ 2011-09-23 10:47           ` Andy Shevchenko
  2011-09-23 10:47             ` [PATCH 2/2] wireless: at76c50x: use native hex_pack_byte() method Andy Shevchenko
  2011-09-23 20:18             ` [PATCH 1/2] kernel.h: rename pack_hex_byte to hex_pack_byte Andrew Morton
  0 siblings, 2 replies; 31+ messages in thread
From: Andy Shevchenko @ 2011-09-23 10:47 UTC (permalink / raw)
  To: linux-kernel; +Cc: Andy Shevchenko, Andrew Morton

As suggested by Andrew Morton in [1] there is better to have most significant
part first in the function name.

[1] https://lkml.org/lkml/2011/9/20/22

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
---
 include/linux/kernel.h |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index 46ac9a5..5022158 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -374,13 +374,18 @@ extern const char hex_asc[];
 #define hex_asc_lo(x)	hex_asc[((x) & 0x0f)]
 #define hex_asc_hi(x)	hex_asc[((x) & 0xf0) >> 4]
 
-static inline char *pack_hex_byte(char *buf, u8 byte)
+static inline char *hex_byte_pack(char *buf, u8 byte)
 {
 	*buf++ = hex_asc_hi(byte);
 	*buf++ = hex_asc_lo(byte);
 	return buf;
 }
 
+static inline char * __deprecated pack_hex_byte(char *buf, u8 byte)
+{
+	return hex_byte_pack(buf, byte);
+}
+
 extern int hex_to_bin(char ch);
 extern void hex2bin(u8 *dst, const char *src, size_t count);
 
-- 
1.7.6.3


^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH 2/2] wireless: at76c50x: use native hex_pack_byte() method
  2011-09-23 10:47           ` [PATCH 1/2] kernel.h: rename pack_hex_byte to hex_pack_byte Andy Shevchenko
@ 2011-09-23 10:47             ` Andy Shevchenko
  2011-09-27 11:51               ` [PATCHv2] " Andy Shevchenko
  2011-09-27 12:01               ` [PATCHv2.1] " Andy Shevchenko
  2011-09-23 20:18             ` [PATCH 1/2] kernel.h: rename pack_hex_byte to hex_pack_byte Andrew Morton
  1 sibling, 2 replies; 31+ messages in thread
From: Andy Shevchenko @ 2011-09-23 10:47 UTC (permalink / raw)
  To: linux-kernel; +Cc: Andy Shevchenko, John W. Linville, linux-wireless, netdev

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: "John W. Linville" <linville@tuxdriver.com>
Cc: linux-wireless@vger.kernel.org
Cc: netdev@vger.kernel.org
---
 drivers/net/wireless/at76c50x-usb.c |    5 +----
 1 files changed, 1 insertions(+), 4 deletions(-)

diff --git a/drivers/net/wireless/at76c50x-usb.c b/drivers/net/wireless/at76c50x-usb.c
index 2986014..157507a6 100644
--- a/drivers/net/wireless/at76c50x-usb.c
+++ b/drivers/net/wireless/at76c50x-usb.c
@@ -500,7 +500,6 @@ exit:
 
 #define HEX2STR_BUFFERS 4
 #define HEX2STR_MAX_LEN 64
-#define BIN2HEX(x) ((x) < 10 ? '0' + (x) : (x) + 'A' - 10)
 
 /* Convert binary data into hex string */
 static char *hex2str(void *buf, int len)
@@ -520,10 +519,8 @@ static char *hex2str(void *buf, int len)
 	}
 
 	while (len--) {
-		*obuf++ = BIN2HEX(*ibuf >> 4);
-		*obuf++ = BIN2HEX(*ibuf & 0xf);
+		obuf = hex_pack_byte(obuf, *ibuf++);
 		*obuf++ = '-';
-		ibuf++;
 	}
 	*(--obuf) = '\0';
 
-- 
1.7.6.3


^ permalink raw reply related	[flat|nested] 31+ messages in thread

* Re: [PATCH 1/2] kernel.h: rename pack_hex_byte to hex_pack_byte
  2011-09-23 10:47           ` [PATCH 1/2] kernel.h: rename pack_hex_byte to hex_pack_byte Andy Shevchenko
  2011-09-23 10:47             ` [PATCH 2/2] wireless: at76c50x: use native hex_pack_byte() method Andy Shevchenko
@ 2011-09-23 20:18             ` Andrew Morton
  2011-09-27 10:51               ` Andy Shevchenko
  1 sibling, 1 reply; 31+ messages in thread
From: Andrew Morton @ 2011-09-23 20:18 UTC (permalink / raw)
  To: Andy Shevchenko; +Cc: linux-kernel

On Fri, 23 Sep 2011 13:47:26 +0300
Andy Shevchenko <andriy.shevchenko@linux.intel.com> wrote:

> As suggested by Andrew Morton in [1] there is better to have most significant
> part first in the function name.
> 
> [1] https://lkml.org/lkml/2011/9/20/22
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> Cc: Andrew Morton <akpm@linux-foundation.org>
> ---
>  include/linux/kernel.h |    7 ++++++-
>  1 files changed, 6 insertions(+), 1 deletions(-)
> 
> diff --git a/include/linux/kernel.h b/include/linux/kernel.h
> index 46ac9a5..5022158 100644
> --- a/include/linux/kernel.h
> +++ b/include/linux/kernel.h
> @@ -374,13 +374,18 @@ extern const char hex_asc[];
>  #define hex_asc_lo(x)	hex_asc[((x) & 0x0f)]
>  #define hex_asc_hi(x)	hex_asc[((x) & 0xf0) >> 4]
>  
> -static inline char *pack_hex_byte(char *buf, u8 byte)
> +static inline char *hex_byte_pack(char *buf, u8 byte)
>  {
>  	*buf++ = hex_asc_hi(byte);
>  	*buf++ = hex_asc_lo(byte);
>  	return buf;
>  }
>  
> +static inline char * __deprecated pack_hex_byte(char *buf, u8 byte)
> +{
> +	return hex_byte_pack(buf, byte);
> +}
> +

err, no thanks.  That's just going to hit everyone with great
screenfuls of compile warnings while waiting for someone else to fix
them up.


^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH 1/2] kernel.h: rename pack_hex_byte to hex_pack_byte
  2011-09-23 20:18             ` [PATCH 1/2] kernel.h: rename pack_hex_byte to hex_pack_byte Andrew Morton
@ 2011-09-27 10:51               ` Andy Shevchenko
  2011-09-27 17:32                 ` Andrew Morton
  0 siblings, 1 reply; 31+ messages in thread
From: Andy Shevchenko @ 2011-09-27 10:51 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Andy Shevchenko, linux-kernel

On Fri, Sep 23, 2011 at 11:18 PM, Andrew Morton <akpm@google.com> wrote:
> err, no thanks.  That's just going to hit everyone with great
> screenfuls of compile warnings while waiting for someone else to fix
> them up.

Okay, what about renaming pack_hex_byte to hex_byte_pack and
introducing temporary macro for backward compatibility?


-- 
With Best Regards,
Andy Shevchenko

^ permalink raw reply	[flat|nested] 31+ messages in thread

* [PATCHv2] wireless: at76c50x: use native hex_pack_byte() method
  2011-09-23 10:47             ` [PATCH 2/2] wireless: at76c50x: use native hex_pack_byte() method Andy Shevchenko
@ 2011-09-27 11:51               ` Andy Shevchenko
  2011-09-27 12:01               ` [PATCHv2.1] " Andy Shevchenko
  1 sibling, 0 replies; 31+ messages in thread
From: Andy Shevchenko @ 2011-09-27 11:51 UTC (permalink / raw)
  To: linux-kernel; +Cc: Andy Shevchenko, John W. Linville, linux-wireless, netdev

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: "John W. Linville" <linville@tuxdriver.com>
Cc: linux-wireless@vger.kernel.org
Cc: netdev@vger.kernel.org
---
 drivers/net/wireless/at76c50x-usb.c |   16 ++++++----------
 1 files changed, 6 insertions(+), 10 deletions(-)

diff --git a/drivers/net/wireless/at76c50x-usb.c b/drivers/net/wireless/at76c50x-usb.c
index 2986014..96daaad 100644
--- a/drivers/net/wireless/at76c50x-usb.c
+++ b/drivers/net/wireless/at76c50x-usb.c
@@ -500,7 +500,6 @@ exit:
 
 #define HEX2STR_BUFFERS 4
 #define HEX2STR_MAX_LEN 64
-#define BIN2HEX(x) ((x) < 10 ? '0' + (x) : (x) + 'A' - 10)
 
 /* Convert binary data into hex string */
 static char *hex2str(void *buf, int len)
@@ -514,18 +513,15 @@ static char *hex2str(void *buf, int len)
 	if (len > HEX2STR_MAX_LEN)
 		len = HEX2STR_MAX_LEN;
 
-	if (len <= 0) {
-		ret[0] = '\0';
-		return ret;
-	}
-
 	while (len--) {
-		*obuf++ = BIN2HEX(*ibuf >> 4);
-		*obuf++ = BIN2HEX(*ibuf & 0xf);
+		obuf = pack_hex_byte(obuf, *ibuf++);
 		*obuf++ = '-';
-		ibuf++;
 	}
-	*(--obuf) = '\0';
+
+	if (*obuf == '-')
+		obuf--;
+
+	*obuf = '\0';
 
 	return ret;
 }
-- 
1.7.6.3


^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCHv2.1] wireless: at76c50x: use native hex_pack_byte() method
  2011-09-23 10:47             ` [PATCH 2/2] wireless: at76c50x: use native hex_pack_byte() method Andy Shevchenko
  2011-09-27 11:51               ` [PATCHv2] " Andy Shevchenko
@ 2011-09-27 12:01               ` Andy Shevchenko
  1 sibling, 0 replies; 31+ messages in thread
From: Andy Shevchenko @ 2011-09-27 12:01 UTC (permalink / raw)
  To: linux-kernel; +Cc: Andy Shevchenko, John W. Linville, linux-wireless, netdev

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: "John W. Linville" <linville@tuxdriver.com>
Cc: linux-wireless@vger.kernel.org
Cc: netdev@vger.kernel.org
---
 drivers/net/wireless/at76c50x-usb.c |   18 +++++++-----------
 1 files changed, 7 insertions(+), 11 deletions(-)

diff --git a/drivers/net/wireless/at76c50x-usb.c b/drivers/net/wireless/at76c50x-usb.c
index 2986014..2dde5f6 100644
--- a/drivers/net/wireless/at76c50x-usb.c
+++ b/drivers/net/wireless/at76c50x-usb.c
@@ -500,10 +500,9 @@ exit:
 
 #define HEX2STR_BUFFERS 4
 #define HEX2STR_MAX_LEN 64
-#define BIN2HEX(x) ((x) < 10 ? '0' + (x) : (x) + 'A' - 10)
 
 /* Convert binary data into hex string */
-static char *hex2str(void *buf, int len)
+static char *hex2str(void *buf, size_t len)
 {
 	static atomic_t a = ATOMIC_INIT(0);
 	static char bufs[HEX2STR_BUFFERS][3 * HEX2STR_MAX_LEN + 1];
@@ -514,18 +513,15 @@ static char *hex2str(void *buf, int len)
 	if (len > HEX2STR_MAX_LEN)
 		len = HEX2STR_MAX_LEN;
 
-	if (len <= 0) {
-		ret[0] = '\0';
-		return ret;
-	}
-
 	while (len--) {
-		*obuf++ = BIN2HEX(*ibuf >> 4);
-		*obuf++ = BIN2HEX(*ibuf & 0xf);
+		obuf = pack_hex_byte(obuf, *ibuf++);
 		*obuf++ = '-';
-		ibuf++;
 	}
-	*(--obuf) = '\0';
+
+	if (*obuf == '-')
+		obuf--;
+
+	*obuf = '\0';
 
 	return ret;
 }
-- 
1.7.6.3


^ permalink raw reply related	[flat|nested] 31+ messages in thread

* Re: [PATCH 1/2] kernel.h: rename pack_hex_byte to hex_pack_byte
  2011-09-27 10:51               ` Andy Shevchenko
@ 2011-09-27 17:32                 ` Andrew Morton
  2011-10-10 14:33                   ` [PATCHv2 1/5] lib: rename pack_hex_byte to hex_byte_pack Andy Shevchenko
  0 siblings, 1 reply; 31+ messages in thread
From: Andrew Morton @ 2011-09-27 17:32 UTC (permalink / raw)
  To: Andy Shevchenko; +Cc: Andy Shevchenko, linux-kernel, Andrew Morton

On Tue, Sep 27, 2011 at 3:51 AM, Andy Shevchenko
<andy.shevchenko@gmail.com> wrote:
> On Fri, Sep 23, 2011 at 11:18 PM, Andrew Morton <akpm@google.com> wrote:
>> err, no thanks.  That's just going to hit everyone with great
>> screenfuls of compile warnings while waiting for someone else to fix
>> them up.
>
> Okay, what about renaming pack_hex_byte to hex_byte_pack and
> introducing temporary macro for backward compatibility?

It's better to convert all the in-kernel call sites at the same time
as adding the
__deprecated tag to the old function.

^ permalink raw reply	[flat|nested] 31+ messages in thread

* [PATCHv2 1/5] lib: rename pack_hex_byte to hex_byte_pack
  2011-09-27 17:32                 ` Andrew Morton
@ 2011-10-10 14:33                   ` Andy Shevchenko
  2011-10-10 14:33                     ` [PATCHv2 2/5] kgdb: follow " Andy Shevchenko
                                       ` (3 more replies)
  0 siblings, 4 replies; 31+ messages in thread
From: Andy Shevchenko @ 2011-10-10 14:33 UTC (permalink / raw)
  To: Andrew Morton, linux-kernel; +Cc: Andy Shevchenko

As suggested by Andrew Morton in [1] there is better to have most significant
part first in the function name.

[1] https://lkml.org/lkml/2011/9/20/22

There is no functional change.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 include/linux/kernel.h |    7 ++++++-
 lib/vsprintf.c         |   14 +++++++-------
 2 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index a10ed77..4c0d3b2 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -376,13 +376,18 @@ extern const char hex_asc[];
 #define hex_asc_lo(x)	hex_asc[((x) & 0x0f)]
 #define hex_asc_hi(x)	hex_asc[((x) & 0xf0) >> 4]
 
-static inline char *pack_hex_byte(char *buf, u8 byte)
+static inline char *hex_byte_pack(char *buf, u8 byte)
 {
 	*buf++ = hex_asc_hi(byte);
 	*buf++ = hex_asc_lo(byte);
 	return buf;
 }
 
+static inline char * __deprecated pack_hex_byte(char *buf, u8 byte)
+{
+	return hex_byte_pack(buf, byte);
+}
+
 extern int hex_to_bin(char ch);
 extern int __must_check hex2bin(u8 *dst, const char *src, size_t count);
 
diff --git a/lib/vsprintf.c b/lib/vsprintf.c
index c1a3927..993599e 100644
--- a/lib/vsprintf.c
+++ b/lib/vsprintf.c
@@ -547,7 +547,7 @@ char *mac_address_string(char *buf, char *end, u8 *addr,
 	}
 
 	for (i = 0; i < 6; i++) {
-		p = pack_hex_byte(p, addr[i]);
+		p = hex_byte_pack(p, addr[i]);
 		if (fmt[0] == 'M' && i != 5)
 			*p++ = separator;
 	}
@@ -667,13 +667,13 @@ char *ip6_compressed_string(char *p, const char *addr)
 		lo = word & 0xff;
 		if (hi) {
 			if (hi > 0x0f)
-				p = pack_hex_byte(p, hi);
+				p = hex_byte_pack(p, hi);
 			else
 				*p++ = hex_asc_lo(hi);
-			p = pack_hex_byte(p, lo);
+			p = hex_byte_pack(p, lo);
 		}
 		else if (lo > 0x0f)
-			p = pack_hex_byte(p, lo);
+			p = hex_byte_pack(p, lo);
 		else
 			*p++ = hex_asc_lo(lo);
 		needcolon = true;
@@ -695,8 +695,8 @@ 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++);
-		p = pack_hex_byte(p, *addr++);
+		p = hex_byte_pack(p, *addr++);
+		p = hex_byte_pack(p, *addr++);
 		if (fmt[0] == 'I' && i != 7)
 			*p++ = ':';
 	}
@@ -754,7 +754,7 @@ char *uuid_string(char *buf, char *end, const u8 *addr,
 	}
 
 	for (i = 0; i < 16; i++) {
-		p = pack_hex_byte(p, addr[index[i]]);
+		p = hex_byte_pack(p, addr[index[i]]);
 		switch (i) {
 		case 3:
 		case 5:
-- 
1.7.6.3


^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCHv2 2/5] kgdb: follow rename pack_hex_byte to hex_byte_pack
  2011-10-10 14:33                   ` [PATCHv2 1/5] lib: rename pack_hex_byte to hex_byte_pack Andy Shevchenko
@ 2011-10-10 14:33                     ` Andy Shevchenko
  2011-10-10 14:55                       ` Jesper Nilsson
  2011-10-10 14:33                     ` [PATCHv2 3/5] security: " Andy Shevchenko
                                       ` (2 subsequent siblings)
  3 siblings, 1 reply; 31+ messages in thread
From: Andy Shevchenko @ 2011-10-10 14:33 UTC (permalink / raw)
  To: Andrew Morton, linux-kernel
  Cc: Andy Shevchenko, Jesper Nilsson, David Howells, Koichi Yasutake,
	Jason Wessel, kgdb-bugreport

There is no functional change.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: Jesper Nilsson <jesper.nilsson@axis.com>
Cc: David Howells <dhowells@redhat.com>
Cc: Koichi Yasutake <yasutake.koichi@jp.panasonic.com>
Cc: Jason Wessel <jason.wessel@windriver.com>
Cc: kgdb-bugreport@lists.sourceforge.net
---
 arch/cris/arch-v10/kernel/kgdb.c |    6 ++--
 arch/cris/arch-v32/kernel/kgdb.c |   14 +++++-----
 arch/frv/kernel/gdb-stub.c       |   44 ++++++++++++++++----------------
 arch/mn10300/kernel/gdb-stub.c   |   52 +++++++++++++++++++-------------------
 kernel/debug/gdbstub.c           |   12 ++++----
 5 files changed, 64 insertions(+), 64 deletions(-)

diff --git a/arch/cris/arch-v10/kernel/kgdb.c b/arch/cris/arch-v10/kernel/kgdb.c
index b9f9c8c..b579dd0 100644
--- a/arch/cris/arch-v10/kernel/kgdb.c
+++ b/arch/cris/arch-v10/kernel/kgdb.c
@@ -694,7 +694,7 @@ mem2hex(char *buf, unsigned char *mem, int count)
                 /* Valid mem address. */
                 for (i = 0; i < count; i++) {
                         ch = *mem++;
-			buf = pack_hex_byte(buf, ch);
+			buf = hex_byte_pack(buf, ch);
                 }
         }
         
@@ -868,7 +868,7 @@ stub_is_stopped(int sigval)
 	/* Send trap type (converted to signal) */
 
 	*ptr++ = 'T';
-	ptr = pack_hex_byte(ptr, sigval);
+	ptr = hex_byte_pack(ptr, sigval);
 
 	/* Send register contents. We probably only need to send the
 	 * PC, frame pointer and stack pointer here. Other registers will be
@@ -881,7 +881,7 @@ stub_is_stopped(int sigval)
                 status = read_register (regno, &reg_cont);
                 
 		if (status == SUCCESS) {
-			ptr = pack_hex_byte(ptr, regno);
+			ptr = hex_byte_pack(ptr, regno);
                         *ptr++ = ':';
 
                         ptr = mem2hex(ptr, (unsigned char *)&reg_cont,
diff --git a/arch/cris/arch-v32/kernel/kgdb.c b/arch/cris/arch-v32/kernel/kgdb.c
index c0343c3..8c1d35c 100644
--- a/arch/cris/arch-v32/kernel/kgdb.c
+++ b/arch/cris/arch-v32/kernel/kgdb.c
@@ -677,7 +677,7 @@ mem2hex(char *buf, unsigned char *mem, int count)
                 /* Valid mem address. */
 		for (i = 0; i < count; i++) {
 			ch = *mem++;
-			buf = pack_hex_byte(buf, ch);
+			buf = hex_byte_pack(buf, ch);
 		}
         }
         /* Terminate properly. */
@@ -695,7 +695,7 @@ mem2hex_nbo(char *buf, unsigned char *mem, int count)
 	mem += count - 1;
 	for (i = 0; i < count; i++) {
 		ch = *mem--;
-		buf = pack_hex_byte(buf, ch);
+		buf = hex_byte_pack(buf, ch);
         }
 
         /* Terminate properly. */
@@ -880,7 +880,7 @@ stub_is_stopped(int sigval)
 	/* Send trap type (converted to signal) */
 
 	*ptr++ = 'T';
-	ptr = pack_hex_byte(ptr, sigval);
+	ptr = hex_byte_pack(ptr, sigval);
 
 	if (((reg.exs & 0xff00) >> 8) == 0xc) {
 
@@ -988,26 +988,26 @@ stub_is_stopped(int sigval)
 	}
 	/* Only send PC, frame and stack pointer. */
 	read_register(PC, &reg_cont);
-	ptr = pack_hex_byte(ptr, PC);
+	ptr = hex_byte_pack(ptr, PC);
 	*ptr++ = ':';
 	ptr = mem2hex(ptr, (unsigned char *)&reg_cont, register_size[PC]);
 	*ptr++ = ';';
 
 	read_register(R8, &reg_cont);
-	ptr = pack_hex_byte(ptr, R8);
+	ptr = hex_byte_pack(ptr, R8);
 	*ptr++ = ':';
 	ptr = mem2hex(ptr, (unsigned char *)&reg_cont, register_size[R8]);
 	*ptr++ = ';';
 
 	read_register(SP, &reg_cont);
-	ptr = pack_hex_byte(ptr, SP);
+	ptr = hex_byte_pack(ptr, SP);
 	*ptr++ = ':';
 	ptr = mem2hex(ptr, (unsigned char *)&reg_cont, register_size[SP]);
 	*ptr++ = ';';
 
 	/* Send ERP as well; this will save us an entire register fetch in some cases. */
         read_register(ERP, &reg_cont);
-	ptr = pack_hex_byte(ptr, ERP);
+	ptr = hex_byte_pack(ptr, ERP);
         *ptr++ = ':';
         ptr = mem2hex(ptr, (unsigned char *)&reg_cont, register_size[ERP]);
         *ptr++ = ';';
diff --git a/arch/frv/kernel/gdb-stub.c b/arch/frv/kernel/gdb-stub.c
index a4dba6b..a6d5381 100644
--- a/arch/frv/kernel/gdb-stub.c
+++ b/arch/frv/kernel/gdb-stub.c
@@ -672,7 +672,7 @@ static unsigned char *mem2hex(const void *_mem, char *buf, int count, int may_fa
 	if ((uint32_t)mem&1 && count>=1) {
 		if (!gdbstub_read_byte(mem,ch))
 			return NULL;
-		buf = pack_hex_byte(buf, ch[0]);
+		buf = hex_byte_pack(buf, ch[0]);
 		mem++;
 		count--;
 	}
@@ -680,8 +680,8 @@ static unsigned char *mem2hex(const void *_mem, char *buf, int count, int may_fa
 	if ((uint32_t)mem&3 && count>=2) {
 		if (!gdbstub_read_word(mem,(uint16_t *)ch))
 			return NULL;
-		buf = pack_hex_byte(buf, ch[0]);
-		buf = pack_hex_byte(buf, ch[1]);
+		buf = hex_byte_pack(buf, ch[0]);
+		buf = hex_byte_pack(buf, ch[1]);
 		mem += 2;
 		count -= 2;
 	}
@@ -689,10 +689,10 @@ static unsigned char *mem2hex(const void *_mem, char *buf, int count, int may_fa
 	while (count>=4) {
 		if (!gdbstub_read_dword(mem,(uint32_t *)ch))
 			return NULL;
-		buf = pack_hex_byte(buf, ch[0]);
-		buf = pack_hex_byte(buf, ch[1]);
-		buf = pack_hex_byte(buf, ch[2]);
-		buf = pack_hex_byte(buf, ch[3]);
+		buf = hex_byte_pack(buf, ch[0]);
+		buf = hex_byte_pack(buf, ch[1]);
+		buf = hex_byte_pack(buf, ch[2]);
+		buf = hex_byte_pack(buf, ch[3]);
 		mem += 4;
 		count -= 4;
 	}
@@ -700,8 +700,8 @@ static unsigned char *mem2hex(const void *_mem, char *buf, int count, int may_fa
 	if (count>=2) {
 		if (!gdbstub_read_word(mem,(uint16_t *)ch))
 			return NULL;
-		buf = pack_hex_byte(buf, ch[0]);
-		buf = pack_hex_byte(buf, ch[1]);
+		buf = hex_byte_pack(buf, ch[0]);
+		buf = hex_byte_pack(buf, ch[1]);
 		mem += 2;
 		count -= 2;
 	}
@@ -709,7 +709,7 @@ static unsigned char *mem2hex(const void *_mem, char *buf, int count, int may_fa
 	if (count>=1) {
 		if (!gdbstub_read_byte(mem,ch))
 			return NULL;
-		buf = pack_hex_byte(buf, ch[0]);
+		buf = hex_byte_pack(buf, ch[0]);
 	}
 
 	*buf = 0;
@@ -1498,21 +1498,21 @@ void gdbstub(int sigval)
 		ptr = mem2hex(title, ptr, sizeof(title) - 1,0);
 
 		hx = hex_asc_hi(brr >> 24);
-		ptr = pack_hex_byte(ptr, hx);
+		ptr = hex_byte_pack(ptr, hx);
 		hx = hex_asc_lo(brr >> 24);
-		ptr = pack_hex_byte(ptr, hx);
+		ptr = hex_byte_pack(ptr, hx);
 		hx = hex_asc_hi(brr >> 16);
-		ptr = pack_hex_byte(ptr, hx);
+		ptr = hex_byte_pack(ptr, hx);
 		hx = hex_asc_lo(brr >> 16);
-		ptr = pack_hex_byte(ptr, hx);
+		ptr = hex_byte_pack(ptr, hx);
 		hx = hex_asc_hi(brr >> 8);
-		ptr = pack_hex_byte(ptr, hx);
+		ptr = hex_byte_pack(ptr, hx);
 		hx = hex_asc_lo(brr >> 8);
-		ptr = pack_hex_byte(ptr, hx);
+		ptr = hex_byte_pack(ptr, hx);
 		hx = hex_asc_hi(brr);
-		ptr = pack_hex_byte(ptr, hx);
+		ptr = hex_byte_pack(ptr, hx);
 		hx = hex_asc_lo(brr);
-		ptr = pack_hex_byte(ptr, hx);
+		ptr = hex_byte_pack(ptr, hx);
 
 		ptr = mem2hex(crlf, ptr, sizeof(crlf) - 1, 0);
 		*ptr = 0;
@@ -1526,10 +1526,10 @@ void gdbstub(int sigval)
 
 	/* Send trap type (converted to signal) */
 	*ptr++ = 'T';
-	ptr = pack_hex_byte(ptr, sigval);
+	ptr = hex_byte_pack(ptr, sigval);
 
 	/* Send Error PC */
-	ptr = pack_hex_byte(ptr, GDB_REG_PC);
+	ptr = hex_byte_pack(ptr, GDB_REG_PC);
 	*ptr++ = ':';
 	ptr = mem2hex(&__debug_frame->pc, ptr, 4, 0);
 	*ptr++ = ';';
@@ -1537,7 +1537,7 @@ void gdbstub(int sigval)
 	/*
 	 * Send frame pointer
 	 */
-	ptr = pack_hex_byte(ptr, GDB_REG_FP);
+	ptr = hex_byte_pack(ptr, GDB_REG_FP);
 	*ptr++ = ':';
 	ptr = mem2hex(&__debug_frame->fp, ptr, 4, 0);
 	*ptr++ = ';';
@@ -1545,7 +1545,7 @@ void gdbstub(int sigval)
 	/*
 	 * Send stack pointer
 	 */
-	ptr = pack_hex_byte(ptr, GDB_REG_SP);
+	ptr = hex_byte_pack(ptr, GDB_REG_SP);
 	*ptr++ = ':';
 	ptr = mem2hex(&__debug_frame->sp, ptr, 4, 0);
 	*ptr++ = ';';
diff --git a/arch/mn10300/kernel/gdb-stub.c b/arch/mn10300/kernel/gdb-stub.c
index 538266b..522eb8a 100644
--- a/arch/mn10300/kernel/gdb-stub.c
+++ b/arch/mn10300/kernel/gdb-stub.c
@@ -798,7 +798,7 @@ unsigned char *mem2hex(const void *_mem, char *buf, int count, int may_fault)
 	if ((u32) mem & 1 && count >= 1) {
 		if (gdbstub_read_byte(mem, ch) != 0)
 			return 0;
-		buf = pack_hex_byte(buf, ch[0]);
+		buf = hex_byte_pack(buf, ch[0]);
 		mem++;
 		count--;
 	}
@@ -806,8 +806,8 @@ unsigned char *mem2hex(const void *_mem, char *buf, int count, int may_fault)
 	if ((u32) mem & 3 && count >= 2) {
 		if (gdbstub_read_word(mem, ch) != 0)
 			return 0;
-		buf = pack_hex_byte(buf, ch[0]);
-		buf = pack_hex_byte(buf, ch[1]);
+		buf = hex_byte_pack(buf, ch[0]);
+		buf = hex_byte_pack(buf, ch[1]);
 		mem += 2;
 		count -= 2;
 	}
@@ -815,10 +815,10 @@ unsigned char *mem2hex(const void *_mem, char *buf, int count, int may_fault)
 	while (count >= 4) {
 		if (gdbstub_read_dword(mem, ch) != 0)
 			return 0;
-		buf = pack_hex_byte(buf, ch[0]);
-		buf = pack_hex_byte(buf, ch[1]);
-		buf = pack_hex_byte(buf, ch[2]);
-		buf = pack_hex_byte(buf, ch[3]);
+		buf = hex_byte_pack(buf, ch[0]);
+		buf = hex_byte_pack(buf, ch[1]);
+		buf = hex_byte_pack(buf, ch[2]);
+		buf = hex_byte_pack(buf, ch[3]);
 		mem += 4;
 		count -= 4;
 	}
@@ -826,8 +826,8 @@ unsigned char *mem2hex(const void *_mem, char *buf, int count, int may_fault)
 	if (count >= 2) {
 		if (gdbstub_read_word(mem, ch) != 0)
 			return 0;
-		buf = pack_hex_byte(buf, ch[0]);
-		buf = pack_hex_byte(buf, ch[1]);
+		buf = hex_byte_pack(buf, ch[0]);
+		buf = hex_byte_pack(buf, ch[1]);
 		mem += 2;
 		count -= 2;
 	}
@@ -835,7 +835,7 @@ unsigned char *mem2hex(const void *_mem, char *buf, int count, int may_fault)
 	if (count >= 1) {
 		if (gdbstub_read_byte(mem, ch) != 0)
 			return 0;
-		buf = pack_hex_byte(buf, ch[0]);
+		buf = hex_byte_pack(buf, ch[0]);
 	}
 
 	*buf = 0;
@@ -1273,13 +1273,13 @@ static int gdbstub(struct pt_regs *regs, enum exception_code excep)
 		ptr = mem2hex(title, ptr, sizeof(title) - 1, 0);
 
 		hx = hex_asc_hi(excep >> 8);
-		ptr = pack_hex_byte(ptr, hx);
+		ptr = hex_byte_pack(ptr, hx);
 		hx = hex_asc_lo(excep >> 8);
-		ptr = pack_hex_byte(ptr, hx);
+		ptr = hex_byte_pack(ptr, hx);
 		hx = hex_asc_hi(excep);
-		ptr = pack_hex_byte(ptr, hx);
+		ptr = hex_byte_pack(ptr, hx);
 		hx = hex_asc_lo(excep);
-		ptr = pack_hex_byte(ptr, hx);
+		ptr = hex_byte_pack(ptr, hx);
 
 		ptr = mem2hex(crlf, ptr, sizeof(crlf) - 1, 0);
 		*ptr = 0;
@@ -1291,21 +1291,21 @@ static int gdbstub(struct pt_regs *regs, enum exception_code excep)
 		ptr = mem2hex(tbcberr, ptr, sizeof(tbcberr) - 1, 0);
 
 		hx = hex_asc_hi(bcberr >> 24);
-		ptr = pack_hex_byte(ptr, hx);
+		ptr = hex_byte_pack(ptr, hx);
 		hx = hex_asc_lo(bcberr >> 24);
-		ptr = pack_hex_byte(ptr, hx);
+		ptr = hex_byte_pack(ptr, hx);
 		hx = hex_asc_hi(bcberr >> 16);
-		ptr = pack_hex_byte(ptr, hx);
+		ptr = hex_byte_pack(ptr, hx);
 		hx = hex_asc_lo(bcberr >> 16);
-		ptr = pack_hex_byte(ptr, hx);
+		ptr = hex_byte_pack(ptr, hx);
 		hx = hex_asc_hi(bcberr >> 8);
-		ptr = pack_hex_byte(ptr, hx);
+		ptr = hex_byte_pack(ptr, hx);
 		hx = hex_asc_lo(bcberr >> 8);
-		ptr = pack_hex_byte(ptr, hx);
+		ptr = hex_byte_pack(ptr, hx);
 		hx = hex_asc_hi(bcberr);
-		ptr = pack_hex_byte(ptr, hx);
+		ptr = hex_byte_pack(ptr, hx);
 		hx = hex_asc_lo(bcberr);
-		ptr = pack_hex_byte(ptr, hx);
+		ptr = hex_byte_pack(ptr, hx);
 
 		ptr = mem2hex(crlf, ptr, sizeof(crlf) - 1, 0);
 		*ptr = 0;
@@ -1321,12 +1321,12 @@ static int gdbstub(struct pt_regs *regs, enum exception_code excep)
 	 * Send trap type (converted to signal)
 	 */
 	*ptr++ = 'T';
-	ptr = pack_hex_byte(ptr, sigval);
+	ptr = hex_byte_pack(ptr, sigval);
 
 	/*
 	 * Send Error PC
 	 */
-	ptr = pack_hex_byte(ptr, GDB_REGID_PC);
+	ptr = hex_byte_pack(ptr, GDB_REGID_PC);
 	*ptr++ = ':';
 	ptr = mem2hex(&regs->pc, ptr, 4, 0);
 	*ptr++ = ';';
@@ -1334,7 +1334,7 @@ static int gdbstub(struct pt_regs *regs, enum exception_code excep)
 	/*
 	 * Send frame pointer
 	 */
-	ptr = pack_hex_byte(ptr, GDB_REGID_FP);
+	ptr = hex_byte_pack(ptr, GDB_REGID_FP);
 	*ptr++ = ':';
 	ptr = mem2hex(&regs->a3, ptr, 4, 0);
 	*ptr++ = ';';
@@ -1343,7 +1343,7 @@ static int gdbstub(struct pt_regs *regs, enum exception_code excep)
 	 * Send stack pointer
 	 */
 	ssp = (unsigned long) (regs + 1);
-	ptr = pack_hex_byte(ptr, GDB_REGID_SP);
+	ptr = hex_byte_pack(ptr, GDB_REGID_SP);
 	*ptr++ = ':';
 	ptr = mem2hex(&ssp, ptr, 4, 0);
 	*ptr++ = ';';
diff --git a/kernel/debug/gdbstub.c b/kernel/debug/gdbstub.c
index 3487248..c22d8c2 100644
--- a/kernel/debug/gdbstub.c
+++ b/kernel/debug/gdbstub.c
@@ -217,7 +217,7 @@ void gdbstub_msg_write(const char *s, int len)
 
 		/* Pack in hex chars */
 		for (i = 0; i < wcount; i++)
-			bufptr = pack_hex_byte(bufptr, s[i]);
+			bufptr = hex_byte_pack(bufptr, s[i]);
 		*bufptr = '\0';
 
 		/* Move up */
@@ -249,7 +249,7 @@ char *kgdb_mem2hex(char *mem, char *buf, int count)
 	if (err)
 		return NULL;
 	while (count > 0) {
-		buf = pack_hex_byte(buf, *tmp);
+		buf = hex_byte_pack(buf, *tmp);
 		tmp++;
 		count--;
 	}
@@ -411,14 +411,14 @@ static char *pack_threadid(char *pkt, unsigned char *id)
 	limit = id + (BUF_THREAD_ID_SIZE / 2);
 	while (id < limit) {
 		if (!lzero || *id != 0) {
-			pkt = pack_hex_byte(pkt, *id);
+			pkt = hex_byte_pack(pkt, *id);
 			lzero = 0;
 		}
 		id++;
 	}
 
 	if (lzero)
-		pkt = pack_hex_byte(pkt, 0);
+		pkt = hex_byte_pack(pkt, 0);
 
 	return pkt;
 }
@@ -486,7 +486,7 @@ static void gdb_cmd_status(struct kgdb_state *ks)
 	dbg_remove_all_break();
 
 	remcom_out_buffer[0] = 'S';
-	pack_hex_byte(&remcom_out_buffer[1], ks->signo);
+	hex_byte_pack(&remcom_out_buffer[1], ks->signo);
 }
 
 static void gdb_get_regs_helper(struct kgdb_state *ks)
@@ -954,7 +954,7 @@ int gdb_serial_stub(struct kgdb_state *ks)
 		/* Reply to host that an exception has occurred */
 		ptr = remcom_out_buffer;
 		*ptr++ = 'T';
-		ptr = pack_hex_byte(ptr, ks->signo);
+		ptr = hex_byte_pack(ptr, ks->signo);
 		ptr += strlen(strcpy(ptr, "thread:"));
 		int_to_threadref(thref, shadow_pid(current->pid));
 		ptr = pack_threadid(ptr, thref);
-- 
1.7.6.3


^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCHv2 3/5] security: follow rename pack_hex_byte to hex_byte_pack
  2011-10-10 14:33                   ` [PATCHv2 1/5] lib: rename pack_hex_byte to hex_byte_pack Andy Shevchenko
  2011-10-10 14:33                     ` [PATCHv2 2/5] kgdb: follow " Andy Shevchenko
@ 2011-10-10 14:33                     ` Andy Shevchenko
  2011-10-10 14:33                     ` [PATCHv2 4/5] fat: " Andy Shevchenko
  2011-10-10 14:33                     ` [PATCHv2 5/5] wireless: at76c50x: " Andy Shevchenko
  3 siblings, 0 replies; 31+ messages in thread
From: Andy Shevchenko @ 2011-10-10 14:33 UTC (permalink / raw)
  To: Andrew Morton, linux-kernel; +Cc: Andy Shevchenko, Mimi Zohar

There is no functional change.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: Mimi Zohar <zohar@us.ibm.com>
---
 security/keys/encrypted-keys/encrypted.c |    2 +-
 security/keys/trusted.c                  |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/security/keys/encrypted-keys/encrypted.c b/security/keys/encrypted-keys/encrypted.c
index f33804c..dcc843c 100644
--- a/security/keys/encrypted-keys/encrypted.c
+++ b/security/keys/encrypted-keys/encrypted.c
@@ -293,7 +293,7 @@ static char *datablob_format(struct encrypted_key_payload *epayload,
 	/* convert the hex encoded iv, encrypted-data and HMAC to ascii */
 	bufp = &ascii_buf[len];
 	for (i = 0; i < (asciiblob_len - len) / 2; i++)
-		bufp = pack_hex_byte(bufp, iv[i]);
+		bufp = hex_byte_pack(bufp, iv[i]);
 out:
 	return ascii_buf;
 }
diff --git a/security/keys/trusted.c b/security/keys/trusted.c
index 0964fc2..0ed5fdf 100644
--- a/security/keys/trusted.c
+++ b/security/keys/trusted.c
@@ -1098,7 +1098,7 @@ static long trusted_read(const struct key *key, char __user *buffer,
 
 	bufp = ascii_buf;
 	for (i = 0; i < p->blob_len; i++)
-		bufp = pack_hex_byte(bufp, p->blob[i]);
+		bufp = hex_byte_pack(bufp, p->blob[i]);
 	if ((copy_to_user(buffer, ascii_buf, 2 * p->blob_len)) != 0) {
 		kfree(ascii_buf);
 		return -EFAULT;
-- 
1.7.6.3


^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCHv2 4/5] fat: follow rename pack_hex_byte to hex_byte_pack
  2011-10-10 14:33                   ` [PATCHv2 1/5] lib: rename pack_hex_byte to hex_byte_pack Andy Shevchenko
  2011-10-10 14:33                     ` [PATCHv2 2/5] kgdb: follow " Andy Shevchenko
  2011-10-10 14:33                     ` [PATCHv2 3/5] security: " Andy Shevchenko
@ 2011-10-10 14:33                     ` Andy Shevchenko
  2011-10-10 20:02                       ` OGAWA Hirofumi
  2011-10-10 14:33                     ` [PATCHv2 5/5] wireless: at76c50x: " Andy Shevchenko
  3 siblings, 1 reply; 31+ messages in thread
From: Andy Shevchenko @ 2011-10-10 14:33 UTC (permalink / raw)
  To: Andrew Morton, linux-kernel; +Cc: Andy Shevchenko, OGAWA Hirofumi

There is no functional change.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
---
 fs/fat/dir.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/fat/dir.c b/fs/fat/dir.c
index 5efbd5d..aca191b 100644
--- a/fs/fat/dir.c
+++ b/fs/fat/dir.c
@@ -156,8 +156,8 @@ static int uni16_to_x8(struct super_block *sb, unsigned char *ascii,
 		} else {
 			if (uni_xlate == 1) {
 				*op++ = ':';
-				op = pack_hex_byte(op, ec >> 8);
-				op = pack_hex_byte(op, ec);
+				op = hex_byte_pack(op, ec >> 8);
+				op = hex_byte_pack(op, ec);
 				len -= 5;
 			} else {
 				*op++ = '?';
-- 
1.7.6.3


^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCHv2 5/5] wireless: at76c50x: follow rename pack_hex_byte to hex_byte_pack
  2011-10-10 14:33                   ` [PATCHv2 1/5] lib: rename pack_hex_byte to hex_byte_pack Andy Shevchenko
                                       ` (2 preceding siblings ...)
  2011-10-10 14:33                     ` [PATCHv2 4/5] fat: " Andy Shevchenko
@ 2011-10-10 14:33                     ` Andy Shevchenko
  2011-10-11 13:55                       ` John W. Linville
  3 siblings, 1 reply; 31+ messages in thread
From: Andy Shevchenko @ 2011-10-10 14:33 UTC (permalink / raw)
  To: Andrew Morton, linux-kernel; +Cc: Andy Shevchenko, John W. Linville

There is no functional change.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: "John W. Linville" <linville@tuxdriver.com>
---
 drivers/net/wireless/at76c50x-usb.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/net/wireless/at76c50x-usb.c b/drivers/net/wireless/at76c50x-usb.c
index 39322d4..4045e5a 100644
--- a/drivers/net/wireless/at76c50x-usb.c
+++ b/drivers/net/wireless/at76c50x-usb.c
@@ -517,7 +517,7 @@ static char *hex2str(void *buf, size_t len)
 		goto exit;
 
 	while (len--) {
-		obuf = pack_hex_byte(obuf, *ibuf++);
+		obuf = hex_byte_pack(obuf, *ibuf++);
 		*obuf++ = '-';
 	}
 	obuf--;
-- 
1.7.6.3


^ permalink raw reply related	[flat|nested] 31+ messages in thread

* Re: [PATCHv2 2/5] kgdb: follow rename pack_hex_byte to hex_byte_pack
  2011-10-10 14:33                     ` [PATCHv2 2/5] kgdb: follow " Andy Shevchenko
@ 2011-10-10 14:55                       ` Jesper Nilsson
  0 siblings, 0 replies; 31+ messages in thread
From: Jesper Nilsson @ 2011-10-10 14:55 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Andrew Morton, linux-kernel, David Howells, Koichi Yasutake,
	Jason Wessel, kgdb-bugreport

On Mon, Oct 10, 2011 at 04:33:36PM +0200, Andy Shevchenko wrote:
> There is no functional change.

For CRIS parts:

Acked-by: Jesper Nilsson <jesper.nilsson@axis.com>

> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> Cc: Jesper Nilsson <jesper.nilsson@axis.com>
> Cc: David Howells <dhowells@redhat.com>
> Cc: Koichi Yasutake <yasutake.koichi@jp.panasonic.com>
> Cc: Jason Wessel <jason.wessel@windriver.com>
> Cc: kgdb-bugreport@lists.sourceforge.net
> ---
>  arch/cris/arch-v10/kernel/kgdb.c |    6 ++--
>  arch/cris/arch-v32/kernel/kgdb.c |   14 +++++-----
>  arch/frv/kernel/gdb-stub.c       |   44 ++++++++++++++++----------------
>  arch/mn10300/kernel/gdb-stub.c   |   52 +++++++++++++++++++-------------------
>  kernel/debug/gdbstub.c           |   12 ++++----
>  5 files changed, 64 insertions(+), 64 deletions(-)
> 
> diff --git a/arch/cris/arch-v10/kernel/kgdb.c b/arch/cris/arch-v10/kernel/kgdb.c
> index b9f9c8c..b579dd0 100644
> --- a/arch/cris/arch-v10/kernel/kgdb.c
> +++ b/arch/cris/arch-v10/kernel/kgdb.c
> @@ -694,7 +694,7 @@ mem2hex(char *buf, unsigned char *mem, int count)
>                  /* Valid mem address. */
>                  for (i = 0; i < count; i++) {
>                          ch = *mem++;
> -                       buf = pack_hex_byte(buf, ch);
> +                       buf = hex_byte_pack(buf, ch);
>                  }
>          }
> 
> @@ -868,7 +868,7 @@ stub_is_stopped(int sigval)
>         /* Send trap type (converted to signal) */
> 
>         *ptr++ = 'T';
> -       ptr = pack_hex_byte(ptr, sigval);
> +       ptr = hex_byte_pack(ptr, sigval);
> 
>         /* Send register contents. We probably only need to send the
>          * PC, frame pointer and stack pointer here. Other registers will be
> @@ -881,7 +881,7 @@ stub_is_stopped(int sigval)
>                  status = read_register (regno, &reg_cont);
> 
>                 if (status == SUCCESS) {
> -                       ptr = pack_hex_byte(ptr, regno);
> +                       ptr = hex_byte_pack(ptr, regno);
>                          *ptr++ = ':';
> 
>                          ptr = mem2hex(ptr, (unsigned char *)&reg_cont,
> diff --git a/arch/cris/arch-v32/kernel/kgdb.c b/arch/cris/arch-v32/kernel/kgdb.c
> index c0343c3..8c1d35c 100644
> --- a/arch/cris/arch-v32/kernel/kgdb.c
> +++ b/arch/cris/arch-v32/kernel/kgdb.c
> @@ -677,7 +677,7 @@ mem2hex(char *buf, unsigned char *mem, int count)
>                  /* Valid mem address. */
>                 for (i = 0; i < count; i++) {
>                         ch = *mem++;
> -                       buf = pack_hex_byte(buf, ch);
> +                       buf = hex_byte_pack(buf, ch);
>                 }
>          }
>          /* Terminate properly. */
> @@ -695,7 +695,7 @@ mem2hex_nbo(char *buf, unsigned char *mem, int count)
>         mem += count - 1;
>         for (i = 0; i < count; i++) {
>                 ch = *mem--;
> -               buf = pack_hex_byte(buf, ch);
> +               buf = hex_byte_pack(buf, ch);
>          }
> 
>          /* Terminate properly. */
> @@ -880,7 +880,7 @@ stub_is_stopped(int sigval)
>         /* Send trap type (converted to signal) */
> 
>         *ptr++ = 'T';
> -       ptr = pack_hex_byte(ptr, sigval);
> +       ptr = hex_byte_pack(ptr, sigval);
> 
>         if (((reg.exs & 0xff00) >> 8) == 0xc) {
> 
> @@ -988,26 +988,26 @@ stub_is_stopped(int sigval)
>         }
>         /* Only send PC, frame and stack pointer. */
>         read_register(PC, &reg_cont);
> -       ptr = pack_hex_byte(ptr, PC);
> +       ptr = hex_byte_pack(ptr, PC);
>         *ptr++ = ':';
>         ptr = mem2hex(ptr, (unsigned char *)&reg_cont, register_size[PC]);
>         *ptr++ = ';';
> 
>         read_register(R8, &reg_cont);
> -       ptr = pack_hex_byte(ptr, R8);
> +       ptr = hex_byte_pack(ptr, R8);
>         *ptr++ = ':';
>         ptr = mem2hex(ptr, (unsigned char *)&reg_cont, register_size[R8]);
>         *ptr++ = ';';
> 
>         read_register(SP, &reg_cont);
> -       ptr = pack_hex_byte(ptr, SP);
> +       ptr = hex_byte_pack(ptr, SP);
>         *ptr++ = ':';
>         ptr = mem2hex(ptr, (unsigned char *)&reg_cont, register_size[SP]);
>         *ptr++ = ';';
> 
>         /* Send ERP as well; this will save us an entire register fetch in some cases. */
>          read_register(ERP, &reg_cont);
> -       ptr = pack_hex_byte(ptr, ERP);
> +       ptr = hex_byte_pack(ptr, ERP);
>          *ptr++ = ':';
>          ptr = mem2hex(ptr, (unsigned char *)&reg_cont, register_size[ERP]);
>          *ptr++ = ';';
> diff --git a/arch/frv/kernel/gdb-stub.c b/arch/frv/kernel/gdb-stub.c
> index a4dba6b..a6d5381 100644
> --- a/arch/frv/kernel/gdb-stub.c
> +++ b/arch/frv/kernel/gdb-stub.c
> @@ -672,7 +672,7 @@ static unsigned char *mem2hex(const void *_mem, char *buf, int count, int may_fa
>         if ((uint32_t)mem&1 && count>=1) {
>                 if (!gdbstub_read_byte(mem,ch))
>                         return NULL;
> -               buf = pack_hex_byte(buf, ch[0]);
> +               buf = hex_byte_pack(buf, ch[0]);
>                 mem++;
>                 count--;
>         }
> @@ -680,8 +680,8 @@ static unsigned char *mem2hex(const void *_mem, char *buf, int count, int may_fa
>         if ((uint32_t)mem&3 && count>=2) {
>                 if (!gdbstub_read_word(mem,(uint16_t *)ch))
>                         return NULL;
> -               buf = pack_hex_byte(buf, ch[0]);
> -               buf = pack_hex_byte(buf, ch[1]);
> +               buf = hex_byte_pack(buf, ch[0]);
> +               buf = hex_byte_pack(buf, ch[1]);
>                 mem += 2;
>                 count -= 2;
>         }
> @@ -689,10 +689,10 @@ static unsigned char *mem2hex(const void *_mem, char *buf, int count, int may_fa
>         while (count>=4) {
>                 if (!gdbstub_read_dword(mem,(uint32_t *)ch))
>                         return NULL;
> -               buf = pack_hex_byte(buf, ch[0]);
> -               buf = pack_hex_byte(buf, ch[1]);
> -               buf = pack_hex_byte(buf, ch[2]);
> -               buf = pack_hex_byte(buf, ch[3]);
> +               buf = hex_byte_pack(buf, ch[0]);
> +               buf = hex_byte_pack(buf, ch[1]);
> +               buf = hex_byte_pack(buf, ch[2]);
> +               buf = hex_byte_pack(buf, ch[3]);
>                 mem += 4;
>                 count -= 4;
>         }
> @@ -700,8 +700,8 @@ static unsigned char *mem2hex(const void *_mem, char *buf, int count, int may_fa
>         if (count>=2) {
>                 if (!gdbstub_read_word(mem,(uint16_t *)ch))
>                         return NULL;
> -               buf = pack_hex_byte(buf, ch[0]);
> -               buf = pack_hex_byte(buf, ch[1]);
> +               buf = hex_byte_pack(buf, ch[0]);
> +               buf = hex_byte_pack(buf, ch[1]);
>                 mem += 2;
>                 count -= 2;
>         }
> @@ -709,7 +709,7 @@ static unsigned char *mem2hex(const void *_mem, char *buf, int count, int may_fa
>         if (count>=1) {
>                 if (!gdbstub_read_byte(mem,ch))
>                         return NULL;
> -               buf = pack_hex_byte(buf, ch[0]);
> +               buf = hex_byte_pack(buf, ch[0]);
>         }
> 
>         *buf = 0;
> @@ -1498,21 +1498,21 @@ void gdbstub(int sigval)
>                 ptr = mem2hex(title, ptr, sizeof(title) - 1,0);
> 
>                 hx = hex_asc_hi(brr >> 24);
> -               ptr = pack_hex_byte(ptr, hx);
> +               ptr = hex_byte_pack(ptr, hx);
>                 hx = hex_asc_lo(brr >> 24);
> -               ptr = pack_hex_byte(ptr, hx);
> +               ptr = hex_byte_pack(ptr, hx);
>                 hx = hex_asc_hi(brr >> 16);
> -               ptr = pack_hex_byte(ptr, hx);
> +               ptr = hex_byte_pack(ptr, hx);
>                 hx = hex_asc_lo(brr >> 16);
> -               ptr = pack_hex_byte(ptr, hx);
> +               ptr = hex_byte_pack(ptr, hx);
>                 hx = hex_asc_hi(brr >> 8);
> -               ptr = pack_hex_byte(ptr, hx);
> +               ptr = hex_byte_pack(ptr, hx);
>                 hx = hex_asc_lo(brr >> 8);
> -               ptr = pack_hex_byte(ptr, hx);
> +               ptr = hex_byte_pack(ptr, hx);
>                 hx = hex_asc_hi(brr);
> -               ptr = pack_hex_byte(ptr, hx);
> +               ptr = hex_byte_pack(ptr, hx);
>                 hx = hex_asc_lo(brr);
> -               ptr = pack_hex_byte(ptr, hx);
> +               ptr = hex_byte_pack(ptr, hx);
> 
>                 ptr = mem2hex(crlf, ptr, sizeof(crlf) - 1, 0);
>                 *ptr = 0;
> @@ -1526,10 +1526,10 @@ void gdbstub(int sigval)
> 
>         /* Send trap type (converted to signal) */
>         *ptr++ = 'T';
> -       ptr = pack_hex_byte(ptr, sigval);
> +       ptr = hex_byte_pack(ptr, sigval);
> 
>         /* Send Error PC */
> -       ptr = pack_hex_byte(ptr, GDB_REG_PC);
> +       ptr = hex_byte_pack(ptr, GDB_REG_PC);
>         *ptr++ = ':';
>         ptr = mem2hex(&__debug_frame->pc, ptr, 4, 0);
>         *ptr++ = ';';
> @@ -1537,7 +1537,7 @@ void gdbstub(int sigval)
>         /*
>          * Send frame pointer
>          */
> -       ptr = pack_hex_byte(ptr, GDB_REG_FP);
> +       ptr = hex_byte_pack(ptr, GDB_REG_FP);
>         *ptr++ = ':';
>         ptr = mem2hex(&__debug_frame->fp, ptr, 4, 0);
>         *ptr++ = ';';
> @@ -1545,7 +1545,7 @@ void gdbstub(int sigval)
>         /*
>          * Send stack pointer
>          */
> -       ptr = pack_hex_byte(ptr, GDB_REG_SP);
> +       ptr = hex_byte_pack(ptr, GDB_REG_SP);
>         *ptr++ = ':';
>         ptr = mem2hex(&__debug_frame->sp, ptr, 4, 0);
>         *ptr++ = ';';
> diff --git a/arch/mn10300/kernel/gdb-stub.c b/arch/mn10300/kernel/gdb-stub.c
> index 538266b..522eb8a 100644
> --- a/arch/mn10300/kernel/gdb-stub.c
> +++ b/arch/mn10300/kernel/gdb-stub.c
> @@ -798,7 +798,7 @@ unsigned char *mem2hex(const void *_mem, char *buf, int count, int may_fault)
>         if ((u32) mem & 1 && count >= 1) {
>                 if (gdbstub_read_byte(mem, ch) != 0)
>                         return 0;
> -               buf = pack_hex_byte(buf, ch[0]);
> +               buf = hex_byte_pack(buf, ch[0]);
>                 mem++;
>                 count--;
>         }
> @@ -806,8 +806,8 @@ unsigned char *mem2hex(const void *_mem, char *buf, int count, int may_fault)
>         if ((u32) mem & 3 && count >= 2) {
>                 if (gdbstub_read_word(mem, ch) != 0)
>                         return 0;
> -               buf = pack_hex_byte(buf, ch[0]);
> -               buf = pack_hex_byte(buf, ch[1]);
> +               buf = hex_byte_pack(buf, ch[0]);
> +               buf = hex_byte_pack(buf, ch[1]);
>                 mem += 2;
>                 count -= 2;
>         }
> @@ -815,10 +815,10 @@ unsigned char *mem2hex(const void *_mem, char *buf, int count, int may_fault)
>         while (count >= 4) {
>                 if (gdbstub_read_dword(mem, ch) != 0)
>                         return 0;
> -               buf = pack_hex_byte(buf, ch[0]);
> -               buf = pack_hex_byte(buf, ch[1]);
> -               buf = pack_hex_byte(buf, ch[2]);
> -               buf = pack_hex_byte(buf, ch[3]);
> +               buf = hex_byte_pack(buf, ch[0]);
> +               buf = hex_byte_pack(buf, ch[1]);
> +               buf = hex_byte_pack(buf, ch[2]);
> +               buf = hex_byte_pack(buf, ch[3]);
>                 mem += 4;
>                 count -= 4;
>         }
> @@ -826,8 +826,8 @@ unsigned char *mem2hex(const void *_mem, char *buf, int count, int may_fault)
>         if (count >= 2) {
>                 if (gdbstub_read_word(mem, ch) != 0)
>                         return 0;
> -               buf = pack_hex_byte(buf, ch[0]);
> -               buf = pack_hex_byte(buf, ch[1]);
> +               buf = hex_byte_pack(buf, ch[0]);
> +               buf = hex_byte_pack(buf, ch[1]);
>                 mem += 2;
>                 count -= 2;
>         }
> @@ -835,7 +835,7 @@ unsigned char *mem2hex(const void *_mem, char *buf, int count, int may_fault)
>         if (count >= 1) {
>                 if (gdbstub_read_byte(mem, ch) != 0)
>                         return 0;
> -               buf = pack_hex_byte(buf, ch[0]);
> +               buf = hex_byte_pack(buf, ch[0]);
>         }
> 
>         *buf = 0;
> @@ -1273,13 +1273,13 @@ static int gdbstub(struct pt_regs *regs, enum exception_code excep)
>                 ptr = mem2hex(title, ptr, sizeof(title) - 1, 0);
> 
>                 hx = hex_asc_hi(excep >> 8);
> -               ptr = pack_hex_byte(ptr, hx);
> +               ptr = hex_byte_pack(ptr, hx);
>                 hx = hex_asc_lo(excep >> 8);
> -               ptr = pack_hex_byte(ptr, hx);
> +               ptr = hex_byte_pack(ptr, hx);
>                 hx = hex_asc_hi(excep);
> -               ptr = pack_hex_byte(ptr, hx);
> +               ptr = hex_byte_pack(ptr, hx);
>                 hx = hex_asc_lo(excep);
> -               ptr = pack_hex_byte(ptr, hx);
> +               ptr = hex_byte_pack(ptr, hx);
> 
>                 ptr = mem2hex(crlf, ptr, sizeof(crlf) - 1, 0);
>                 *ptr = 0;
> @@ -1291,21 +1291,21 @@ static int gdbstub(struct pt_regs *regs, enum exception_code excep)
>                 ptr = mem2hex(tbcberr, ptr, sizeof(tbcberr) - 1, 0);
> 
>                 hx = hex_asc_hi(bcberr >> 24);
> -               ptr = pack_hex_byte(ptr, hx);
> +               ptr = hex_byte_pack(ptr, hx);
>                 hx = hex_asc_lo(bcberr >> 24);
> -               ptr = pack_hex_byte(ptr, hx);
> +               ptr = hex_byte_pack(ptr, hx);
>                 hx = hex_asc_hi(bcberr >> 16);
> -               ptr = pack_hex_byte(ptr, hx);
> +               ptr = hex_byte_pack(ptr, hx);
>                 hx = hex_asc_lo(bcberr >> 16);
> -               ptr = pack_hex_byte(ptr, hx);
> +               ptr = hex_byte_pack(ptr, hx);
>                 hx = hex_asc_hi(bcberr >> 8);
> -               ptr = pack_hex_byte(ptr, hx);
> +               ptr = hex_byte_pack(ptr, hx);
>                 hx = hex_asc_lo(bcberr >> 8);
> -               ptr = pack_hex_byte(ptr, hx);
> +               ptr = hex_byte_pack(ptr, hx);
>                 hx = hex_asc_hi(bcberr);
> -               ptr = pack_hex_byte(ptr, hx);
> +               ptr = hex_byte_pack(ptr, hx);
>                 hx = hex_asc_lo(bcberr);
> -               ptr = pack_hex_byte(ptr, hx);
> +               ptr = hex_byte_pack(ptr, hx);
> 
>                 ptr = mem2hex(crlf, ptr, sizeof(crlf) - 1, 0);
>                 *ptr = 0;
> @@ -1321,12 +1321,12 @@ static int gdbstub(struct pt_regs *regs, enum exception_code excep)
>          * Send trap type (converted to signal)
>          */
>         *ptr++ = 'T';
> -       ptr = pack_hex_byte(ptr, sigval);
> +       ptr = hex_byte_pack(ptr, sigval);
> 
>         /*
>          * Send Error PC
>          */
> -       ptr = pack_hex_byte(ptr, GDB_REGID_PC);
> +       ptr = hex_byte_pack(ptr, GDB_REGID_PC);
>         *ptr++ = ':';
>         ptr = mem2hex(&regs->pc, ptr, 4, 0);
>         *ptr++ = ';';
> @@ -1334,7 +1334,7 @@ static int gdbstub(struct pt_regs *regs, enum exception_code excep)
>         /*
>          * Send frame pointer
>          */
> -       ptr = pack_hex_byte(ptr, GDB_REGID_FP);
> +       ptr = hex_byte_pack(ptr, GDB_REGID_FP);
>         *ptr++ = ':';
>         ptr = mem2hex(&regs->a3, ptr, 4, 0);
>         *ptr++ = ';';
> @@ -1343,7 +1343,7 @@ static int gdbstub(struct pt_regs *regs, enum exception_code excep)
>          * Send stack pointer
>          */
>         ssp = (unsigned long) (regs + 1);
> -       ptr = pack_hex_byte(ptr, GDB_REGID_SP);
> +       ptr = hex_byte_pack(ptr, GDB_REGID_SP);
>         *ptr++ = ':';
>         ptr = mem2hex(&ssp, ptr, 4, 0);
>         *ptr++ = ';';
> diff --git a/kernel/debug/gdbstub.c b/kernel/debug/gdbstub.c
> index 3487248..c22d8c2 100644
> --- a/kernel/debug/gdbstub.c
> +++ b/kernel/debug/gdbstub.c
> @@ -217,7 +217,7 @@ void gdbstub_msg_write(const char *s, int len)
> 
>                 /* Pack in hex chars */
>                 for (i = 0; i < wcount; i++)
> -                       bufptr = pack_hex_byte(bufptr, s[i]);
> +                       bufptr = hex_byte_pack(bufptr, s[i]);
>                 *bufptr = '\0';
> 
>                 /* Move up */
> @@ -249,7 +249,7 @@ char *kgdb_mem2hex(char *mem, char *buf, int count)
>         if (err)
>                 return NULL;
>         while (count > 0) {
> -               buf = pack_hex_byte(buf, *tmp);
> +               buf = hex_byte_pack(buf, *tmp);
>                 tmp++;
>                 count--;
>         }
> @@ -411,14 +411,14 @@ static char *pack_threadid(char *pkt, unsigned char *id)
>         limit = id + (BUF_THREAD_ID_SIZE / 2);
>         while (id < limit) {
>                 if (!lzero || *id != 0) {
> -                       pkt = pack_hex_byte(pkt, *id);
> +                       pkt = hex_byte_pack(pkt, *id);
>                         lzero = 0;
>                 }
>                 id++;
>         }
> 
>         if (lzero)
> -               pkt = pack_hex_byte(pkt, 0);
> +               pkt = hex_byte_pack(pkt, 0);
> 
>         return pkt;
>  }
> @@ -486,7 +486,7 @@ static void gdb_cmd_status(struct kgdb_state *ks)
>         dbg_remove_all_break();
> 
>         remcom_out_buffer[0] = 'S';
> -       pack_hex_byte(&remcom_out_buffer[1], ks->signo);
> +       hex_byte_pack(&remcom_out_buffer[1], ks->signo);
>  }
> 
>  static void gdb_get_regs_helper(struct kgdb_state *ks)
> @@ -954,7 +954,7 @@ int gdb_serial_stub(struct kgdb_state *ks)
>                 /* Reply to host that an exception has occurred */
>                 ptr = remcom_out_buffer;
>                 *ptr++ = 'T';
> -               ptr = pack_hex_byte(ptr, ks->signo);
> +               ptr = hex_byte_pack(ptr, ks->signo);
>                 ptr += strlen(strcpy(ptr, "thread:"));
>                 int_to_threadref(thref, shadow_pid(current->pid));
>                 ptr = pack_threadid(ptr, thref);
> --
> 1.7.6.3
/^JN - Jesper Nilsson
-- 
               Jesper Nilsson -- jesper.nilsson@axis.com

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCHv2 4/5] fat: follow rename pack_hex_byte to hex_byte_pack
  2011-10-10 14:33                     ` [PATCHv2 4/5] fat: " Andy Shevchenko
@ 2011-10-10 20:02                       ` OGAWA Hirofumi
  0 siblings, 0 replies; 31+ messages in thread
From: OGAWA Hirofumi @ 2011-10-10 20:02 UTC (permalink / raw)
  To: Andy Shevchenko; +Cc: Andrew Morton, linux-kernel

Andy Shevchenko <andriy.shevchenko@linux.intel.com> writes:

> There is no functional change.
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> Cc: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>

Acked-by: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>

Thanks.

> ---
>  fs/fat/dir.c |    4 ++--
>  1 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/fs/fat/dir.c b/fs/fat/dir.c
> index 5efbd5d..aca191b 100644
> --- a/fs/fat/dir.c
> +++ b/fs/fat/dir.c
> @@ -156,8 +156,8 @@ static int uni16_to_x8(struct super_block *sb, unsigned char *ascii,
>  		} else {
>  			if (uni_xlate == 1) {
>  				*op++ = ':';
> -				op = pack_hex_byte(op, ec >> 8);
> -				op = pack_hex_byte(op, ec);
> +				op = hex_byte_pack(op, ec >> 8);
> +				op = hex_byte_pack(op, ec);
>  				len -= 5;
>  			} else {
>  				*op++ = '?';

-- 
OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCHv2 5/5] wireless: at76c50x: follow rename pack_hex_byte to hex_byte_pack
  2011-10-10 14:33                     ` [PATCHv2 5/5] wireless: at76c50x: " Andy Shevchenko
@ 2011-10-11 13:55                       ` John W. Linville
  0 siblings, 0 replies; 31+ messages in thread
From: John W. Linville @ 2011-10-11 13:55 UTC (permalink / raw)
  To: Andy Shevchenko; +Cc: Andrew Morton, linux-kernel

On Mon, Oct 10, 2011 at 05:33:39PM +0300, Andy Shevchenko wrote:
> There is no functional change.
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> Cc: "John W. Linville" <linville@tuxdriver.com>

Acked-by: John W. Linville <linville@tuxdriver.com>

-- 
John W. Linville		Someday the world will need a hero, and you
linville@tuxdriver.com			might be all we have.  Be ready.

^ permalink raw reply	[flat|nested] 31+ messages in thread

end of thread, other threads:[~2011-10-11 14:00 UTC | newest]

Thread overview: 31+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-09-16 12:50 [RFC][PATCH 1/5] lib: add unpack_hex_byte() Mimi Zohar
2011-09-16 12:50 ` [RFC][PATCH 2/5] lib: add error checking to hex2bin Mimi Zohar
2011-09-16 13:13   ` Andy Shevchenko
2011-09-19 21:20   ` Andrew Morton
2011-09-16 12:50 ` [RFC][PATCH 3/5] trusted-keys: check hex2bin result Mimi Zohar
2011-09-16 12:50 ` [RFC][PATCH 4/5] encrypted-keys: " Mimi Zohar
2011-09-16 12:50 ` [RFC][PATCH 5/5] target: " Mimi Zohar
2011-09-16 14:07   ` Tetsuo Handa
2011-09-16 20:21     ` Nicholas A. Bellinger
2011-09-19 11:19       ` Mimi Zohar
2011-09-16 13:11 ` [RFC][PATCH 1/5] lib: add unpack_hex_byte() Andy Shevchenko
2011-09-19 21:19 ` Andrew Morton
2011-09-19 22:35   ` Mimi Zohar
2011-09-19 22:38     ` Andrew Morton
2011-09-20  6:04       ` Andy Shevchenko
2011-09-20  6:26         ` Andrew Morton
2011-09-23 10:47           ` [PATCH 1/2] kernel.h: rename pack_hex_byte to hex_pack_byte Andy Shevchenko
2011-09-23 10:47             ` [PATCH 2/2] wireless: at76c50x: use native hex_pack_byte() method Andy Shevchenko
2011-09-27 11:51               ` [PATCHv2] " Andy Shevchenko
2011-09-27 12:01               ` [PATCHv2.1] " Andy Shevchenko
2011-09-23 20:18             ` [PATCH 1/2] kernel.h: rename pack_hex_byte to hex_pack_byte Andrew Morton
2011-09-27 10:51               ` Andy Shevchenko
2011-09-27 17:32                 ` Andrew Morton
2011-10-10 14:33                   ` [PATCHv2 1/5] lib: rename pack_hex_byte to hex_byte_pack Andy Shevchenko
2011-10-10 14:33                     ` [PATCHv2 2/5] kgdb: follow " Andy Shevchenko
2011-10-10 14:55                       ` Jesper Nilsson
2011-10-10 14:33                     ` [PATCHv2 3/5] security: " Andy Shevchenko
2011-10-10 14:33                     ` [PATCHv2 4/5] fat: " Andy Shevchenko
2011-10-10 20:02                       ` OGAWA Hirofumi
2011-10-10 14:33                     ` [PATCHv2 5/5] wireless: at76c50x: " Andy Shevchenko
2011-10-11 13:55                       ` John W. Linville

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).