From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B374C3FC0 for ; Fri, 17 Sep 2021 04:54:53 +0000 (UTC) Received: by mail.kernel.org (Postfix) with ESMTPSA id 6F58560F92; Fri, 17 Sep 2021 04:54:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1631854493; bh=epGIe7Xmru8ybFQY3hEOWF1YwlANoRaxzAVPbzDag28=; h=From:To:Cc:Subject:Date:From; b=aIE9YuTaa1LMWJAFa1QmyJoNgRMuBUFRJsshM6mw83AFyqVSFAiw/dQicv1LfcqKj a64IRNdoS7KAyIR8N6lqPB1zxofJBNV3hvKJXTNVvUc4ptVQGOzXkHo2KwU6+lTocV TWUPAmMG1UqRS2w6sjErQSnn6/xxTUFxAFR1uGU9kcsiT97LsziOuzGh+iZMa5ArPZ gm//DTFqYtIDCViY5+PFL6XQgaPpDEetG0NSUa8w20OVn9kurLpmA3BB1vXJpPrt6X WHExBjeM3P+pzAcQEfqztyKqTWKiklYJ0U9qGfxEiv5HogNHrK/VkecOK+NzUdkz6G qwPdkSpioPjqg== From: Nathan Chancellor To: Richard Cochran , Jonathan Lemon , "David S. Miller" , Jakub Kicinski Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, llvm@lists.linux.dev, Nathan Chancellor Subject: [PATCH net-next v2] ptp: ocp: Avoid operator precedence warning in ptp_ocp_summary_show() Date: Thu, 16 Sep 2021 21:52:05 -0700 Message-Id: <20210917045204.1385801-1-nathan@kernel.org> X-Mailer: git-send-email 2.33.0 Precedence: bulk X-Mailing-List: llvm@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Bot: notify Content-Transfer-Encoding: 8bit Clang warns twice: drivers/ptp/ptp_ocp.c:2065:16: error: operator '?:' has lower precedence than '&'; '&' will be evaluated first [-Werror,-Wbitwise-conditional-parentheses] on & map ? " ON" : "OFF", src); ~~~~~~~~ ^ drivers/ptp/ptp_ocp.c:2065:16: note: place parentheses around the '&' expression to silence this warning on & map ? " ON" : "OFF", src); ^ ( ) drivers/ptp/ptp_ocp.c:2065:16: note: place parentheses around the '?:' expression to evaluate it first on & map ? " ON" : "OFF", src); ^ on and map are both booleans so this should be a logical AND, which clears up the operator precedence issue. Fixes: a62a56d04e63 ("ptp: ocp: Enable 4th timestamper / PPS generator") Link: https://github.com/ClangBuiltLinux/linux/issues/1457 Suggested-by: Jonathan Lemon Signed-off-by: Nathan Chancellor --- v1 -> v2: https://lore.kernel.org/r/20210916194351.3860836-1-nathan@kernel.org/ * Change fix from adding parentheses to moving from bitwise to logical AND. Thanks to Jonathan for catching that both operands were boolean, which I unfortunately missed. drivers/ptp/ptp_ocp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/ptp/ptp_ocp.c b/drivers/ptp/ptp_ocp.c index 844b1401cc5d..c26708f486cf 100644 --- a/drivers/ptp/ptp_ocp.c +++ b/drivers/ptp/ptp_ocp.c @@ -2062,11 +2062,11 @@ ptp_ocp_summary_show(struct seq_file *s, void *data) on = ioread32(&ts_reg->enable); map = !!(bp->pps_req_map & OCP_REQ_TIMESTAMP); seq_printf(s, "%7s: %s, src: %s\n", "TS3", - on & map ? " ON" : "OFF", src); + on && map ? " ON" : "OFF", src); map = !!(bp->pps_req_map & OCP_REQ_PPS); seq_printf(s, "%7s: %s, src: %s\n", "PPS", - on & map ? " ON" : "OFF", src); + on && map ? " ON" : "OFF", src); } if (bp->irig_out) { base-commit: 8dc84dcd7f74b50f81de3dbf6f6b5b146e3a8eea -- 2.33.0