From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752288AbdGaNzp (ORCPT ); Mon, 31 Jul 2017 09:55:45 -0400 Received: from mga09.intel.com ([134.134.136.24]:29881 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751647AbdGaNzo (ORCPT ); Mon, 31 Jul 2017 09:55:44 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.40,442,1496127600"; d="scan'208";a="1157307471" From: Andy Shevchenko To: linux-kernel@vger.kernel.org, Joe Perches , Arnd Bergmann , Rasmus Villemoes , Andrew Morton Cc: Andy Shevchenko Subject: [PATCH v1] lib/hexdump: Return -EINVAL in case of error in hex2bin() Date: Mon, 31 Jul 2017 16:55:10 +0300 Message-Id: <20170731135510.68023-1-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.13.2 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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(). Signed-off-by: Andy Shevchenko --- lib/hexdump.c | 5 +++-- 1 file 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 @@ #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; } -- 2.13.2