Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp987248pxb; Thu, 21 Oct 2021 13:27:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxK9JN5iIh/EwFKqkfyShjncpir4CNPqjYAi2P11lJscZLvi0Id26gbc3+ibFzQxWye7e80 X-Received: by 2002:a50:e141:: with SMTP id i1mr10978618edl.157.1634848053045; Thu, 21 Oct 2021 13:27:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634848053; cv=none; d=google.com; s=arc-20160816; b=UzzVGq3RT5FVR22e+u5zPQBm4QbAUPI6vw/gUdFEW3NOyHmE/fK7CNJEXLXFbHqSTh GrFv6VBqE+QPtWOvqk05wd1l5InpAN3KDJa8zr1/mlcqViJpDPcFYaWk43/PIz17p7dD 2LiI6ILJH8alX/mekusNmk91uIcIW0EEpfGjeHjhTFtVFA/Urk3uUS+j+DHHIW+9ZX3k NF4RyBQv88YcmDMIdluuMYoCittWJKgWjnAc6B/ZQB9F+hAb/J8m0q0D+ArtK84+d5ej ucUc6lYU5vnVrGVsyKp6FF4/zSeE09+oUqYM46FV5vQPtlDJ4Ct2phzDxlpUsamhxBRV QEiA== 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=g5DvbE7FLaUTxrTA/Bu9CHuHDbZNO2PDCtym3pmbtcc=; b=M7fzbpuBTLnofhlBjde7aHvLXf5eQeaCjydH9RXiv4cmisirEdmCbQsiRhHj5/dbYJ 5xvjaMEokHB86CRk0SXfh1WHIRv2EosQmeFqT+zH3AaG6hk9+R76h9kJUAGijXs/BvBY GjN57Aw3nDmfXwSUW+vEIzKMOmjRsSLcV7M/4Ph57J4oPxBrnaJvaEz4t/V6Nw7YIvY9 JvoPmvqhdWozOQU5WAbHFDKYLZkoza+TG5Ud7HWh1RgWyYUJiRSiIkmbKNDGxm8FoJrx gIPM7WCSb1Qirhqb6Plo3uS+XSesjKeDSD72M2SWoaZ4xm/WTPSRJ6uUqcUdGsKo6G0F 7l6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="rj/1E0IG"; 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 i2si13093861ejw.120.2021.10.21.13.27.09; Thu, 21 Oct 2021 13:27:33 -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="rj/1E0IG"; 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 S231934AbhJUU0W (ORCPT + 99 others); Thu, 21 Oct 2021 16:26:22 -0400 Received: from mail.kernel.org ([198.145.29.99]:51302 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231887AbhJUU0V (ORCPT ); Thu, 21 Oct 2021 16:26:21 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id E774160E8B; Thu, 21 Oct 2021 20:24:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1634847844; bh=jg39CC34qCaGNNBh/BEjvI4xMifdkAP0+LmruQqx7iM=; h=From:To:Cc:Subject:Date:From; b=rj/1E0IGzxMpU1MhVc+iZ6ua4g06JARLJjbgWZ3SBbmlzbrr5ou0xz1+RlBWk0j6h uHEgFo5Hz/9cpxmbS6yiYSgOnXSDa0cyEUhSdSaI2byUuFk2y6/LItmiraYlkdzHjw aFhOk2e6tgI/9WBgpR18RLoe9IHYhca8l5mu0f0m50VCBuXiOYsrSq+xHCwwk84Zyo WFOhNtqoO0UwlDJ1jZYCsdXT1CrAUwnx+vRv2Vjp3U4h0lHP8x5wMVnOPc94Kf/RAO FjqT7DyXy3J2iJNMRLBOhLuluPNJTgNxUc3UfgE84Y2bX19cBEHiroF4gsUGbWN2mQ WqbpVFPCWazEA== From: Nathan Chancellor To: Nick Terrell Cc: Nick Desaulniers , linux-kernel@vger.kernel.org, llvm@lists.linux.dev, Nathan Chancellor Subject: [PATCH] lib: zstd: Add cast to silence clang's -Wbitwise-instead-of-logical Date: Thu, 21 Oct 2021 13:23:53 -0700 Message-Id: <20211021202353.2356400-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 warns that there is an instance where boolean expressions are being used with bitwise operators instead of logical ones: lib/zstd/decompress/huf_decompress.c:890:25: warning: use of bitwise '&' with boolean operands [-Wbitwise-instead-of-logical] (BIT_reloadDStreamFast(&bitD1) == BIT_DStream_unfinished) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ zstd does this frequently to help with performance, as logical operators have branches whereas bitwise ones do not. To fix this warning in other cases, the expressions were placed on separate lines with the '&=' operator; however, this particular instance was moved away from that so that it could be surrounded by LIKELY, which is a macro for __builtin_expect(), to help with a performance regression, according to upstream zstd pull #1973. Aside from switching to logical operators, which is likely undesirable in this instance, or disabling the warning outright, the solution is casting one of the expressions to an integer type to make it clear to clang that the author knows what they are doing. Add a cast to U32 to silence the warning. The first U32 cast is to silence an instance of -Wshorten-64-to-32 because __builtin_expect() returns long so it cannot be moved. Link: https://github.com/ClangBuiltLinux/linux/issues/1486 Link: https://github.com/facebook/zstd/pull/1973 Reported-by: Nick Desaulniers Signed-off-by: Nathan Chancellor --- lib/zstd/decompress/huf_decompress.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/zstd/decompress/huf_decompress.c b/lib/zstd/decompress/huf_decompress.c index 05570ed5f8be..5105e59ac04a 100644 --- a/lib/zstd/decompress/huf_decompress.c +++ b/lib/zstd/decompress/huf_decompress.c @@ -886,7 +886,7 @@ HUF_decompress4X2_usingDTable_internal_body( HUF_DECODE_SYMBOLX2_0(op2, &bitD2); HUF_DECODE_SYMBOLX2_0(op3, &bitD3); HUF_DECODE_SYMBOLX2_0(op4, &bitD4); - endSignal = (U32)LIKELY( + endSignal = (U32)LIKELY((U32) (BIT_reloadDStreamFast(&bitD1) == BIT_DStream_unfinished) & (BIT_reloadDStreamFast(&bitD2) == BIT_DStream_unfinished) & (BIT_reloadDStreamFast(&bitD3) == BIT_DStream_unfinished) -- 2.33.1.637.gf443b226ca