Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp5105573pxb; Thu, 14 Oct 2021 19:35:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxHudcpqTSc0MELDfUFOYEs32FDaCgXsd/p2m6V+pzgI4BpB8N47N6LDMHMwOWO9fXvYRzF X-Received: by 2002:a17:907:9908:: with SMTP id ka8mr3597405ejc.164.1634265338852; Thu, 14 Oct 2021 19:35:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634265338; cv=none; d=google.com; s=arc-20160816; b=QoObMoXS3OW83a1XRcmCcCJs7anST6wAWFzPnG7tfPWSCcR545nn1KZ4KeSYEUXsxO iU4VUPFVqMQxCF9gWzTlhIGmMQ1ZyE+1m+cU7U/UTAYqUHlCzRK8RxTxxRX4Es/Mz2EO os2xmh4I/ka+UYLrhcP5lR87LkNvCnhbDHeP5OQB5HUPt5ukwkDgupk4ah7QWU04KnWr u/ibNOlpMrXASIw6qwHSJjH1HVGEEc885GRVgmUODwnsiZU3eJvSxNFRbnxnyTY8oD91 lXpvH/rK/D9hUghykAOvy82DdZFtluQKShB+3NYmn69EJ/2Z0O84qRC3zgAMAYevA69x DeyA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=SFadkErlNIIy3CDYs62TC/yg+H+jpF/VBcGiTV4iRgk=; b=eWIzvo4xcguG9vH8fSKvm6O2YKK5hi/gZWenD0vMJqvZlPM1HJjkekDwU0rFuCd2Fm 8cliLbjYcDCewkp18Xy+oIK3idAFohgTgYTuPwMVPxu3XRARojdl9eqUX9fj+SjrblCf GIObnEneqa0QJKBH5AHDF8/krNCq6ddbvXfeGyy/PcMYHtGonl3cpFu4myq47AVDHXMa IGG08GaQxzrH42EuwsNiHUNuOG7OnagCfmPptvTcUMLsHl/CMaeYvzEMhsEtHhRyVjG1 SkCoy7MZAgrigI0isc8/uJCF5DLaFNyC2vFdiVnAVcme96Ex89DwgjW67c07PK8vFo04 l4Yg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=LyJrl9V7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ga19si8377908ejc.73.2021.10.14.19.35.07; Thu, 14 Oct 2021 19:35:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=LyJrl9V7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232660AbhJNVAS (ORCPT + 99 others); Thu, 14 Oct 2021 17:00:18 -0400 Received: from mail.kernel.org ([198.145.29.99]:50964 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231308AbhJNVAS (ORCPT ); Thu, 14 Oct 2021 17:00:18 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 86DDA60F9E; Thu, 14 Oct 2021 20:58:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1634245092; bh=q0dwlCNGa/Hxh5HuJwhdsfDhhj1HIkksM3XfYlf7fZU=; h=From:To:Cc:Subject:Date:From; b=LyJrl9V7d4APSJLu0NY7Bz4az0bKYR1A982hZ3Zlz0xzKs/aiT+qGErYJHm56/WTF EBZNLtwc1TJE4UgFR7zu/fSvU49U81lYSPFYHrqXjq7xOH1OvXQXdQqyHh+W5h7umu vpm2Jb91JREz5GeoSSWaOlSsakP1JP8OhA8sr1VH8N/RkRfXNbXdUZQAQA/iFYQR/s RRSEsLekKq2rhO4mxxua7W3wrosuJNRJP+tiXpuwN2cdcXQK3cZ8PojKHDo++qdYwa tjKt5XT3LLBPhUrDVTJ54ZThVKz8/nTou/hK2E1t37VVIwpESV+YPdXDOwV3lk4Rx1 GgltfH0r8Twig== From: Nathan Chancellor To: Dmitry Torokhov Cc: Nick Desaulniers , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, llvm@lists.linux.dev, Nathan Chancellor Subject: [PATCH] Input: touchscreen - Avoid bitwise vs logical OR warning Date: Thu, 14 Oct 2021 13:57:57 -0700 Message-Id: <20211014205757.3474635-1-nathan@kernel.org> X-Mailer: git-send-email 2.33.1.637.gf443b226ca MIME-Version: 1.0 X-Patchwork-Bot: notify Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org A new warning in clang points out a few places in this driver where a bitwise OR is being used with boolean types: drivers/input/touchscreen.c:81:17: warning: use of bitwise '|' with boolean operands [-Wbitwise-instead-of-logical] data_present = touchscreen_get_prop_u32(dev, "touchscreen-min-x", ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ This use of a bitwise OR is intentional, as bitwise operations do not short circuit, which allows all the calls to touchscreen_get_prop_u32() to happen so that the last parameter is initialized while coalescing the results of the calls to make a decision after they are all evaluated. To make this clearer to the compiler, use the '|=' operator to assign the result of each touchscreen_get_prop_u32() call to data_present, which keeps the meaning of the code the same but makes it obvious that every one of these calls is expected to happen. Link: https://github.com/ClangBuiltLinux/linux/issues/1472 Signed-off-by: Nathan Chancellor --- drivers/input/touchscreen.c | 42 ++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/drivers/input/touchscreen.c b/drivers/input/touchscreen.c index dd18cb917c4d..4620e20d0190 100644 --- a/drivers/input/touchscreen.c +++ b/drivers/input/touchscreen.c @@ -80,27 +80,27 @@ void touchscreen_parse_properties(struct input_dev *input, bool multitouch, data_present = touchscreen_get_prop_u32(dev, "touchscreen-min-x", input_abs_get_min(input, axis_x), - &minimum) | - touchscreen_get_prop_u32(dev, "touchscreen-size-x", - input_abs_get_max(input, - axis_x) + 1, - &maximum) | - touchscreen_get_prop_u32(dev, "touchscreen-fuzz-x", - input_abs_get_fuzz(input, axis_x), - &fuzz); + &minimum); + data_present |= touchscreen_get_prop_u32(dev, "touchscreen-size-x", + input_abs_get_max(input, + axis_x) + 1, + &maximum); + data_present |= touchscreen_get_prop_u32(dev, "touchscreen-fuzz-x", + input_abs_get_fuzz(input, axis_x), + &fuzz); if (data_present) touchscreen_set_params(input, axis_x, minimum, maximum - 1, fuzz); data_present = touchscreen_get_prop_u32(dev, "touchscreen-min-y", input_abs_get_min(input, axis_y), - &minimum) | - touchscreen_get_prop_u32(dev, "touchscreen-size-y", - input_abs_get_max(input, - axis_y) + 1, - &maximum) | - touchscreen_get_prop_u32(dev, "touchscreen-fuzz-y", - input_abs_get_fuzz(input, axis_y), - &fuzz); + &minimum); + data_present |= touchscreen_get_prop_u32(dev, "touchscreen-size-y", + input_abs_get_max(input, + axis_y) + 1, + &maximum); + data_present |= touchscreen_get_prop_u32(dev, "touchscreen-fuzz-y", + input_abs_get_fuzz(input, axis_y), + &fuzz); if (data_present) touchscreen_set_params(input, axis_y, minimum, maximum - 1, fuzz); @@ -108,11 +108,11 @@ void touchscreen_parse_properties(struct input_dev *input, bool multitouch, data_present = touchscreen_get_prop_u32(dev, "touchscreen-max-pressure", input_abs_get_max(input, axis), - &maximum) | - touchscreen_get_prop_u32(dev, - "touchscreen-fuzz-pressure", - input_abs_get_fuzz(input, axis), - &fuzz); + &maximum); + data_present |= touchscreen_get_prop_u32(dev, + "touchscreen-fuzz-pressure", + input_abs_get_fuzz(input, axis), + &fuzz); if (data_present) touchscreen_set_params(input, axis, 0, maximum, fuzz); base-commit: a41392e0877a271007e9209e63c34cab7527eb43 -- 2.33.1.637.gf443b226ca