Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932636AbbHJSld (ORCPT ); Mon, 10 Aug 2015 14:41:33 -0400 Received: from mail-pd0-f169.google.com ([209.85.192.169]:32877 "EHLO mail-pd0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932162AbbHJSla (ORCPT ); Mon, 10 Aug 2015 14:41:30 -0400 From: Brian Norris To: Chanwoo Choi , MyungJoo Ham Cc: Brian Norris , , Greg Kroah-Hartman , Roger Quadros , "Ivan T . Ivanov" Subject: [PATCH] extcon: fix signedness issues Date: Mon, 10 Aug 2015 11:39:40 -0700 Message-Id: <1439231980-105388-1-git-send-email-computersforpeace@gmail.com> X-Mailer: git-send-email 2.5.0.rc2.392.g76e840b MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2432 Lines: 67 commit be052cc87745 ("extcon: Fix hang and extcon_get/set_cable_state().") introduced several signedness issues. sparse reports them: drivers/extcon/extcon.c: In function ‘find_cable_index_by_name’: drivers/extcon/extcon.c:153:2: warning: comparison of unsigned expression < 0 is always false [-Wtype-limits] drivers/extcon/extcon.c: In function ‘extcon_get_cable_state’: drivers/extcon/extcon.c:384:2: warning: comparison of unsigned expression < 0 is always false [-Wtype-limits] drivers/extcon/extcon.c: In function ‘extcon_set_cable_state’: drivers/extcon/extcon.c:432:2: warning: comparison of unsigned expression < 0 is always false [-Wtype-limits] Fixes: be052cc87745 ("extcon: Fix hang and extcon_get/set_cable_state().") Signed-off-by: Brian Norris --- This is *only* compile-tested drivers/extcon/extcon.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/extcon/extcon.c b/drivers/extcon/extcon.c index 43b57b02d050..a394ca419715 100644 --- a/drivers/extcon/extcon.c +++ b/drivers/extcon/extcon.c @@ -126,7 +126,7 @@ static int find_cable_index_by_id(struct extcon_dev *edev, const unsigned int id static int find_cable_id_by_name(struct extcon_dev *edev, const char *name) { - unsigned int id = -EINVAL; + int id = -EINVAL; int i = 0; /* Find the id of extcon cable */ @@ -143,7 +143,7 @@ static int find_cable_id_by_name(struct extcon_dev *edev, const char *name) static int find_cable_index_by_name(struct extcon_dev *edev, const char *name) { - unsigned int id; + int id; if (edev->max_supported == 0) return -EINVAL; @@ -378,7 +378,7 @@ EXPORT_SYMBOL_GPL(extcon_get_cable_state_); */ int extcon_get_cable_state(struct extcon_dev *edev, const char *cable_name) { - unsigned int id; + int id; id = find_cable_id_by_name(edev, cable_name); if (id < 0) @@ -426,7 +426,7 @@ EXPORT_SYMBOL_GPL(extcon_set_cable_state_); int extcon_set_cable_state(struct extcon_dev *edev, const char *cable_name, bool cable_state) { - unsigned int id; + int id; id = find_cable_id_by_name(edev, cable_name); if (id < 0) -- 2.5.0.rc2.392.g76e840b -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/