diff options
author | Andy Shevchenko <andriy.shevchenko@linux.intel.com> | 2017-09-08 19:15:28 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2017-09-08 21:26:49 -0400 |
commit | 9888a588ea96ba2804f955bbc2667346719da887 (patch) | |
tree | 0d8596815377b7f283e7c361e3a9018b99ee3856 | |
parent | f0f1a45f95e85a8ac28c4d62bf2a84db0799efab (diff) |
lib/hexdump.c: return -EINVAL in case of error in hex2bin()
In some cases caller would like to use error code directly without
shadowing.
-EINVAL feels a rightful code to return in case of error in hex2bin().
Link: http://lkml.kernel.org/r/20170731135510.68023-1-andriy.shevchenko@linux.intel.com
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | lib/hexdump.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/hexdump.c b/lib/hexdump.c index 992457b1284c..81b70ed37209 100644 --- a/lib/hexdump.c +++ b/lib/hexdump.c | |||
@@ -9,6 +9,7 @@ | |||
9 | 9 | ||
10 | #include <linux/types.h> | 10 | #include <linux/types.h> |
11 | #include <linux/ctype.h> | 11 | #include <linux/ctype.h> |
12 | #include <linux/errno.h> | ||
12 | #include <linux/kernel.h> | 13 | #include <linux/kernel.h> |
13 | #include <linux/export.h> | 14 | #include <linux/export.h> |
14 | #include <asm/unaligned.h> | 15 | #include <asm/unaligned.h> |
@@ -42,7 +43,7 @@ EXPORT_SYMBOL(hex_to_bin); | |||
42 | * @src: ascii hexadecimal string | 43 | * @src: ascii hexadecimal string |
43 | * @count: result length | 44 | * @count: result length |
44 | * | 45 | * |
45 | * Return 0 on success, -1 in case of bad input. | 46 | * Return 0 on success, -EINVAL in case of bad input. |
46 | */ | 47 | */ |
47 | int hex2bin(u8 *dst, const char *src, size_t count) | 48 | int hex2bin(u8 *dst, const char *src, size_t count) |
48 | { | 49 | { |
@@ -51,7 +52,7 @@ int hex2bin(u8 *dst, const char *src, size_t count) | |||
51 | int lo = hex_to_bin(*src++); | 52 | int lo = hex_to_bin(*src++); |
52 | 53 | ||
53 | if ((hi < 0) || (lo < 0)) | 54 | if ((hi < 0) || (lo < 0)) |
54 | return -1; | 55 | return -EINVAL; |
55 | 56 | ||
56 | *dst++ = (hi << 4) | lo; | 57 | *dst++ = (hi << 4) | lo; |
57 | } | 58 | } |