Received: by 2002:a05:6358:700f:b0:131:369:b2a3 with SMTP id 15csp243881rwo; Tue, 1 Aug 2023 16:25:43 -0700 (PDT) X-Google-Smtp-Source: APBJJlEkfUHCzONnj8PRYwsx7AOlm7UB6u1Zx9tcEu73HJ+jvTPqNQUh8QtIxnZl5CS+jsjp0Gna X-Received: by 2002:a50:ee12:0:b0:51e:1af0:3a90 with SMTP id g18-20020a50ee12000000b0051e1af03a90mr3421334eds.37.1690932343236; Tue, 01 Aug 2023 16:25:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690932343; cv=none; d=google.com; s=arc-20160816; b=arkOCgsnRql++3pk5wlmG8MTl+zOsVtjUoCq5NL12F1LdodHeG7WKS+EKFs7cDXqIs dgQuguo7CItIWho95NjjcGyAru7b0ZMxIxC6mRex+b3xWw9ptN2v8NQgQwIUjtmPRz8P hy36+/Z7/b+pacbutOs1sMeyN/suu0jTbFEdyYWX2Pr8dE3ebQ2b9mFYpnsJk3gTql1I LCDi3eXh1axUxEBXXfDj8ZVNum9J75cksPd3OHblswd4r73s+TUmRxXfn3HzoZYbwqGS l3zQqDj1TvKq7YKhxwvA2vvsJPotLTFDqkGn2dUNW5sIXjWh/ot+goWFSlt/dfDdIxfl kBIA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:mime-version:date :dkim-signature; bh=qdq1QXzvBye3WPzSe4XaK38onFNZo3hs4fREXJmryW4=; fh=5x7hHzX+w3jUmoEKY/vsbx+Ypzq+IiMU9lBan/QcVOA=; b=eDQlMwgxO3pFivQIHVB69HWTmO6DPgRI2soBJWq4Yf1j8lEu45Zo4eS/GBZxQx6dXG V0xzMoHhZ62DV9KtvkldgBX2OMhOCqVuzCZG9iyuPcsvhSWRSiFARJzxx0e+cOgGLOA6 cGAsG1+NzZNaqrpW2JKqAw2x/87JDuXPKtJxHbM3+gKxdW+qgTizjx3lCU5L3BoxPgft B6RzhrWaCBDLl+tln2dcElYtPWsycEVKFrN7QlXz/P1d0QdS+2C6njWaaPNBMeR58EUv 0kMUuZR8zENyo8+ZrlJL60CWhQ9rHLkgSyTzhMDvZAnZ+5+jhjFGzMw9De6egH+t69vy Zw4w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=yFZATxVF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p17-20020a056402075100b00521d2fbcfa2si9787706edy.311.2023.08.01.16.25.18; Tue, 01 Aug 2023 16:25:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=yFZATxVF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232208AbjHAWWi (ORCPT + 99 others); Tue, 1 Aug 2023 18:22:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42320 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232531AbjHAWWb (ORCPT ); Tue, 1 Aug 2023 18:22:31 -0400 Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 696212707 for ; Tue, 1 Aug 2023 15:22:26 -0700 (PDT) Received: by mail-yb1-xb4a.google.com with SMTP id 3f1490d57ef6-d3ae42d146cso347556276.0 for ; Tue, 01 Aug 2023 15:22:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1690928545; x=1691533345; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=qdq1QXzvBye3WPzSe4XaK38onFNZo3hs4fREXJmryW4=; b=yFZATxVFwdyeZsYr/9WCBmdfdj5iHWfXapu8fa8Ga+vqLw+ZGN5LSPG0FGOl+dSWwJ dV8cPD6wXAWF2sw1PaeSS7S2a3SIhuzG7wje2xR8P/+Sygug78lCik23/ZZpU+4PBpcY CiU8R+B5L8IP3kjcZD1OhBgCxddy1Z2pw7qqEYIcl73Miwuo5L5bjWhNvH5F8OMlZgSd rE3P8FC8m2XPvfSaMO38q8amGfJ3eKBf6S5gtNuovLEdZu1lQsQIRojVM493LoldoTZD YdQCqeNo9SPI9tw+Ca8LEMMD51Z6mHn7KMAE52D34Xuc0PAdsvepS0gNhEW3dbY/IV+A QFwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690928545; x=1691533345; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=qdq1QXzvBye3WPzSe4XaK38onFNZo3hs4fREXJmryW4=; b=PINP2gTIjcEeXUhbd/nM/kN5FtWNft/zmQTCK1YSlN3IEaznNIBKs/nuJ5GfoeLeur Tgh7LgcFNxcE/80mmZZ+PElhFd7zkej8wAoNCzh4AD45P8cfS9I85QiZmgGfNhuhL/Ag 2kTWiKV9EMTwnzlQe221YTGn/5XIoL9g8fCitT7ePytB7Zy1jpzyMEv1eeHbFkasMKFe +38Uqm0RcgAYB0i7/Cw/PgUK0AgN7Fs0hYL15cjCiag8GJG/gaJ15SUzLXnG943pmaN7 oojAv+Dmb6E+O15ta1aUSLd4FNGBVIfrQD4XgOw/UasA+3d7hZLdrhYbdHTnhw3Ioqv7 MuVQ== X-Gm-Message-State: ABy/qLbn/cBkiEvlv1zBJUvkH0H9jencgkQT56wYsM/N5VmIRvCxcbcb hDv2A9nfcB/O2GAn4iwpWCVq1YEEvPF46I/L9kU= X-Received: from ndesaulniers-desktop.svl.corp.google.com ([2620:15c:2d1:203:feaa:8649:3c6a:9e94]) (user=ndesaulniers job=sendgmr) by 2002:a05:6902:1804:b0:d07:cb52:a3cf with SMTP id cf4-20020a056902180400b00d07cb52a3cfmr96059ybb.5.1690928545489; Tue, 01 Aug 2023 15:22:25 -0700 (PDT) Date: Tue, 01 Aug 2023 15:22:17 -0700 Mime-Version: 1.0 X-B4-Tracking: v=1; b=H4sIAJiFyWQC/x2NQQqDMBBFryKzNpBJkUivIi4ydlJn0SgzYgvi3 Rtdvvcf/AOMVdjg2RygvIvJUipg28A0p/JmJ6/KEHx4+N6jI9m+Yuxij4EQucsUodaUqiRNZZq v/pNsY72GVTnL774YxvP8A5Si+6hyAAAA X-Developer-Key: i=ndesaulniers@google.com; a=ed25519; pk=UIrHvErwpgNbhCkRZAYSX0CFd/XFEwqX3D0xqtqjNug= X-Developer-Signature: v=1; a=ed25519-sha256; t=1690928543; l=2114; i=ndesaulniers@google.com; s=20220923; h=from:subject:message-id; bh=wXfGM6+rwzEUsf/TAMmubM77ovOgqNDW45eNFnd7nUI=; b=xg1QMLVE2aNnHbUJv06d31odtnY8e9Qbg+57vMuYZRKUErkyMAJirs1yLG26IR6bgSdkUt4tJ qsAFQF5WDRHBt4fXyxuf5JbZDjV/Lzw4AFKfQ3fItCoC9PFd/ghrWHK X-Mailer: b4 0.12.2 Message-ID: <20230801-bitwise-v1-1-799bec468dc4@google.com> Subject: [PATCH] word-at-a-time: use the same return type for has_zero regardless of endianness From: ndesaulniers@google.com To: Arnd Bergmann , Linus Torvalds Cc: Nathan Chancellor , Tom Rix , linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org, llvm@lists.linux.dev, Nick Desaulniers Content-Type: text/plain; charset="utf-8" X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Compiling big-endian targets with Clang produces the diagnostic: fs/namei.c:2173:13: warning: use of bitwise '|' with boolean operands [-Wbitwise-instead-of-logical] } while (!(has_zero(a, &adata, &constants) | has_zero(b, &bdata, &constants))); ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ || fs/namei.c:2173:13: note: cast one or both operands to int to silence this warning It appears that when has_zero was introduced, two definitions were produced with different signatures (in particular different return types). Looking at the usage in hash_name() in fs/namei.c, I suspect that has_zero() is meant to be invoked twice per while loop iteration; using logical-or would not update `bdata` when `a` did not have zeros. So I think it's preferred to always return an unsigned long rather than a bool then update the while loop in hash_name() to use a logical-or rather than bitwise-or. Link: https://github.com/ClangBuiltLinux/linux/issues/1832 Fixes: 36126f8f2ed8 ("word-at-a-time: make the interfaces truly generic") Debugged-by: Nathan Chancellor Signed-off-by: Nick Desaulniers --- include/asm-generic/word-at-a-time.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/asm-generic/word-at-a-time.h b/include/asm-generic/word-at-a-time.h index 20c93f08c993..95a1d214108a 100644 --- a/include/asm-generic/word-at-a-time.h +++ b/include/asm-generic/word-at-a-time.h @@ -38,7 +38,7 @@ static inline long find_zero(unsigned long mask) return (mask >> 8) ? byte : byte + 1; } -static inline bool has_zero(unsigned long val, unsigned long *data, const struct word_at_a_time *c) +static inline unsigned long has_zero(unsigned long val, unsigned long *data, const struct word_at_a_time *c) { unsigned long rhs = val | c->low_bits; *data = rhs; --- base-commit: 18b44bc5a67275641fb26f2c54ba7eef80ac5950 change-id: 20230801-bitwise-7812b11e5fb7 Best regards, -- Nick Desaulniers