From patchwork Thu Jun 25 06:46:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 11624677 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A1C1490 for ; Thu, 25 Jun 2020 06:48:54 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 53F7E20773 for ; Thu, 25 Jun 2020 06:48:54 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="W7ESBZbQ"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="BoR0BVfF" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 53F7E20773 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=r2TfmwDBMhzHTzEJmhfWkk+/rWKoS4IedMJ9M2DonLY=; b=W7ESBZbQrK6FFpbiqK9TNLhA+ KrhIr4UEGJi0JBhW0XyIZojO7FedzoR4Ueubv712RP2wKLjy8aLwuONQUQQUDcxsF6CI/M3dbvYgg u/ihRR3H29bSRXlJjkHJChQROZP/wjiiAmcmvq/5skMl/BnY8nrjgIIBcCNzjQHNgq6ljqaOhyJBV ZRa9jMBlW1CTz84vfvTCmSeNtMjDP9fzXRdifV6Cv4n/3DX8TfWN2uaOGTR8JTK8GsfC/nAixO42e nM2x2X0NwwNFD72V63m38C4LXlpd1iHPDyJ+ZeWbk2NHUg7Li/4rLfr2RcwkRJPP2YLievGKaHdBp ISgSRuG8Q==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1joLf4-0000Pp-P2; Thu, 25 Jun 2020 06:47:02 +0000 Received: from mail-wm1-x342.google.com ([2a00:1450:4864:20::342]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1joLee-00007O-AB for linux-arm-kernel@lists.infradead.org; Thu, 25 Jun 2020 06:46:37 +0000 Received: by mail-wm1-x342.google.com with SMTP id 22so4424230wmg.1 for ; Wed, 24 Jun 2020 23:46:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ZzLtCVZ0xnD69Tq7rrN3k4RXzAsRLvX+l/b23e7w5no=; b=BoR0BVfFhS9za/tBEuj3YkwiY8nNI24M8p9fmhuCM6IiYJIEKM/q4XFtIYaAjPe2Dk +nz7AdEJTpAE6Z+mq1fY/goiHr+ULfYi+dRbajh5fVCoRPVr0Q+zoCiJpLRmGQXpi0nF hp5QBIuI6XCJpSCjUX0V3zfIn+ZbWxvJgbgmtqBW+2vkICODU7hu8BBVpkSerVZbYksH 3F+0fRc9wCbqjlgJjwvTx76agAqHN5CXzt9RhogHKW0HMD0Hsdt+C+QgFL5edj3pUqh/ qEeWE5X1U9a0rI6T84EX3KqVH/ST5X+6bwNw57W9gxqGVfLBP9icFRkYY03DiWqvKjBD zDhA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ZzLtCVZ0xnD69Tq7rrN3k4RXzAsRLvX+l/b23e7w5no=; b=fDrzNEEaF791OQB0qZ2zwYB+SHjGD5PefQKVBffR7REFv59itKTWdZOW5iX6wSqpap tPWhC0xcx5AbYXNAuri2AAklL71jwma7RX4qD2IabgWRxa4sOM9gY3ukbBwSqlNxe/Cz KbxDgJ7RjNzWEsdxA2o/1X0h9Hn6nSL678Q17fl1K2dUG/aAn+XWbr8DPxwKtC9/xYk6 d7UBq9nGmNabV4W4hZPTsomLlxzcD7eLUuYqRaj7aJEv5oI/6+yT4nCxK3ANv/2eMt4f l6d9zR5b7s7upIIEdNg38XhcSlNR/IfbwvFfj0UriWGPPBLWhKjUqrdsQpJyA3ou2Y63 /Pfw== X-Gm-Message-State: AOAM5306mFBkE/XOjlkwsDO3r5MjBevh2qsaLZpljHp9+o63Xg9yuHcQ WzaUU3a9c5+wzLBqBXQzHLZPmg== X-Google-Smtp-Source: ABdhPJwbgPCP3KuminY9vt8AVhB+YH09uHBBW5EhL/706W7PsYH5XWdLmpQqngWOkPmCwNX2J/EVng== X-Received: by 2002:a1c:de07:: with SMTP id v7mr1737470wmg.56.1593067595221; Wed, 24 Jun 2020 23:46:35 -0700 (PDT) Received: from localhost.localdomain ([2.27.35.144]) by smtp.gmail.com with ESMTPSA id c20sm27235363wrb.65.2020.06.24.23.46.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Jun 2020 23:46:34 -0700 (PDT) From: Lee Jones To: lee.jones@linaro.org Subject: [PATCH 08/10] mfd: atmel-smc: Silence comparison of unsigned expression < 0 is always false warning (W=1) Date: Thu, 25 Jun 2020 07:46:17 +0100 Message-Id: <20200625064619.2775707-9-lee.jones@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200625064619.2775707-1-lee.jones@linaro.org> References: <20200625064619.2775707-1-lee.jones@linaro.org> MIME-Version: 1.0 X-Spam-Note: CRM114 invocation failed X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:342 listed in] [list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Boris Brezillon , Alexandre Belloni , linux-kernel@vger.kernel.org, stable@vger.kernel.org, Ludovic Desroches , linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org GENMASK and it's callees conduct checking to ensure the passed parameters are valid. One of those checks is for '< 0'. So if an unsigned value is passed, in an invalid comparison takes place. Judging from the current code, it looks as though 'unsigned int' is the correct type to use, so simply cast these small values with no chance of being false negative to signed int for comparison/error checking purposes. Squashes the following W=1 warnings: In file included from /home/lee/projects/linux/kernel/include/linux/bits.h:23, from /home/lee/projects/linux/kernel/include/linux/bitops.h:5, from /home/lee/projects/linux/kernel/include/linux/kernel.h:12, from /home/lee/projects/linux/kernel/include/linux/mfd/syscon/atmel-smc.h:14, from /home/lee/projects/linux/kernel/drivers/mfd/atmel-smc.c:11: /home/lee/projects/linux/kernel/drivers/mfd/atmel-smc.c: In function ‘atmel_smc_cs_encode_ncycles’: /home/lee/projects/linux/kernel/include/linux/bits.h:26:28: warning: comparison of unsigned expression < 0 is always false [-Wtype-limits] 26 | __builtin_constant_p((l) > (h)), (l) > (h), 0))) | ^ /home/lee/projects/linux/kernel/include/linux/build_bug.h:16:62: note: in definition of macro ‘BUILD_BUG_ON_ZERO’ 16 | #define BUILD_BUG_ON_ZERO(e) ((int)(sizeof(struct { int:(-!!(e)); }))) | ^ /home/lee/projects/linux/kernel/include/linux/bits.h:39:3: note: in expansion of macro ‘GENMASK_INPUT_CHECK’ 39 | (GENMASK_INPUT_CHECK(h, l) + __GENMASK(h, l)) | ^~~~~~~~~~~~~~~~~~~ /home/lee/projects/linux/kernel/drivers/mfd/atmel-smc.c:49:25: note: in expansion of macro ‘GENMASK’ 49 | unsigned int lsbmask = GENMASK(msbpos - 1, 0); | ^~~~~~~ /home/lee/projects/linux/kernel/include/linux/bits.h:26:40: warning: comparison of unsigned expression < 0 is always false [-Wtype-limits] 26 | __builtin_constant_p((l) > (h)), (l) > (h), 0))) | ^ /home/lee/projects/linux/kernel/include/linux/build_bug.h:16:62: note: in definition of macro ‘BUILD_BUG_ON_ZERO’ 16 | #define BUILD_BUG_ON_ZERO(e) ((int)(sizeof(struct { int:(-!!(e)); }))) | ^ /home/lee/projects/linux/kernel/include/linux/bits.h:39:3: note: in expansion of macro ‘GENMASK_INPUT_CHECK’ 39 | (GENMASK_INPUT_CHECK(h, l) + __GENMASK(h, l)) | ^~~~~~~~~~~~~~~~~~~ Cc: Cc: Nicolas Ferre Cc: Alexandre Belloni Cc: Ludovic Desroches Cc: Boris Brezillon Signed-off-by: Lee Jones --- drivers/mfd/atmel-smc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/mfd/atmel-smc.c b/drivers/mfd/atmel-smc.c index 1fa2ec950e7df..17bbe9d1fa740 100644 --- a/drivers/mfd/atmel-smc.c +++ b/drivers/mfd/atmel-smc.c @@ -46,8 +46,8 @@ static int atmel_smc_cs_encode_ncycles(unsigned int ncycles, unsigned int msbfactor, unsigned int *encodedval) { - unsigned int lsbmask = GENMASK(msbpos - 1, 0); - unsigned int msbmask = GENMASK(msbwidth - 1, 0); + unsigned int lsbmask = GENMASK((int)msbpos - 1, 0); + unsigned int msbmask = GENMASK((int)msbwidth - 1, 0); unsigned int msb, lsb; int ret = 0;