Received: by 2002:a05:6602:2086:0:0:0:0 with SMTP id a6csp4426508ioa; Wed, 27 Apr 2022 03:43:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzlS2rFaibDe0X+f9GN14lUTBBAyZSVBcztLgsbG4GwTPmYREGDtpTFobT06rmQFHEuuKPq X-Received: by 2002:a17:902:7e83:b0:158:ae65:b926 with SMTP id z3-20020a1709027e8300b00158ae65b926mr19140254pla.41.1651056215291; Wed, 27 Apr 2022 03:43:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651056215; cv=none; d=google.com; s=arc-20160816; b=vFQlrMeGpsrGHR8kGkQsPjXbVYrRUVZVxum2Y3ovOkBhNH/fkSVjIuF1Gkvr7gCONe mHCHxETRNgHinEGAL7VJz8uoblFJAqHwfrwZnTh/e+RgNCx6s33kV2kR3bCBOll0cTge rzKEwMcRI+iUw6C6qFNh/iHIwQPrhnv2qchq7UoGu974szv6aL44P7PumUyGnf8rJXlK MyCwa8RhAL32LIsKlBBEoHDD5JYH1ZdxArPXnpVcCjmYuLVuUKNnl0o4lx8WJnMLWNXF P1PNlOWcqy4NGZM9hSFOEPnyrEsa/DdyEVD31upJAyghFX7qAKHVNce/Fl4T8n6tTSbg W0Ig== 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:sender:dkim-signature; bh=76ANDOqY59ZR47YfaBH9/PPxLh4wv/KZ4Gd05hmQ0dQ=; b=YCdRo7hcPNhSwW5Z+HxEgD5MD2cNSyusEd3cnlNeDtxL1jKu4+Nv7Q9YpfydkIqg7Z uQHtr/qVqXxVz54x2ljIEiUnpSG6VaZBRE/15LofXTcTjY2L7upOEZ2wp5t77zrGCB0d 2xUiyKwvM/qk2JkzWhTaGY3y7ODGO2rdDb+zMppxFqsghZNfDS1+qI8v4FbnGbyygUKK 3j0zVW6wZzchuoTGp/wBvk0ErUaqOzVwSw7wkjdOdC4ZzSgSJm3N/fe+C5PO7vLgH5lm f6zSbXL9zQqwcW2sS613h4HRki4VipDgNV/xbZOJ7xjDIKc2JEBcdBQEVTMEqFPOBPSL rxHw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=HWcdREyE; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id t19-20020a1709028c9300b00153b2d16507si1122741plo.271.2022.04.27.03.43.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Apr 2022 03:43:35 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=HWcdREyE; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 1D9D73FAF7C; Wed, 27 Apr 2022 02:52:51 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348049AbiDZQUk (ORCPT + 99 others); Tue, 26 Apr 2022 12:20:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49254 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236321AbiDZQUg (ORCPT ); Tue, 26 Apr 2022 12:20:36 -0400 Received: from mail-pf1-x429.google.com (mail-pf1-x429.google.com [IPv6:2607:f8b0:4864:20::429]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 24DD86F9E0 for ; Tue, 26 Apr 2022 09:17:29 -0700 (PDT) Received: by mail-pf1-x429.google.com with SMTP id a15so18398914pfv.11 for ; Tue, 26 Apr 2022 09:17:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=76ANDOqY59ZR47YfaBH9/PPxLh4wv/KZ4Gd05hmQ0dQ=; b=HWcdREyEfpxb2LIABQ91++rPQJYSdOCCKwzPTXdsn88FlNOuyUxHKCozdUF2e4HLcC HlJrGoewtonmmCU2lxKR80T9ewPIy3Sym6BIwJ966uP06DAXZcFvuNobY0yf5s7YFRwK TPy9kcWV7gdWjnwLqAFg6EK2kGkKpytJFpEtnCgqBKaE1TadN60CtAtbZqoHbRfPnfNi oPhasfrMPOr5lva58XgAa2kzqJposn3ALiQ90sE8Ok0MkHR427N7l5iQNT7SAQrYyf17 /48HfA3BU9RSgzhKeaamepC4ByYhiWkPfsXqry+EGxZ6Doyhw2ZGqYLV91QLVSF4yANq 8eDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :mime-version:content-transfer-encoding; bh=76ANDOqY59ZR47YfaBH9/PPxLh4wv/KZ4Gd05hmQ0dQ=; b=5svu7Z+SPkJunpqdVaZk/UvtK6RpJKyYRIPo1OeZ5IrINAvCJdaN5q1KkqrIw8PZ9z qJAPZ8rUKz92+CP5HWfgrB3ouvXAaQfm9uqAMVNFF3Mke0bBdlL9A2nAgeZXjSHliEMo cdqS1g9l0MmwhbeIo/1FKhIGGzTQrJgVXfArMoPrjUUql1KVdDh7QDSsMd2UPFAz7Wnc QLLeWm9nZ0qUB6FZSbBo5xZGB+t2jUSSgoY3Xx/y3P9RSr4eRZu/Y3cTG/TuCh9F4Ra7 x2vmbPYwrlAwyHddS1RrcHAJFbyAAosZRqWE5wD9twtZRulKl3fJ8AyOs3A0ox4wPvNN 4jbQ== X-Gm-Message-State: AOAM530AAMzkNZYSB5+7hPqbn02U2fISX9e6YOAiaSdqpMQtS5V5OUry sMVWgJYrv+IS6eqpbghSCBA= X-Received: by 2002:a65:418b:0:b0:382:250b:4dda with SMTP id a11-20020a65418b000000b00382250b4ddamr20598765pgq.428.1650989848573; Tue, 26 Apr 2022 09:17:28 -0700 (PDT) Received: from localhost.localdomain (124x33x176x97.ap124.ftth.ucom.ne.jp. [124.33.176.97]) by smtp.gmail.com with ESMTPSA id s3-20020a056a00194300b004f6664d26eesm17546844pfk.88.2022.04.26.09.17.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Apr 2022 09:17:28 -0700 (PDT) Sender: Vincent Mailhol From: Vincent Mailhol To: Yury Norov , Andy Shevchenko , Rasmus Villemoes , Nathan Chancellor , Nick Desaulniers , Tom Rix Cc: linux-kernel@vger.kernel.org, Arnd Bergmann , Vincent Mailhol Subject: [PATCH] linux/find: ignore -Wtype-limits to reduce W=2 warnings by 34% tree-wide Date: Wed, 27 Apr 2022 01:16:58 +0900 Message-Id: <20220426161658.437466-1-mailhol.vincent@wanadoo.fr> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE autolearn=no 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 find_first_bit(), find_first_and_bit(), find_first_and_bit() and find_first_and_bit() all invokes GENMASK(size - 1, 0). This triggers below warning when compiled with W=2. | ./include/linux/find.h: In function 'find_first_bit': | ./include/linux/bits.h:25:36: warning: comparison of unsigned | expression in '< 0' is always false [-Wtype-limits] | 25 | __is_constexpr((l) > (h)), (l) > (h), 0))) | | ^ | ./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)); }))) | | ^ | ./include/linux/bits.h:25:17: note: in expansion of macro '__is_constexpr' | 25 | __is_constexpr((l) > (h)), (l) > (h), 0))) | | ^~~~~~~~~~~~~~ | ./include/linux/bits.h:38:10: note: in expansion of macro 'GENMASK_INPUT_CHECK' | 38 | (GENMASK_INPUT_CHECK(h, l) + __GENMASK(h, l)) | | ^~~~~~~~~~~~~~~~~~~ | ./include/linux/find.h:119:45: note: in expansion of macro 'GENMASK' | 119 | unsigned long val = *addr & GENMASK(size - 1, 0); | | ^~~~~~~ linux/find.h being a widely used header file, above warning show up in thousand of files which include this header (either directly on indirectly). Because it is a false positive, we just silence -Wtype-limits flag locally to remove the spam. clang does not warn about it, so we just apply the diag_ignore() directive to gcc. By doing so, the warnings for a W=2 build are reduced by 34%. Benchmark was done with gcc 11.2.1 on Linux v5.17 x86_64 allyesconfig (except CONFIG_WERROR). Beforethe patch: 515496 warnings and after: 340097. For reference, past proposal to modify GENMASK_INPUT_CHECK() was rejected in: https://lore.kernel.org/all/20220304124416.1181029-1-mailhol.vincent@wanadoo.fr/ Signed-off-by: Vincent Mailhol --- include/linux/find.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/include/linux/find.h b/include/linux/find.h index 5bb6db213bcb..efd4b3f7dd17 100644 --- a/include/linux/find.h +++ b/include/linux/find.h @@ -103,6 +103,10 @@ unsigned long find_next_zero_bit(const unsigned long *addr, unsigned long size, } #endif +__diag_push(); +__diag_ignore(GCC, 8, "-Wtype-limits", + "GENMASK(size - 1, 0) yields 'comparison of unsigned expression in < 0 is always false' which is OK"); + #ifndef find_first_bit /** * find_first_bit - find the first set bit in a memory region @@ -193,6 +197,8 @@ unsigned long find_last_bit(const unsigned long *addr, unsigned long size) } #endif +__diag_pop(); /* ignore -Wtype-limits */ + /** * find_next_clump8 - find next 8-bit clump with set bits in a memory region * @clump: location to store copy of found clump -- 2.35.1