From: Andy Shevchenko Date: Fri, 8 Sep 2017 23:15:28 +0000 (-0700) Subject: lib/hexdump.c: return -EINVAL in case of error in hex2bin() X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=9888a588ea96ba2804f955bbc2667346719da887;p=GitHub%2FLineageOS%2Fandroid_kernel_motorola_exynos9610.git 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 Cc: Arnd Bergmann Cc: Rasmus Villemoes Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- 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 @@ #include #include +#include #include #include #include @@ -42,7 +43,7 @@ EXPORT_SYMBOL(hex_to_bin); * @src: ascii hexadecimal string * @count: result length * - * Return 0 on success, -1 in case of bad input. + * Return 0 on success, -EINVAL in case of bad input. */ int hex2bin(u8 *dst, const char *src, size_t count) { @@ -51,7 +52,7 @@ int hex2bin(u8 *dst, const char *src, size_t count) int lo = hex_to_bin(*src++); if ((hi < 0) || (lo < 0)) - return -1; + return -EINVAL; *dst++ = (hi << 4) | lo; }