[next,2/5] minmax: Allow min()/max()/clamp() if the arguments have the same signedness.
Message ID | 454f967d452548a9acfa7c0a0872507e@AcuMS.aculab.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9010:0:b0:3e4:2afc:c1 with SMTP id l16csp2380805vqg; Tue, 25 Jul 2023 03:49:30 -0700 (PDT) X-Google-Smtp-Source: APBJJlGVHD/L31OcDTnQe2Onit4oPgErr9pMN91Act2woP6a07ZKVhxTMJxWkld9gRUkNp/8zbk8 X-Received: by 2002:a17:902:da85:b0:1bb:91f2:bb32 with SMTP id j5-20020a170902da8500b001bb91f2bb32mr12743075plx.39.1690282170617; Tue, 25 Jul 2023 03:49:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690282170; cv=none; d=google.com; s=arc-20160816; b=WZMcA+1RDD4gEsrtJ8bU4EZlG96NCHgY1RvFM0Pjf/AFeBXaAGeqsc+tjC3wd8S2xm 3DMllcNvAPz1VmKXbXaw/jb26GUj/5CikCa7SzSE4sO6kaIDhbw/n2zZVE/oY9keg7Ds j1lNBwc93lNj/B+nKxwOTiLDe7EXTRgx1D9WreECx1oLBlrLOOYerm2It9rAhJW0LsC3 ge+TyxQn8XyMrEEXKnOV6GczhUtVZ/muZvfWJ4W7OTiTC8Q+VyCk6TVmYJ/qUiQDNzNl INRZ4Asu7NNemziThZHzPMDrz/GFHWZh7oTbkmOaHyfkRWsF0A8d4AndTbdDGkDSyUVp FWtw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :mime-version:accept-language:message-id:date:thread-index :thread-topic:subject:to:from; bh=GQIDH+ArfV7rUdxsKuGKCeNhp5BE08KHtyqq2BlqmX8=; fh=6LDawf1JAWamBn08sBajPnNnIEu8LybObHHZW9kFGho=; b=mowqo4g8HZ+BiRaTmHUI7kLpdcgpp/ZsskeoZbQ2+zvUW+CPvPWs7q+NAmLR1a7PGA Ltd5BZva8eZCD71toxlMEu7I6d7ctgZhrQOnccELUpcfCRJBGikBKy/GFpTpmEyUrd6V fiCDUlXRZ+uYNo2t8wk5/NJ6IySgG2yKsnnIXqlOSktdbxhV1ezH237ImZNKtAAVwaan s5sgXE2qW8MVbNBBjHqheWG3jkB+t8acnO66z6A1PxDNIawJtOltYX1o0QyACsg5CRqo 6D+Loy0eSET+F2zagicwKp+pNqJWxHCdAHvsATksxJU64jr6Z5f1fyYAdnYxstaKlF+p HCtw== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=aculab.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b7-20020a170902d50700b001b3c7e6a8c0si11984385plg.531.2023.07.25.03.49.18; Tue, 25 Jul 2023 03:49:30 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=aculab.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230000AbjGYKBL convert rfc822-to-8bit (ORCPT <rfc822;kloczko.tomasz@gmail.com> + 99 others); Tue, 25 Jul 2023 06:01:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59674 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233143AbjGYKA5 (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 25 Jul 2023 06:00:57 -0400 Received: from eu-smtp-delivery-151.mimecast.com (eu-smtp-delivery-151.mimecast.com [185.58.85.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8716C19BF for <linux-kernel@vger.kernel.org>; Tue, 25 Jul 2023 03:00:53 -0700 (PDT) Received: from AcuMS.aculab.com (156.67.243.121 [156.67.243.121]) by relay.mimecast.com with ESMTP with both STARTTLS and AUTH (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id uk-mta-306-g7AkR0QgMKSVaBT6vdJD5Q-1; Tue, 25 Jul 2023 11:00:51 +0100 X-MC-Unique: g7AkR0QgMKSVaBT6vdJD5Q-1 Received: from AcuMS.Aculab.com (10.202.163.6) by AcuMS.aculab.com (10.202.163.6) with Microsoft SMTP Server (TLS) id 15.0.1497.48; Tue, 25 Jul 2023 11:00:49 +0100 Received: from AcuMS.Aculab.com ([::1]) by AcuMS.aculab.com ([::1]) with mapi id 15.00.1497.048; Tue, 25 Jul 2023 11:00:49 +0100 From: David Laight <David.Laight@ACULAB.COM> To: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>, "'Andy Shevchenko'" <andriy.shevchenko@linux.intel.com>, 'Andrew Morton' <akpm@linux-foundation.org>, "Matthew Wilcox (Oracle)" <willy@infradead.org>, Christoph Hellwig <hch@infradead.org>, "Jason A. Donenfeld" <Jason@zx2c4.com> Subject: [PATCH next 2/5] minmax: Allow min()/max()/clamp() if the arguments have the same signedness. Thread-Topic: [PATCH next 2/5] minmax: Allow min()/max()/clamp() if the arguments have the same signedness. Thread-Index: Adm+2wKUQ5yQ6t/FR+W/hRy2DuErJQ== Date: Tue, 25 Jul 2023 10:00:49 +0000 Message-ID: <454f967d452548a9acfa7c0a0872507e@AcuMS.aculab.com> Accept-Language: en-GB, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [10.202.205.107] MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: aculab.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1772389317432651263 X-GMAIL-MSGID: 1772389317432651263 |
Series |
[next,1/5] minmax: Add min_unsigned(a, b) and max_unsigned(a, b)
|
|
Commit Message
David Laight
July 25, 2023, 10 a.m. UTC
The type-check in min()/max() is there to stop unexpected results if a
negative value gets converted to a large unsigned value.
However it also rejects 'unsigned int' v 'unsigned long' compares
which are common and never problematc.
Replace the 'same type' check with a 'same signedness' check.
The new test isn't itself a compile time error, so use static_assert()
to report the error and give a meaningful error message.
Due to the way builtin_choose_expr() works detecting the error in the
'non-constant' side (where static_assert() can be used) also detects
errors when the arguments are constant.
Signed-off-by: David Laight <david.laight@aculab.com>
---
include/linux/minmax.h | 61 +++++++++++++++++++-----------------------
1 file changed, 28 insertions(+), 33 deletions(-)
Comments
Hi David, kernel test robot noticed the following build errors: [auto build test ERROR on akpm-mm/mm-everything] [also build test ERROR on linus/master v6.5-rc3 next-20230725] [cannot apply to next-20230725 hch-configfs/for-next] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch#_base_tree_information] url: https://github.com/intel-lab-lkp/linux/commits/David-Laight/minmax-Add-min_unsigned-a-b-and-max_unsigned-a-b/20230725-180332 base: https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-everything patch link: https://lore.kernel.org/r/454f967d452548a9acfa7c0a0872507e%40AcuMS.aculab.com patch subject: [PATCH next 2/5] minmax: Allow min()/max()/clamp() if the arguments have the same signedness. config: loongarch-allnoconfig (https://download.01.org/0day-ci/archive/20230725/202307252139.Kz3mgUAw-lkp@intel.com/config) compiler: loongarch64-linux-gcc (GCC) 12.3.0 reproduce: (https://download.01.org/0day-ci/archive/20230725/202307252139.Kz3mgUAw-lkp@intel.com/reproduce) If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags | Reported-by: kernel test robot <lkp@intel.com> | Closes: https://lore.kernel.org/oe-kbuild-all/202307252139.Kz3mgUAw-lkp@intel.com/ All errors (new ones prefixed by >>): In file included from include/linux/irqdomain.h:36, from arch/loongarch/include/asm/irq.h:8, from include/linux/irq.h:23, from arch/loongarch/include/asm/hardirq.h:10, from include/linux/hardirq.h:11, from include/linux/interrupt.h:11, from drivers/irqchip/irq-loongarch-cpu.c:8: >> include/linux/irqchip.h:24:10: error: implicit declaration of function '__typecheck'; did you mean 'typecheck'? [-Werror=implicit-function-declaration] 24 | (__typecheck(typecheck_irq_init_cb, &fn) ? fn : fn) | ^~~~~~~~~~~ include/linux/of.h:1478:31: note: in definition of macro '_OF_DECLARE' 1478 | .data = (fn == (fn_type)NULL) ? fn : fn } | ^~ include/linux/irqchip.h:37:9: note: in expansion of macro 'OF_DECLARE_2' 37 | OF_DECLARE_2(irqchip, name, compat, typecheck_irq_init_cb(fn)) | ^~~~~~~~~~~~ include/linux/irqchip.h:37:45: note: in expansion of macro 'typecheck_irq_init_cb' 37 | OF_DECLARE_2(irqchip, name, compat, typecheck_irq_init_cb(fn)) | ^~~~~~~~~~~~~~~~~~~~~ drivers/irqchip/irq-loongarch-cpu.c:110:1: note: in expansion of macro 'IRQCHIP_DECLARE' 110 | IRQCHIP_DECLARE(cpu_intc, "loongson,cpu-interrupt-controller", cpuintc_of_init); | ^~~~~~~~~~~~~~~ >> include/linux/of.h:1478:30: error: initializer element is not constant 1478 | .data = (fn == (fn_type)NULL) ? fn : fn } | ^ include/linux/of.h:1493:17: note: in expansion of macro '_OF_DECLARE' 1493 | _OF_DECLARE(table, name, compat, fn, of_init_fn_2) | ^~~~~~~~~~~ include/linux/irqchip.h:37:9: note: in expansion of macro 'OF_DECLARE_2' 37 | OF_DECLARE_2(irqchip, name, compat, typecheck_irq_init_cb(fn)) | ^~~~~~~~~~~~ drivers/irqchip/irq-loongarch-cpu.c:110:1: note: in expansion of macro 'IRQCHIP_DECLARE' 110 | IRQCHIP_DECLARE(cpu_intc, "loongson,cpu-interrupt-controller", cpuintc_of_init); | ^~~~~~~~~~~~~~~ include/linux/of.h:1478:30: note: (near initialization for '__of_table_cpu_intc.data') 1478 | .data = (fn == (fn_type)NULL) ? fn : fn } | ^ include/linux/of.h:1493:17: note: in expansion of macro '_OF_DECLARE' 1493 | _OF_DECLARE(table, name, compat, fn, of_init_fn_2) | ^~~~~~~~~~~ include/linux/irqchip.h:37:9: note: in expansion of macro 'OF_DECLARE_2' 37 | OF_DECLARE_2(irqchip, name, compat, typecheck_irq_init_cb(fn)) | ^~~~~~~~~~~~ drivers/irqchip/irq-loongarch-cpu.c:110:1: note: in expansion of macro 'IRQCHIP_DECLARE' 110 | IRQCHIP_DECLARE(cpu_intc, "loongson,cpu-interrupt-controller", cpuintc_of_init); | ^~~~~~~~~~~~~~~ cc1: some warnings being treated as errors -- In file included from include/linux/irqdomain.h:36, from arch/loongarch/include/asm/irq.h:8, from include/linux/irq.h:23, from arch/loongarch/include/asm/hardirq.h:10, from include/linux/hardirq.h:11, from include/linux/interrupt.h:11, from drivers/irqchip/irq-loongson-liointc.c:10: >> include/linux/irqchip.h:24:10: error: implicit declaration of function '__typecheck'; did you mean 'typecheck'? [-Werror=implicit-function-declaration] 24 | (__typecheck(typecheck_irq_init_cb, &fn) ? fn : fn) | ^~~~~~~~~~~ include/linux/of.h:1478:31: note: in definition of macro '_OF_DECLARE' 1478 | .data = (fn == (fn_type)NULL) ? fn : fn } | ^~ include/linux/irqchip.h:37:9: note: in expansion of macro 'OF_DECLARE_2' 37 | OF_DECLARE_2(irqchip, name, compat, typecheck_irq_init_cb(fn)) | ^~~~~~~~~~~~ include/linux/irqchip.h:37:45: note: in expansion of macro 'typecheck_irq_init_cb' 37 | OF_DECLARE_2(irqchip, name, compat, typecheck_irq_init_cb(fn)) | ^~~~~~~~~~~~~~~~~~~~~ drivers/irqchip/irq-loongson-liointc.c:371:1: note: in expansion of macro 'IRQCHIP_DECLARE' 371 | IRQCHIP_DECLARE(loongson_liointc_1_0, "loongson,liointc-1.0", liointc_of_init); | ^~~~~~~~~~~~~~~ >> include/linux/of.h:1478:30: error: initializer element is not constant 1478 | .data = (fn == (fn_type)NULL) ? fn : fn } | ^ include/linux/of.h:1493:17: note: in expansion of macro '_OF_DECLARE' 1493 | _OF_DECLARE(table, name, compat, fn, of_init_fn_2) | ^~~~~~~~~~~ include/linux/irqchip.h:37:9: note: in expansion of macro 'OF_DECLARE_2' 37 | OF_DECLARE_2(irqchip, name, compat, typecheck_irq_init_cb(fn)) | ^~~~~~~~~~~~ drivers/irqchip/irq-loongson-liointc.c:371:1: note: in expansion of macro 'IRQCHIP_DECLARE' 371 | IRQCHIP_DECLARE(loongson_liointc_1_0, "loongson,liointc-1.0", liointc_of_init); | ^~~~~~~~~~~~~~~ include/linux/of.h:1478:30: note: (near initialization for '__of_table_loongson_liointc_1_0.data') 1478 | .data = (fn == (fn_type)NULL) ? fn : fn } | ^ include/linux/of.h:1493:17: note: in expansion of macro '_OF_DECLARE' 1493 | _OF_DECLARE(table, name, compat, fn, of_init_fn_2) | ^~~~~~~~~~~ include/linux/irqchip.h:37:9: note: in expansion of macro 'OF_DECLARE_2' 37 | OF_DECLARE_2(irqchip, name, compat, typecheck_irq_init_cb(fn)) | ^~~~~~~~~~~~ drivers/irqchip/irq-loongson-liointc.c:371:1: note: in expansion of macro 'IRQCHIP_DECLARE' 371 | IRQCHIP_DECLARE(loongson_liointc_1_0, "loongson,liointc-1.0", liointc_of_init); | ^~~~~~~~~~~~~~~ >> include/linux/of.h:1478:30: error: initializer element is not constant 1478 | .data = (fn == (fn_type)NULL) ? fn : fn } | ^ include/linux/of.h:1493:17: note: in expansion of macro '_OF_DECLARE' 1493 | _OF_DECLARE(table, name, compat, fn, of_init_fn_2) | ^~~~~~~~~~~ include/linux/irqchip.h:37:9: note: in expansion of macro 'OF_DECLARE_2' 37 | OF_DECLARE_2(irqchip, name, compat, typecheck_irq_init_cb(fn)) | ^~~~~~~~~~~~ drivers/irqchip/irq-loongson-liointc.c:372:1: note: in expansion of macro 'IRQCHIP_DECLARE' 372 | IRQCHIP_DECLARE(loongson_liointc_1_0a, "loongson,liointc-1.0a", liointc_of_init); | ^~~~~~~~~~~~~~~ include/linux/of.h:1478:30: note: (near initialization for '__of_table_loongson_liointc_1_0a.data') 1478 | .data = (fn == (fn_type)NULL) ? fn : fn } | ^ include/linux/of.h:1493:17: note: in expansion of macro '_OF_DECLARE' 1493 | _OF_DECLARE(table, name, compat, fn, of_init_fn_2) | ^~~~~~~~~~~ include/linux/irqchip.h:37:9: note: in expansion of macro 'OF_DECLARE_2' 37 | OF_DECLARE_2(irqchip, name, compat, typecheck_irq_init_cb(fn)) | ^~~~~~~~~~~~ drivers/irqchip/irq-loongson-liointc.c:372:1: note: in expansion of macro 'IRQCHIP_DECLARE' 372 | IRQCHIP_DECLARE(loongson_liointc_1_0a, "loongson,liointc-1.0a", liointc_of_init); | ^~~~~~~~~~~~~~~ >> include/linux/of.h:1478:30: error: initializer element is not constant 1478 | .data = (fn == (fn_type)NULL) ? fn : fn } | ^ include/linux/of.h:1493:17: note: in expansion of macro '_OF_DECLARE' 1493 | _OF_DECLARE(table, name, compat, fn, of_init_fn_2) | ^~~~~~~~~~~ include/linux/irqchip.h:37:9: note: in expansion of macro 'OF_DECLARE_2' 37 | OF_DECLARE_2(irqchip, name, compat, typecheck_irq_init_cb(fn)) | ^~~~~~~~~~~~ drivers/irqchip/irq-loongson-liointc.c:373:1: note: in expansion of macro 'IRQCHIP_DECLARE' 373 | IRQCHIP_DECLARE(loongson_liointc_2_0, "loongson,liointc-2.0", liointc_of_init); | ^~~~~~~~~~~~~~~ include/linux/of.h:1478:30: note: (near initialization for '__of_table_loongson_liointc_2_0.data') 1478 | .data = (fn == (fn_type)NULL) ? fn : fn } | ^ include/linux/of.h:1493:17: note: in expansion of macro '_OF_DECLARE' 1493 | _OF_DECLARE(table, name, compat, fn, of_init_fn_2) | ^~~~~~~~~~~ include/linux/irqchip.h:37:9: note: in expansion of macro 'OF_DECLARE_2' 37 | OF_DECLARE_2(irqchip, name, compat, typecheck_irq_init_cb(fn)) | ^~~~~~~~~~~~ drivers/irqchip/irq-loongson-liointc.c:373:1: note: in expansion of macro 'IRQCHIP_DECLARE' 373 | IRQCHIP_DECLARE(loongson_liointc_2_0, "loongson,liointc-2.0", liointc_of_init); | ^~~~~~~~~~~~~~~ cc1: some warnings being treated as errors -- In file included from include/linux/irqdomain.h:36, from arch/loongarch/include/asm/irq.h:8, from include/linux/irq.h:23, from arch/loongarch/include/asm/hardirq.h:10, from include/linux/hardirq.h:11, from include/linux/interrupt.h:11, from drivers/irqchip/irq-loongson-eiointc.c:11: >> include/linux/irqchip.h:24:10: error: implicit declaration of function '__typecheck'; did you mean 'typecheck'? [-Werror=implicit-function-declaration] 24 | (__typecheck(typecheck_irq_init_cb, &fn) ? fn : fn) | ^~~~~~~~~~~ include/linux/of.h:1478:31: note: in definition of macro '_OF_DECLARE' 1478 | .data = (fn == (fn_type)NULL) ? fn : fn } | ^~ include/linux/irqchip.h:37:9: note: in expansion of macro 'OF_DECLARE_2' 37 | OF_DECLARE_2(irqchip, name, compat, typecheck_irq_init_cb(fn)) | ^~~~~~~~~~~~ include/linux/irqchip.h:37:45: note: in expansion of macro 'typecheck_irq_init_cb' 37 | OF_DECLARE_2(irqchip, name, compat, typecheck_irq_init_cb(fn)) | ^~~~~~~~~~~~~~~~~~~~~ drivers/irqchip/irq-loongson-eiointc.c:508:1: note: in expansion of macro 'IRQCHIP_DECLARE' 508 | IRQCHIP_DECLARE(loongson_ls2k0500_eiointc, "loongson,ls2k0500-eiointc", eiointc_of_init); | ^~~~~~~~~~~~~~~ >> include/linux/of.h:1478:30: error: initializer element is not constant 1478 | .data = (fn == (fn_type)NULL) ? fn : fn } | ^ include/linux/of.h:1493:17: note: in expansion of macro '_OF_DECLARE' 1493 | _OF_DECLARE(table, name, compat, fn, of_init_fn_2) | ^~~~~~~~~~~ include/linux/irqchip.h:37:9: note: in expansion of macro 'OF_DECLARE_2' 37 | OF_DECLARE_2(irqchip, name, compat, typecheck_irq_init_cb(fn)) | ^~~~~~~~~~~~ drivers/irqchip/irq-loongson-eiointc.c:508:1: note: in expansion of macro 'IRQCHIP_DECLARE' 508 | IRQCHIP_DECLARE(loongson_ls2k0500_eiointc, "loongson,ls2k0500-eiointc", eiointc_of_init); | ^~~~~~~~~~~~~~~ include/linux/of.h:1478:30: note: (near initialization for '__of_table_loongson_ls2k0500_eiointc.data') 1478 | .data = (fn == (fn_type)NULL) ? fn : fn } | ^ include/linux/of.h:1493:17: note: in expansion of macro '_OF_DECLARE' 1493 | _OF_DECLARE(table, name, compat, fn, of_init_fn_2) | ^~~~~~~~~~~ include/linux/irqchip.h:37:9: note: in expansion of macro 'OF_DECLARE_2' 37 | OF_DECLARE_2(irqchip, name, compat, typecheck_irq_init_cb(fn)) | ^~~~~~~~~~~~ drivers/irqchip/irq-loongson-eiointc.c:508:1: note: in expansion of macro 'IRQCHIP_DECLARE' 508 | IRQCHIP_DECLARE(loongson_ls2k0500_eiointc, "loongson,ls2k0500-eiointc", eiointc_of_init); | ^~~~~~~~~~~~~~~ >> include/linux/of.h:1478:30: error: initializer element is not constant 1478 | .data = (fn == (fn_type)NULL) ? fn : fn } | ^ include/linux/of.h:1493:17: note: in expansion of macro '_OF_DECLARE' 1493 | _OF_DECLARE(table, name, compat, fn, of_init_fn_2) | ^~~~~~~~~~~ include/linux/irqchip.h:37:9: note: in expansion of macro 'OF_DECLARE_2' 37 | OF_DECLARE_2(irqchip, name, compat, typecheck_irq_init_cb(fn)) | ^~~~~~~~~~~~ drivers/irqchip/irq-loongson-eiointc.c:509:1: note: in expansion of macro 'IRQCHIP_DECLARE' 509 | IRQCHIP_DECLARE(loongson_ls2k2000_eiointc, "loongson,ls2k2000-eiointc", eiointc_of_init); | ^~~~~~~~~~~~~~~ include/linux/of.h:1478:30: note: (near initialization for '__of_table_loongson_ls2k2000_eiointc.data') 1478 | .data = (fn == (fn_type)NULL) ? fn : fn } | ^ include/linux/of.h:1493:17: note: in expansion of macro '_OF_DECLARE' 1493 | _OF_DECLARE(table, name, compat, fn, of_init_fn_2) | ^~~~~~~~~~~ include/linux/irqchip.h:37:9: note: in expansion of macro 'OF_DECLARE_2' 37 | OF_DECLARE_2(irqchip, name, compat, typecheck_irq_init_cb(fn)) | ^~~~~~~~~~~~ drivers/irqchip/irq-loongson-eiointc.c:509:1: note: in expansion of macro 'IRQCHIP_DECLARE' 509 | IRQCHIP_DECLARE(loongson_ls2k2000_eiointc, "loongson,ls2k2000-eiointc", eiointc_of_init); | ^~~~~~~~~~~~~~~ cc1: some warnings being treated as errors -- In file included from include/linux/irqdomain.h:36, from arch/loongarch/include/asm/irq.h:8, from include/linux/irq.h:23, from arch/loongarch/include/asm/hardirq.h:10, from include/linux/hardirq.h:11, from include/linux/interrupt.h:11, from drivers/irqchip/irq-loongson-htvec.c:9: >> include/linux/irqchip.h:24:10: error: implicit declaration of function '__typecheck'; did you mean 'typecheck'? [-Werror=implicit-function-declaration] 24 | (__typecheck(typecheck_irq_init_cb, &fn) ? fn : fn) | ^~~~~~~~~~~ include/linux/of.h:1478:31: note: in definition of macro '_OF_DECLARE' 1478 | .data = (fn == (fn_type)NULL) ? fn : fn } | ^~ include/linux/irqchip.h:37:9: note: in expansion of macro 'OF_DECLARE_2' 37 | OF_DECLARE_2(irqchip, name, compat, typecheck_irq_init_cb(fn)) | ^~~~~~~~~~~~ include/linux/irqchip.h:37:45: note: in expansion of macro 'typecheck_irq_init_cb' 37 | OF_DECLARE_2(irqchip, name, compat, typecheck_irq_init_cb(fn)) | ^~~~~~~~~~~~~~~~~~~~~ drivers/irqchip/irq-loongson-htvec.c:257:1: note: in expansion of macro 'IRQCHIP_DECLARE' 257 | IRQCHIP_DECLARE(htvec, "loongson,htvec-1.0", htvec_of_init); | ^~~~~~~~~~~~~~~ >> include/linux/of.h:1478:30: error: initializer element is not constant 1478 | .data = (fn == (fn_type)NULL) ? fn : fn } | ^ include/linux/of.h:1493:17: note: in expansion of macro '_OF_DECLARE' 1493 | _OF_DECLARE(table, name, compat, fn, of_init_fn_2) | ^~~~~~~~~~~ include/linux/irqchip.h:37:9: note: in expansion of macro 'OF_DECLARE_2' 37 | OF_DECLARE_2(irqchip, name, compat, typecheck_irq_init_cb(fn)) | ^~~~~~~~~~~~ drivers/irqchip/irq-loongson-htvec.c:257:1: note: in expansion of macro 'IRQCHIP_DECLARE' 257 | IRQCHIP_DECLARE(htvec, "loongson,htvec-1.0", htvec_of_init); | ^~~~~~~~~~~~~~~ include/linux/of.h:1478:30: note: (near initialization for '__of_table_htvec.data') 1478 | .data = (fn == (fn_type)NULL) ? fn : fn } | ^ include/linux/of.h:1493:17: note: in expansion of macro '_OF_DECLARE' 1493 | _OF_DECLARE(table, name, compat, fn, of_init_fn_2) | ^~~~~~~~~~~ include/linux/irqchip.h:37:9: note: in expansion of macro 'OF_DECLARE_2' 37 | OF_DECLARE_2(irqchip, name, compat, typecheck_irq_init_cb(fn)) | ^~~~~~~~~~~~ drivers/irqchip/irq-loongson-htvec.c:257:1: note: in expansion of macro 'IRQCHIP_DECLARE' 257 | IRQCHIP_DECLARE(htvec, "loongson,htvec-1.0", htvec_of_init); | ^~~~~~~~~~~~~~~ cc1: some warnings being treated as errors -- In file included from include/linux/irqdomain.h:36, from arch/loongarch/include/asm/irq.h:8, from include/linux/irq.h:23, from arch/loongarch/include/asm/hardirq.h:10, from include/linux/hardirq.h:11, from include/linux/interrupt.h:11, from drivers/irqchip/irq-loongson-pch-pic.c:9: >> include/linux/irqchip.h:24:10: error: implicit declaration of function '__typecheck'; did you mean 'typecheck'? [-Werror=implicit-function-declaration] 24 | (__typecheck(typecheck_irq_init_cb, &fn) ? fn : fn) | ^~~~~~~~~~~ include/linux/of.h:1478:31: note: in definition of macro '_OF_DECLARE' 1478 | .data = (fn == (fn_type)NULL) ? fn : fn } | ^~ include/linux/irqchip.h:37:9: note: in expansion of macro 'OF_DECLARE_2' 37 | OF_DECLARE_2(irqchip, name, compat, typecheck_irq_init_cb(fn)) | ^~~~~~~~~~~~ include/linux/irqchip.h:37:45: note: in expansion of macro 'typecheck_irq_init_cb' 37 | OF_DECLARE_2(irqchip, name, compat, typecheck_irq_init_cb(fn)) | ^~~~~~~~~~~~~~~~~~~~~ drivers/irqchip/irq-loongson-pch-pic.c:358:1: note: in expansion of macro 'IRQCHIP_DECLARE' 358 | IRQCHIP_DECLARE(pch_pic, "loongson,pch-pic-1.0", pch_pic_of_init); | ^~~~~~~~~~~~~~~ >> include/linux/of.h:1478:30: error: initializer element is not constant 1478 | .data = (fn == (fn_type)NULL) ? fn : fn } | ^ include/linux/of.h:1493:17: note: in expansion of macro '_OF_DECLARE' 1493 | _OF_DECLARE(table, name, compat, fn, of_init_fn_2) | ^~~~~~~~~~~ include/linux/irqchip.h:37:9: note: in expansion of macro 'OF_DECLARE_2' 37 | OF_DECLARE_2(irqchip, name, compat, typecheck_irq_init_cb(fn)) | ^~~~~~~~~~~~ drivers/irqchip/irq-loongson-pch-pic.c:358:1: note: in expansion of macro 'IRQCHIP_DECLARE' 358 | IRQCHIP_DECLARE(pch_pic, "loongson,pch-pic-1.0", pch_pic_of_init); | ^~~~~~~~~~~~~~~ include/linux/of.h:1478:30: note: (near initialization for '__of_table_pch_pic.data') 1478 | .data = (fn == (fn_type)NULL) ? fn : fn } | ^ include/linux/of.h:1493:17: note: in expansion of macro '_OF_DECLARE' 1493 | _OF_DECLARE(table, name, compat, fn, of_init_fn_2) | ^~~~~~~~~~~ include/linux/irqchip.h:37:9: note: in expansion of macro 'OF_DECLARE_2' 37 | OF_DECLARE_2(irqchip, name, compat, typecheck_irq_init_cb(fn)) | ^~~~~~~~~~~~ drivers/irqchip/irq-loongson-pch-pic.c:358:1: note: in expansion of macro 'IRQCHIP_DECLARE' 358 | IRQCHIP_DECLARE(pch_pic, "loongson,pch-pic-1.0", pch_pic_of_init); | ^~~~~~~~~~~~~~~ cc1: some warnings being treated as errors .. vim +24 include/linux/irqchip.h f1985002839af8 Marc Zyngier 2021-10-20 22 f1985002839af8 Marc Zyngier 2021-10-20 23 #define typecheck_irq_init_cb(fn) \ f1985002839af8 Marc Zyngier 2021-10-20 @24 (__typecheck(typecheck_irq_init_cb, &fn) ? fn : fn) f1985002839af8 Marc Zyngier 2021-10-20 25
Hi David, kernel test robot noticed the following build errors: [auto build test ERROR on akpm-mm/mm-everything] [also build test ERROR on linus/master v6.5-rc3 next-20230725] [cannot apply to next-20230725 hch-configfs/for-next] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch#_base_tree_information] url: https://github.com/intel-lab-lkp/linux/commits/David-Laight/minmax-Add-min_unsigned-a-b-and-max_unsigned-a-b/20230725-180332 base: https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-everything patch link: https://lore.kernel.org/r/454f967d452548a9acfa7c0a0872507e%40AcuMS.aculab.com patch subject: [PATCH next 2/5] minmax: Allow min()/max()/clamp() if the arguments have the same signedness. config: um-allyesconfig (https://download.01.org/0day-ci/archive/20230725/202307252241.W1SwUDKu-lkp@intel.com/config) compiler: clang version 14.0.6 (https://github.com/llvm/llvm-project.git f28c006a5895fc0e329fe15fead81e37457cb1d1) reproduce: (https://download.01.org/0day-ci/archive/20230725/202307252241.W1SwUDKu-lkp@intel.com/reproduce) If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags | Reported-by: kernel test robot <lkp@intel.com> | Closes: https://lore.kernel.org/oe-kbuild-all/202307252241.W1SwUDKu-lkp@intel.com/ All errors (new ones prefixed by >>): In file included from init/calibrate.c:8: >> include/linux/jiffies.h:427:28: error: implicit declaration of function 'static_assert' is invalid in C99 [-Werror,-Wimplicit-function-declaration] return jiffies_to_clock_t(max(0L, delta)); ^ include/linux/minmax.h:69:19: note: expanded from macro 'max' #define max(x, y) __careful_cmp(max, x, y) ^ include/linux/minmax.h:36:3: note: expanded from macro '__careful_cmp' __cmp_once(op, x, y, __UNIQUE_ID(__x), __UNIQUE_ID(__y))) ^ include/linux/minmax.h:29:3: note: expanded from macro '__cmp_once' static_assert(__types_ok(x, y), \ ^ In file included from init/calibrate.c:8: include/linux/jiffies.h:432:26: error: implicit declaration of function 'static_assert' is invalid in C99 [-Werror,-Wimplicit-function-declaration] return jiffies_to_msecs(max(0L, delta)); ^ include/linux/minmax.h:69:19: note: expanded from macro 'max' #define max(x, y) __careful_cmp(max, x, y) ^ include/linux/minmax.h:36:3: note: expanded from macro '__careful_cmp' __cmp_once(op, x, y, __UNIQUE_ID(__x), __UNIQUE_ID(__y))) ^ include/linux/minmax.h:29:3: note: expanded from macro '__cmp_once' static_assert(__types_ok(x, y), \ ^ 2 errors generated. -- In file included from kernel/workqueue.c:39: In file included from include/linux/hardirq.h:11: In file included from arch/um/include/asm/hardirq.h:5: In file included from include/asm-generic/hardirq.h:17: In file included from include/linux/irq.h:20: In file included from include/linux/io.h:13: In file included from arch/um/include/asm/io.h:24: include/asm-generic/io.h:547:31: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] val = __raw_readb(PCI_IOBASE + addr); ~~~~~~~~~~ ^ include/asm-generic/io.h:560:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] val = __le16_to_cpu((__le16 __force)__raw_readw(PCI_IOBASE + addr)); ~~~~~~~~~~ ^ include/uapi/linux/byteorder/little_endian.h:37:51: note: expanded from macro '__le16_to_cpu' #define __le16_to_cpu(x) ((__force __u16)(__le16)(x)) ^ In file included from kernel/workqueue.c:39: In file included from include/linux/hardirq.h:11: In file included from arch/um/include/asm/hardirq.h:5: In file included from include/asm-generic/hardirq.h:17: In file included from include/linux/irq.h:20: In file included from include/linux/io.h:13: In file included from arch/um/include/asm/io.h:24: include/asm-generic/io.h:573:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] val = __le32_to_cpu((__le32 __force)__raw_readl(PCI_IOBASE + addr)); ~~~~~~~~~~ ^ include/uapi/linux/byteorder/little_endian.h:35:51: note: expanded from macro '__le32_to_cpu' #define __le32_to_cpu(x) ((__force __u32)(__le32)(x)) ^ In file included from kernel/workqueue.c:39: In file included from include/linux/hardirq.h:11: In file included from arch/um/include/asm/hardirq.h:5: In file included from include/asm-generic/hardirq.h:17: In file included from include/linux/irq.h:20: In file included from include/linux/io.h:13: In file included from arch/um/include/asm/io.h:24: include/asm-generic/io.h:584:33: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] __raw_writeb(value, PCI_IOBASE + addr); ~~~~~~~~~~ ^ include/asm-generic/io.h:594:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] __raw_writew((u16 __force)cpu_to_le16(value), PCI_IOBASE + addr); ~~~~~~~~~~ ^ include/asm-generic/io.h:604:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] __raw_writel((u32 __force)cpu_to_le32(value), PCI_IOBASE + addr); ~~~~~~~~~~ ^ include/asm-generic/io.h:692:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] readsb(PCI_IOBASE + addr, buffer, count); ~~~~~~~~~~ ^ include/asm-generic/io.h:700:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] readsw(PCI_IOBASE + addr, buffer, count); ~~~~~~~~~~ ^ include/asm-generic/io.h:708:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] readsl(PCI_IOBASE + addr, buffer, count); ~~~~~~~~~~ ^ include/asm-generic/io.h:717:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] writesb(PCI_IOBASE + addr, buffer, count); ~~~~~~~~~~ ^ include/asm-generic/io.h:726:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] writesw(PCI_IOBASE + addr, buffer, count); ~~~~~~~~~~ ^ include/asm-generic/io.h:735:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] writesl(PCI_IOBASE + addr, buffer, count); ~~~~~~~~~~ ^ >> kernel/workqueue.c:4579:9: error: static_assert expression is not an integral constant expression return clamp_val(max_active, 1, lim); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ include/linux/minmax.h:171:32: note: expanded from macro 'clamp_val' #define clamp_val(val, lo, hi) clamp_t(typeof(val), val, lo, hi) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ include/linux/minmax.h:158:36: note: expanded from macro 'clamp_t' #define clamp_t(type, val, lo, hi) __careful_clamp((type)(val), (type)(lo), (type)(hi)) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ include/linux/minmax.h:54:3: note: expanded from macro '__careful_clamp' __clamp_once(val, lo, hi, __UNIQUE_ID(__val), \ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ include/linux/minmax.h:45:17: note: expanded from macro '__clamp_once' static_assert(!__is_constexpr((lo) > (hi)) || (lo) <= (hi), \ ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ include/linux/build_bug.h:77:50: note: expanded from macro 'static_assert' #define static_assert(expr, ...) __static_assert(expr, ##__VA_ARGS__, #expr) ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~ include/linux/build_bug.h:78:56: note: expanded from macro '__static_assert' #define __static_assert(expr, msg, ...) _Static_assert(expr, msg) ^~~~ 12 warnings and 1 error generated. -- In file included from mm/mm_init.c:17: In file included from include/linux/memblock.h:13: In file included from arch/um/include/asm/dma.h:5: In file included from arch/um/include/asm/io.h:24: include/asm-generic/io.h:547:31: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] val = __raw_readb(PCI_IOBASE + addr); ~~~~~~~~~~ ^ include/asm-generic/io.h:560:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] val = __le16_to_cpu((__le16 __force)__raw_readw(PCI_IOBASE + addr)); ~~~~~~~~~~ ^ include/uapi/linux/byteorder/little_endian.h:37:51: note: expanded from macro '__le16_to_cpu' #define __le16_to_cpu(x) ((__force __u16)(__le16)(x)) ^ In file included from mm/mm_init.c:17: In file included from include/linux/memblock.h:13: In file included from arch/um/include/asm/dma.h:5: In file included from arch/um/include/asm/io.h:24: include/asm-generic/io.h:573:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] val = __le32_to_cpu((__le32 __force)__raw_readl(PCI_IOBASE + addr)); ~~~~~~~~~~ ^ include/uapi/linux/byteorder/little_endian.h:35:51: note: expanded from macro '__le32_to_cpu' #define __le32_to_cpu(x) ((__force __u32)(__le32)(x)) ^ In file included from mm/mm_init.c:17: In file included from include/linux/memblock.h:13: In file included from arch/um/include/asm/dma.h:5: In file included from arch/um/include/asm/io.h:24: include/asm-generic/io.h:584:33: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] __raw_writeb(value, PCI_IOBASE + addr); ~~~~~~~~~~ ^ include/asm-generic/io.h:594:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] __raw_writew((u16 __force)cpu_to_le16(value), PCI_IOBASE + addr); ~~~~~~~~~~ ^ include/asm-generic/io.h:604:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] __raw_writel((u32 __force)cpu_to_le32(value), PCI_IOBASE + addr); ~~~~~~~~~~ ^ include/asm-generic/io.h:692:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] readsb(PCI_IOBASE + addr, buffer, count); ~~~~~~~~~~ ^ include/asm-generic/io.h:700:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] readsw(PCI_IOBASE + addr, buffer, count); ~~~~~~~~~~ ^ include/asm-generic/io.h:708:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] readsl(PCI_IOBASE + addr, buffer, count); ~~~~~~~~~~ ^ include/asm-generic/io.h:717:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] writesb(PCI_IOBASE + addr, buffer, count); ~~~~~~~~~~ ^ include/asm-generic/io.h:726:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] writesw(PCI_IOBASE + addr, buffer, count); ~~~~~~~~~~ ^ include/asm-generic/io.h:735:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] writesl(PCI_IOBASE + addr, buffer, count); ~~~~~~~~~~ ^ >> mm/mm_init.c:908:14: error: static_assert expression is not an integral constant expression start_pfn = clamp(start_pfn, zone_start_pfn, zone_end_pfn); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ include/linux/minmax.h:123:28: note: expanded from macro 'clamp' #define clamp(val, lo, hi) __careful_clamp(val, lo, hi) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ include/linux/minmax.h:54:3: note: expanded from macro '__careful_clamp' __clamp_once(val, lo, hi, __UNIQUE_ID(__val), \ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ include/linux/minmax.h:45:17: note: expanded from macro '__clamp_once' static_assert(!__is_constexpr((lo) > (hi)) || (lo) <= (hi), \ ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ include/linux/build_bug.h:77:50: note: expanded from macro 'static_assert' #define static_assert(expr, ...) __static_assert(expr, ##__VA_ARGS__, #expr) ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~ include/linux/build_bug.h:78:56: note: expanded from macro '__static_assert' #define __static_assert(expr, msg, ...) _Static_assert(expr, msg) ^~~~ mm/mm_init.c:909:12: error: static_assert expression is not an integral constant expression end_pfn = clamp(end_pfn, zone_start_pfn, zone_end_pfn); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ include/linux/minmax.h:123:28: note: expanded from macro 'clamp' #define clamp(val, lo, hi) __careful_clamp(val, lo, hi) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ include/linux/minmax.h:54:3: note: expanded from macro '__careful_clamp' __clamp_once(val, lo, hi, __UNIQUE_ID(__val), \ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ include/linux/minmax.h:45:17: note: expanded from macro '__clamp_once' static_assert(!__is_constexpr((lo) > (hi)) || (lo) <= (hi), \ ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ include/linux/build_bug.h:77:50: note: expanded from macro 'static_assert' #define static_assert(expr, ...) __static_assert(expr, ##__VA_ARGS__, #expr) ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~ include/linux/build_bug.h:78:56: note: expanded from macro '__static_assert' #define __static_assert(expr, msg, ...) _Static_assert(expr, msg) ^~~~ mm/mm_init.c:1145:15: error: static_assert expression is not an integral constant expression start_pfn = clamp(start_pfn, range_start_pfn, range_end_pfn); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ include/linux/minmax.h:123:28: note: expanded from macro 'clamp' #define clamp(val, lo, hi) __careful_clamp(val, lo, hi) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ include/linux/minmax.h:54:3: note: expanded from macro '__careful_clamp' __clamp_once(val, lo, hi, __UNIQUE_ID(__val), \ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ include/linux/minmax.h:45:17: note: expanded from macro '__clamp_once' static_assert(!__is_constexpr((lo) > (hi)) || (lo) <= (hi), \ ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ include/linux/build_bug.h:77:50: note: expanded from macro 'static_assert' #define static_assert(expr, ...) __static_assert(expr, ##__VA_ARGS__, #expr) ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~ include/linux/build_bug.h:78:56: note: expanded from macro '__static_assert' #define __static_assert(expr, msg, ...) _Static_assert(expr, msg) ^~~~ mm/mm_init.c:1146:13: error: static_assert expression is not an integral constant expression end_pfn = clamp(end_pfn, range_start_pfn, range_end_pfn); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ include/linux/minmax.h:123:28: note: expanded from macro 'clamp' #define clamp(val, lo, hi) __careful_clamp(val, lo, hi) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ include/linux/minmax.h:54:3: note: expanded from macro '__careful_clamp' __clamp_once(val, lo, hi, __UNIQUE_ID(__val), \ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ include/linux/minmax.h:45:17: note: expanded from macro '__clamp_once' static_assert(!__is_constexpr((lo) > (hi)) || (lo) <= (hi), \ ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ include/linux/build_bug.h:77:50: note: expanded from macro 'static_assert' #define static_assert(expr, ...) __static_assert(expr, ##__VA_ARGS__, #expr) ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~ include/linux/build_bug.h:78:56: note: expanded from macro '__static_assert' #define __static_assert(expr, msg, ...) _Static_assert(expr, msg) ^~~~ mm/mm_init.c:1189:16: error: static_assert expression is not an integral constant expression start_pfn = clamp(memblock_region_memory_base_pfn(r), ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ include/linux/minmax.h:123:28: note: expanded from macro 'clamp' #define clamp(val, lo, hi) __careful_clamp(val, lo, hi) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ include/linux/minmax.h:54:3: note: expanded from macro '__careful_clamp' __clamp_once(val, lo, hi, __UNIQUE_ID(__val), \ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ include/linux/minmax.h:45:17: note: expanded from macro '__clamp_once' static_assert(!__is_constexpr((lo) > (hi)) || (lo) <= (hi), \ ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ include/linux/build_bug.h:77:50: note: expanded from macro 'static_assert' #define static_assert(expr, ...) __static_assert(expr, ##__VA_ARGS__, #expr) ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~ include/linux/build_bug.h:78:56: note: expanded from macro '__static_assert' #define __static_assert(expr, msg, ...) _Static_assert(expr, msg) ^~~~ mm/mm_init.c:1191:14: error: static_assert expression is not an integral constant expression end_pfn = clamp(memblock_region_memory_end_pfn(r), ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ include/linux/minmax.h:123:28: note: expanded from macro 'clamp' #define clamp(val, lo, hi) __careful_clamp(val, lo, hi) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ include/linux/minmax.h:54:3: note: expanded from macro '__careful_clamp' __clamp_once(val, lo, hi, __UNIQUE_ID(__val), \ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ include/linux/minmax.h:45:17: note: expanded from macro '__clamp_once' static_assert(!__is_constexpr((lo) > (hi)) || (lo) <= (hi), \ -- In file included from mm/page_alloc.c:20: In file included from include/linux/highmem.h:12: In file included from include/linux/hardirq.h:11: In file included from arch/um/include/asm/hardirq.h:5: In file included from include/asm-generic/hardirq.h:17: In file included from include/linux/irq.h:20: In file included from include/linux/io.h:13: In file included from arch/um/include/asm/io.h:24: include/asm-generic/io.h:547:31: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] val = __raw_readb(PCI_IOBASE + addr); ~~~~~~~~~~ ^ include/asm-generic/io.h:560:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] val = __le16_to_cpu((__le16 __force)__raw_readw(PCI_IOBASE + addr)); ~~~~~~~~~~ ^ include/uapi/linux/byteorder/little_endian.h:37:51: note: expanded from macro '__le16_to_cpu' #define __le16_to_cpu(x) ((__force __u16)(__le16)(x)) ^ In file included from mm/page_alloc.c:20: In file included from include/linux/highmem.h:12: In file included from include/linux/hardirq.h:11: In file included from arch/um/include/asm/hardirq.h:5: In file included from include/asm-generic/hardirq.h:17: In file included from include/linux/irq.h:20: In file included from include/linux/io.h:13: In file included from arch/um/include/asm/io.h:24: include/asm-generic/io.h:573:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] val = __le32_to_cpu((__le32 __force)__raw_readl(PCI_IOBASE + addr)); ~~~~~~~~~~ ^ include/uapi/linux/byteorder/little_endian.h:35:51: note: expanded from macro '__le32_to_cpu' #define __le32_to_cpu(x) ((__force __u32)(__le32)(x)) ^ In file included from mm/page_alloc.c:20: In file included from include/linux/highmem.h:12: In file included from include/linux/hardirq.h:11: In file included from arch/um/include/asm/hardirq.h:5: In file included from include/asm-generic/hardirq.h:17: In file included from include/linux/irq.h:20: In file included from include/linux/io.h:13: In file included from arch/um/include/asm/io.h:24: include/asm-generic/io.h:584:33: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] __raw_writeb(value, PCI_IOBASE + addr); ~~~~~~~~~~ ^ include/asm-generic/io.h:594:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] __raw_writew((u16 __force)cpu_to_le16(value), PCI_IOBASE + addr); ~~~~~~~~~~ ^ include/asm-generic/io.h:604:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] __raw_writel((u32 __force)cpu_to_le32(value), PCI_IOBASE + addr); ~~~~~~~~~~ ^ include/asm-generic/io.h:692:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] readsb(PCI_IOBASE + addr, buffer, count); ~~~~~~~~~~ ^ include/asm-generic/io.h:700:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] readsw(PCI_IOBASE + addr, buffer, count); ~~~~~~~~~~ ^ include/asm-generic/io.h:708:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] readsl(PCI_IOBASE + addr, buffer, count); ~~~~~~~~~~ ^ include/asm-generic/io.h:717:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] writesb(PCI_IOBASE + addr, buffer, count); ~~~~~~~~~~ ^ include/asm-generic/io.h:726:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] writesw(PCI_IOBASE + addr, buffer, count); ~~~~~~~~~~ ^ include/asm-generic/io.h:735:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] writesl(PCI_IOBASE + addr, buffer, count); ~~~~~~~~~~ ^ >> mm/page_alloc.c:2415:10: error: static_assert expression is not an integral constant expression batch = clamp(batch, min_nr_free, max_nr_free); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ include/linux/minmax.h:123:28: note: expanded from macro 'clamp' #define clamp(val, lo, hi) __careful_clamp(val, lo, hi) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ include/linux/minmax.h:54:3: note: expanded from macro '__careful_clamp' __clamp_once(val, lo, hi, __UNIQUE_ID(__val), \ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ include/linux/minmax.h:45:17: note: expanded from macro '__clamp_once' static_assert(!__is_constexpr((lo) > (hi)) || (lo) <= (hi), \ ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ include/linux/build_bug.h:77:50: note: expanded from macro 'static_assert' #define static_assert(expr, ...) __static_assert(expr, ##__VA_ARGS__, #expr) ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~ include/linux/build_bug.h:78:56: note: expanded from macro '__static_assert' #define __static_assert(expr, msg, ...) _Static_assert(expr, msg) ^~~~ 12 warnings and 1 error generated. .. vim +/static_assert +427 include/linux/jiffies.h ae60d6a0e3a919 Nicholas Mc Guire 2015-05-28 420 9ca308506062fc Baolin Wang 2015-07-29 421 extern unsigned long timespec64_to_jiffies(const struct timespec64 *value); 9ca308506062fc Baolin Wang 2015-07-29 422 extern void jiffies_to_timespec64(const unsigned long jiffies, 9ca308506062fc Baolin Wang 2015-07-29 423 struct timespec64 *value); cbbc719fccdb8c hank 2011-09-20 424 extern clock_t jiffies_to_clock_t(unsigned long x); a399a8053164ec Eric Dumazet 2012-08-08 425 static inline clock_t jiffies_delta_to_clock_t(long delta) a399a8053164ec Eric Dumazet 2012-08-08 426 { a399a8053164ec Eric Dumazet 2012-08-08 @427 return jiffies_to_clock_t(max(0L, delta)); a399a8053164ec Eric Dumazet 2012-08-08 428 } a399a8053164ec Eric Dumazet 2012-08-08 429
Hi David, kernel test robot noticed the following build errors: [auto build test ERROR on akpm-mm/mm-everything] [also build test ERROR on linus/master v6.5-rc3 next-20230725] [cannot apply to next-20230725 hch-configfs/for-next] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch#_base_tree_information] url: https://github.com/intel-lab-lkp/linux/commits/David-Laight/minmax-Add-min_unsigned-a-b-and-max_unsigned-a-b/20230725-180332 base: https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-everything patch link: https://lore.kernel.org/r/454f967d452548a9acfa7c0a0872507e%40AcuMS.aculab.com patch subject: [PATCH next 2/5] minmax: Allow min()/max()/clamp() if the arguments have the same signedness. config: um-allnoconfig (https://download.01.org/0day-ci/archive/20230725/202307252359.Is4T2MXC-lkp@intel.com/config) compiler: clang version 17.0.0 (https://github.com/llvm/llvm-project.git 4a5ac14ee968ff0ad5d2cc1ffa0299048db4c88a) reproduce: (https://download.01.org/0day-ci/archive/20230725/202307252359.Is4T2MXC-lkp@intel.com/reproduce) If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags | Reported-by: kernel test robot <lkp@intel.com> | Closes: https://lore.kernel.org/oe-kbuild-all/202307252359.Is4T2MXC-lkp@intel.com/ All errors (new ones prefixed by >>): In file included from init/calibrate.c:8: >> include/linux/jiffies.h:427:28: error: call to undeclared function 'static_assert'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration] 427 | return jiffies_to_clock_t(max(0L, delta)); | ^ include/linux/minmax.h:69:19: note: expanded from macro 'max' 69 | #define max(x, y) __careful_cmp(max, x, y) | ^ include/linux/minmax.h:36:3: note: expanded from macro '__careful_cmp' 36 | __cmp_once(op, x, y, __UNIQUE_ID(__x), __UNIQUE_ID(__y))) | ^ include/linux/minmax.h:29:3: note: expanded from macro '__cmp_once' 29 | static_assert(__types_ok(x, y), \ | ^ In file included from init/calibrate.c:8: include/linux/jiffies.h:432:26: error: call to undeclared function 'static_assert'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration] 432 | return jiffies_to_msecs(max(0L, delta)); | ^ include/linux/minmax.h:69:19: note: expanded from macro 'max' 69 | #define max(x, y) __careful_cmp(max, x, y) | ^ include/linux/minmax.h:36:3: note: expanded from macro '__careful_cmp' 36 | __cmp_once(op, x, y, __UNIQUE_ID(__x), __UNIQUE_ID(__y))) | ^ include/linux/minmax.h:29:3: note: expanded from macro '__cmp_once' 29 | static_assert(__types_ok(x, y), \ | ^ 2 errors generated. -- In file included from fs/signalfd.c:22: In file included from include/linux/poll.h:7: In file included from include/linux/ktime.h:25: >> include/linux/jiffies.h:427:28: error: call to undeclared function 'static_assert'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration] 427 | return jiffies_to_clock_t(max(0L, delta)); | ^ include/linux/minmax.h:69:19: note: expanded from macro 'max' 69 | #define max(x, y) __careful_cmp(max, x, y) | ^ include/linux/minmax.h:36:3: note: expanded from macro '__careful_cmp' 36 | __cmp_once(op, x, y, __UNIQUE_ID(__x), __UNIQUE_ID(__y))) | ^ include/linux/minmax.h:29:3: note: expanded from macro '__cmp_once' 29 | static_assert(__types_ok(x, y), \ | ^ In file included from fs/signalfd.c:22: In file included from include/linux/poll.h:7: In file included from include/linux/ktime.h:25: include/linux/jiffies.h:432:26: error: call to undeclared function 'static_assert'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration] 432 | return jiffies_to_msecs(max(0L, delta)); | ^ include/linux/minmax.h:69:19: note: expanded from macro 'max' 69 | #define max(x, y) __careful_cmp(max, x, y) | ^ include/linux/minmax.h:36:3: note: expanded from macro '__careful_cmp' 36 | __cmp_once(op, x, y, __UNIQUE_ID(__x), __UNIQUE_ID(__y))) | ^ include/linux/minmax.h:29:3: note: expanded from macro '__cmp_once' 29 | static_assert(__types_ok(x, y), \ | ^ In file included from fs/signalfd.c:22: In file included from include/linux/poll.h:10: In file included from include/linux/fs.h:33: In file included from include/linux/percpu-rwsem.h:7: In file included from include/linux/rcuwait.h:6: In file included from include/linux/sched/signal.h:6: include/linux/signal.h:97:11: warning: array index 3 is past the end of the array (that has type 'unsigned long[1]') [-Warray-bounds] 97 | return (set->sig[3] | set->sig[2] | | ^ ~ arch/x86/include/asm/signal.h:24:2: note: array 'sig' declared here 24 | unsigned long sig[_NSIG_WORDS]; | ^ In file included from fs/signalfd.c:22: In file included from include/linux/poll.h:10: In file included from include/linux/fs.h:33: In file included from include/linux/percpu-rwsem.h:7: In file included from include/linux/rcuwait.h:6: In file included from include/linux/sched/signal.h:6: include/linux/signal.h:97:25: warning: array index 2 is past the end of the array (that has type 'unsigned long[1]') [-Warray-bounds] 97 | return (set->sig[3] | set->sig[2] | | ^ ~ arch/x86/include/asm/signal.h:24:2: note: array 'sig' declared here 24 | unsigned long sig[_NSIG_WORDS]; | ^ In file included from fs/signalfd.c:22: In file included from include/linux/poll.h:10: In file included from include/linux/fs.h:33: In file included from include/linux/percpu-rwsem.h:7: In file included from include/linux/rcuwait.h:6: In file included from include/linux/sched/signal.h:6: include/linux/signal.h:98:4: warning: array index 1 is past the end of the array (that has type 'unsigned long[1]') [-Warray-bounds] 98 | set->sig[1] | set->sig[0]) == 0; | ^ ~ arch/x86/include/asm/signal.h:24:2: note: array 'sig' declared here 24 | unsigned long sig[_NSIG_WORDS]; | ^ In file included from fs/signalfd.c:22: In file included from include/linux/poll.h:10: In file included from include/linux/fs.h:33: In file included from include/linux/percpu-rwsem.h:7: In file included from include/linux/rcuwait.h:6: In file included from include/linux/sched/signal.h:6: include/linux/signal.h:100:11: warning: array index 1 is past the end of the array (that has type 'unsigned long[1]') [-Warray-bounds] 100 | return (set->sig[1] | set->sig[0]) == 0; | ^ ~ arch/x86/include/asm/signal.h:24:2: note: array 'sig' declared here 24 | unsigned long sig[_NSIG_WORDS]; | ^ In file included from fs/signalfd.c:22: In file included from include/linux/poll.h:10: In file included from include/linux/fs.h:33: In file included from include/linux/percpu-rwsem.h:7: In file included from include/linux/rcuwait.h:6: In file included from include/linux/sched/signal.h:6: include/linux/signal.h:113:11: warning: array index 3 is past the end of the array (that has type 'const unsigned long[1]') [-Warray-bounds] 113 | return (set1->sig[3] == set2->sig[3]) && | ^ ~ arch/x86/include/asm/signal.h:24:2: note: array 'sig' declared here 24 | unsigned long sig[_NSIG_WORDS]; | ^ In file included from fs/signalfd.c:22: In file included from include/linux/poll.h:10: In file included from include/linux/fs.h:33: In file included from include/linux/percpu-rwsem.h:7: In file included from include/linux/rcuwait.h:6: In file included from include/linux/sched/signal.h:6: include/linux/signal.h:113:27: warning: array index 3 is past the end of the array (that has type 'const unsigned long[1]') [-Warray-bounds] 113 | return (set1->sig[3] == set2->sig[3]) && | ^ ~ arch/x86/include/asm/signal.h:24:2: note: array 'sig' declared here 24 | unsigned long sig[_NSIG_WORDS]; | ^ In file included from fs/signalfd.c:22: In file included from include/linux/poll.h:10: -- In file included from kernel/irq/spurious.c:8: >> include/linux/jiffies.h:427:28: error: call to undeclared function 'static_assert'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration] 427 | return jiffies_to_clock_t(max(0L, delta)); | ^ include/linux/minmax.h:69:19: note: expanded from macro 'max' 69 | #define max(x, y) __careful_cmp(max, x, y) | ^ include/linux/minmax.h:36:3: note: expanded from macro '__careful_cmp' 36 | __cmp_once(op, x, y, __UNIQUE_ID(__x), __UNIQUE_ID(__y))) | ^ include/linux/minmax.h:29:3: note: expanded from macro '__cmp_once' 29 | static_assert(__types_ok(x, y), \ | ^ In file included from kernel/irq/spurious.c:8: include/linux/jiffies.h:432:26: error: call to undeclared function 'static_assert'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration] 432 | return jiffies_to_msecs(max(0L, delta)); | ^ include/linux/minmax.h:69:19: note: expanded from macro 'max' 69 | #define max(x, y) __careful_cmp(max, x, y) | ^ include/linux/minmax.h:36:3: note: expanded from macro '__careful_cmp' 36 | __cmp_once(op, x, y, __UNIQUE_ID(__x), __UNIQUE_ID(__y))) | ^ include/linux/minmax.h:29:3: note: expanded from macro '__cmp_once' 29 | static_assert(__types_ok(x, y), \ | ^ In file included from kernel/irq/spurious.c:9: In file included from include/linux/irq.h:20: In file included from include/linux/io.h:13: In file included from arch/um/include/asm/io.h:24: include/asm-generic/io.h:547:31: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] 547 | val = __raw_readb(PCI_IOBASE + addr); | ~~~~~~~~~~ ^ include/asm-generic/io.h:560:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] 560 | val = __le16_to_cpu((__le16 __force)__raw_readw(PCI_IOBASE + addr)); | ~~~~~~~~~~ ^ include/uapi/linux/byteorder/little_endian.h:37:51: note: expanded from macro '__le16_to_cpu' 37 | #define __le16_to_cpu(x) ((__force __u16)(__le16)(x)) | ^ In file included from kernel/irq/spurious.c:9: In file included from include/linux/irq.h:20: In file included from include/linux/io.h:13: In file included from arch/um/include/asm/io.h:24: include/asm-generic/io.h:573:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] 573 | val = __le32_to_cpu((__le32 __force)__raw_readl(PCI_IOBASE + addr)); | ~~~~~~~~~~ ^ include/uapi/linux/byteorder/little_endian.h:35:51: note: expanded from macro '__le32_to_cpu' 35 | #define __le32_to_cpu(x) ((__force __u32)(__le32)(x)) | ^ In file included from kernel/irq/spurious.c:9: In file included from include/linux/irq.h:20: In file included from include/linux/io.h:13: In file included from arch/um/include/asm/io.h:24: include/asm-generic/io.h:584:33: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] 584 | __raw_writeb(value, PCI_IOBASE + addr); | ~~~~~~~~~~ ^ include/asm-generic/io.h:594:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] 594 | __raw_writew((u16 __force)cpu_to_le16(value), PCI_IOBASE + addr); | ~~~~~~~~~~ ^ include/asm-generic/io.h:604:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] 604 | __raw_writel((u32 __force)cpu_to_le32(value), PCI_IOBASE + addr); | ~~~~~~~~~~ ^ include/asm-generic/io.h:692:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] 692 | readsb(PCI_IOBASE + addr, buffer, count); | ~~~~~~~~~~ ^ include/asm-generic/io.h:700:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] 700 | readsw(PCI_IOBASE + addr, buffer, count); | ~~~~~~~~~~ ^ include/asm-generic/io.h:708:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] 708 | readsl(PCI_IOBASE + addr, buffer, count); | ~~~~~~~~~~ ^ include/asm-generic/io.h:717:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] 717 | writesb(PCI_IOBASE + addr, buffer, count); | ~~~~~~~~~~ ^ include/asm-generic/io.h:726:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] 726 | writesw(PCI_IOBASE + addr, buffer, count); | ~~~~~~~~~~ ^ include/asm-generic/io.h:735:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] 735 | writesl(PCI_IOBASE + addr, buffer, count); | ~~~~~~~~~~ ^ 12 warnings and 2 errors generated. -- In file included from kernel/time/alarmtimer.c:16: In file included from include/linux/hrtimer.h:15: In file included from include/linux/hrtimer_defs.h:5: In file included from include/linux/ktime.h:25: >> include/linux/jiffies.h:427:28: error: call to undeclared function 'static_assert'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration] 427 | return jiffies_to_clock_t(max(0L, delta)); | ^ include/linux/minmax.h:69:19: note: expanded from macro 'max' 69 | #define max(x, y) __careful_cmp(max, x, y) | ^ include/linux/minmax.h:36:3: note: expanded from macro '__careful_cmp' 36 | __cmp_once(op, x, y, __UNIQUE_ID(__x), __UNIQUE_ID(__y))) | ^ include/linux/minmax.h:29:3: note: expanded from macro '__cmp_once' 29 | static_assert(__types_ok(x, y), \ | ^ In file included from kernel/time/alarmtimer.c:16: In file included from include/linux/hrtimer.h:15: In file included from include/linux/hrtimer_defs.h:5: In file included from include/linux/ktime.h:25: include/linux/jiffies.h:432:26: error: call to undeclared function 'static_assert'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration] 432 | return jiffies_to_msecs(max(0L, delta)); | ^ include/linux/minmax.h:69:19: note: expanded from macro 'max' 69 | #define max(x, y) __careful_cmp(max, x, y) | ^ include/linux/minmax.h:36:3: note: expanded from macro '__careful_cmp' 36 | __cmp_once(op, x, y, __UNIQUE_ID(__x), __UNIQUE_ID(__y))) | ^ include/linux/minmax.h:29:3: note: expanded from macro '__cmp_once' 29 | static_assert(__types_ok(x, y), \ | ^ In file included from kernel/time/alarmtimer.c:18: In file included from include/linux/rtc.h:17: In file included from include/linux/interrupt.h:11: In file included from include/linux/hardirq.h:11: In file included from arch/um/include/asm/hardirq.h:5: In file included from include/asm-generic/hardirq.h:17: In file included from include/linux/irq.h:20: In file included from include/linux/io.h:13: In file included from arch/um/include/asm/io.h:24: include/asm-generic/io.h:547:31: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] 547 | val = __raw_readb(PCI_IOBASE + addr); | ~~~~~~~~~~ ^ include/asm-generic/io.h:560:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] 560 | val = __le16_to_cpu((__le16 __force)__raw_readw(PCI_IOBASE + addr)); | ~~~~~~~~~~ ^ include/uapi/linux/byteorder/little_endian.h:37:51: note: expanded from macro '__le16_to_cpu' 37 | #define __le16_to_cpu(x) ((__force __u16)(__le16)(x)) | ^ In file included from kernel/time/alarmtimer.c:18: In file included from include/linux/rtc.h:17: In file included from include/linux/interrupt.h:11: In file included from include/linux/hardirq.h:11: In file included from arch/um/include/asm/hardirq.h:5: In file included from include/asm-generic/hardirq.h:17: In file included from include/linux/irq.h:20: In file included from include/linux/io.h:13: In file included from arch/um/include/asm/io.h:24: include/asm-generic/io.h:573:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] 573 | val = __le32_to_cpu((__le32 __force)__raw_readl(PCI_IOBASE + addr)); | ~~~~~~~~~~ ^ include/uapi/linux/byteorder/little_endian.h:35:51: note: expanded from macro '__le32_to_cpu' 35 | #define __le32_to_cpu(x) ((__force __u32)(__le32)(x)) | ^ In file included from kernel/time/alarmtimer.c:18: In file included from include/linux/rtc.h:17: In file included from include/linux/interrupt.h:11: In file included from include/linux/hardirq.h:11: In file included from arch/um/include/asm/hardirq.h:5: In file included from include/asm-generic/hardirq.h:17: In file included from include/linux/irq.h:20: In file included from include/linux/io.h:13: In file included from arch/um/include/asm/io.h:24: include/asm-generic/io.h:584:33: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] 584 | __raw_writeb(value, PCI_IOBASE + addr); | ~~~~~~~~~~ ^ include/asm-generic/io.h:594:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] 594 | __raw_writew((u16 __force)cpu_to_le16(value), PCI_IOBASE + addr); | ~~~~~~~~~~ ^ include/asm-generic/io.h:604:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] 604 | __raw_writel((u32 __force)cpu_to_le32(value), PCI_IOBASE + addr); | ~~~~~~~~~~ ^ include/asm-generic/io.h:692:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] 692 | readsb(PCI_IOBASE + addr, buffer, count); | ~~~~~~~~~~ ^ include/asm-generic/io.h:700:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] 700 | readsw(PCI_IOBASE + addr, buffer, count); | ~~~~~~~~~~ ^ include/asm-generic/io.h:708:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] 708 | readsl(PCI_IOBASE + addr, buffer, count); | ~~~~~~~~~~ ^ include/asm-generic/io.h:717:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] 717 | writesb(PCI_IOBASE + addr, buffer, count); | ~~~~~~~~~~ ^ include/asm-generic/io.h:726:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] 726 | writesw(PCI_IOBASE + addr, buffer, count); | ~~~~~~~~~~ ^ include/asm-generic/io.h:735:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] 735 | writesl(PCI_IOBASE + addr, buffer, count); | ~~~~~~~~~~ ^ In file included from kernel/time/alarmtimer.c:18: In file included from include/linux/rtc.h:38: In file included from include/linux/seq_file.h:12: In file included from include/linux/fs.h:33: vim +/static_assert +427 include/linux/jiffies.h ae60d6a0e3a919 Nicholas Mc Guire 2015-05-28 420 9ca308506062fc Baolin Wang 2015-07-29 421 extern unsigned long timespec64_to_jiffies(const struct timespec64 *value); 9ca308506062fc Baolin Wang 2015-07-29 422 extern void jiffies_to_timespec64(const unsigned long jiffies, 9ca308506062fc Baolin Wang 2015-07-29 423 struct timespec64 *value); cbbc719fccdb8c hank 2011-09-20 424 extern clock_t jiffies_to_clock_t(unsigned long x); a399a8053164ec Eric Dumazet 2012-08-08 425 static inline clock_t jiffies_delta_to_clock_t(long delta) a399a8053164ec Eric Dumazet 2012-08-08 426 { a399a8053164ec Eric Dumazet 2012-08-08 @427 return jiffies_to_clock_t(max(0L, delta)); a399a8053164ec Eric Dumazet 2012-08-08 428 } a399a8053164ec Eric Dumazet 2012-08-08 429
From: kernel test robot > Sent: 25 July 2023 16:58 > > kernel test robot noticed the following build errors: > ... > > In file included from init/calibrate.c:8: > >> include/linux/jiffies.h:427:28: error: call to undeclared function 'static_assert'; ISO C99 and > later do not support implicit function declarations [-Wimplicit-function-declaration] > 427 | return jiffies_to_clock_t(max(0L, delta)); > | ^ ... > include/linux/minmax.h:29:3: note: expanded from macro '__cmp_once' > 29 | static_assert(__types_ok(x, y), \ This is fixed by the earlier patch: [PATCH v1 1/1] minmax: Fix header inclusions which adds #include <linux/build_bug.h> and thus defines static_assert(). Can I just assume that will be applied? David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)
From: kernel test robot > Sent: 25 July 2023 15:57 ... > >> mm/mm_init.c:908:14: error: static_assert expression is not an integral constant expression > start_pfn = clamp(start_pfn, zone_start_pfn, zone_end_pfn); .. > include/linux/minmax.h:45:17: note: expanded from macro '__clamp_once' > static_assert(!__is_constexpr((lo) > (hi)) || (lo) <= (hi), That didn't fail in my test builds. The compiler I was using must short-circuited the ||. I'll substitute a 'choose_expr' in v2. David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)
On Wed, Jul 26, 2023 at 08:30:59AM +0000, David Laight wrote: > From: kernel test robot > > Sent: 25 July 2023 16:58 > > > > kernel test robot noticed the following build errors: ... > > In file included from init/calibrate.c:8: > > >> include/linux/jiffies.h:427:28: error: call to undeclared function 'static_assert'; ISO C99 and > > later do not support implicit function declarations [-Wimplicit-function-declaration] > > 427 | return jiffies_to_clock_t(max(0L, delta)); > > | ^ > ... > > include/linux/minmax.h:29:3: note: expanded from macro '__cmp_once' > > 29 | static_assert(__types_ok(x, y), \ > > This is fixed by the earlier patch: > [PATCH v1 1/1] minmax: Fix header inclusions > > which adds #include <linux/build_bug.h> and thus defines static_assert(). > > Can I just assume that will be applied? You can test that and reply there with your Tested-by there, it will help it to be applied.
From: 'Andy Shevchenko' > Sent: 26 July 2023 17:20 > > On Wed, Jul 26, 2023 at 08:30:59AM +0000, David Laight wrote: > > From: kernel test robot > > > Sent: 25 July 2023 16:58 > > > > > > kernel test robot noticed the following build errors: > > ... > > > > In file included from init/calibrate.c:8: > > > >> include/linux/jiffies.h:427:28: error: call to undeclared function 'static_assert'; ISO C99 and > > > later do not support implicit function declarations [-Wimplicit-function-declaration] > > > 427 | return jiffies_to_clock_t(max(0L, delta)); > > > | ^ > > ... > > > include/linux/minmax.h:29:3: note: expanded from macro '__cmp_once' > > > 29 | static_assert(__types_ok(x, y), \ > > > > This is fixed by the earlier patch: > > [PATCH v1 1/1] minmax: Fix header inclusions > > > > which adds #include <linux/build_bug.h> and thus defines static_assert(). > > > > Can I just assume that will be applied? > > You can test that and reply there with your Tested-by there, it will help it > to be applied. I can check it doesn't break my x86-64 build. I think the build error was on a 'um' build - not really obvious in the report. I suspect everything else gets build_bug.h included from a very common header file. On x86-64 (5.10.xxx) by forcing an error I get: CC init/calibrate.o In file included from linux/include/linux/bits.h:22, from linux/include/linux/bitops.h:5, from linux/include/linux/kernel.h:12, from linux/arch/x86/include/asm/percpu.h:27, from linux/arch/x86/include/asm/current.h:6, from linux/arch/x86/include/asm/processor.h:17, from linux/arch/x86/include/asm/timex.h:5, from linux/include/linux/timex.h:67, from linux/include/linux/time32.h:13, from linux/include/linux/time.h:73, from linux/include/linux/jiffies.h:10, from linux/init/calibrate.c:9: linux/include/linux/build_bug.h: ... I can't help feeling some of that chain isn't needed :-) David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)
diff --git a/include/linux/minmax.h b/include/linux/minmax.h index 531860e9cc55..10d236ac7da6 100644 --- a/include/linux/minmax.h +++ b/include/linux/minmax.h @@ -9,33 +9,31 @@ * * - avoid multiple evaluations of the arguments (so side-effects like * "x++" happen only once) when non-constant. - * - perform strict type-checking (to generate warnings instead of - * nasty runtime surprises). See the "unnecessary" pointer comparison - * in __typecheck(). + * - perform signed v unsigned type-checking (to generate compile + * errors instead of nasty runtime surprises). * - retain result as a constant expressions when called with only * constant expressions (to avoid tripping VLA warnings in stack * allocation usage). */ -#define __typecheck(x, y) \ - (!!(sizeof((typeof(x) *)1 == (typeof(y) *)1))) +#define __types_ok(x, y) \ + (is_signed_type(typeof(x)) == is_signed_type(typeof(y))) -#define __no_side_effects(x, y) \ - (__is_constexpr(x) && __is_constexpr(y)) +#define __cmp_op_min < +#define __cmp_op_max > -#define __safe_cmp(x, y) \ - (__typecheck(x, y) && __no_side_effects(x, y)) +#define __cmp(op, x, y) ((x) __cmp_op_##op (y) ? (x) : (y)) -#define __cmp(x, y, op) ((x) op (y) ? (x) : (y)) - -#define __cmp_once(x, y, unique_x, unique_y, op) ({ \ +#define __cmp_once(op, x, y, unique_x, unique_y) ({ \ typeof(x) unique_x = (x); \ typeof(y) unique_y = (y); \ - __cmp(unique_x, unique_y, op); }) + static_assert(__types_ok(x, y), \ + #op "(" #x ", " #y ") signedness error, fix types or consider " #op "_unsigned() before " #op "_t()"); \ + __cmp(op, unique_x, unique_y); }) -#define __careful_cmp(x, y, op) \ - __builtin_choose_expr(__safe_cmp(x, y), \ - __cmp(x, y, op), \ - __cmp_once(x, y, __UNIQUE_ID(__x), __UNIQUE_ID(__y), op)) +#define __careful_cmp(op, x, y) \ + __builtin_choose_expr(__is_constexpr((x) - (y)), \ + __cmp(op, x, y), \ + __cmp_once(op, x, y, __UNIQUE_ID(__x), __UNIQUE_ID(__y))) #define __clamp(val, lo, hi) \ ((val) >= (hi) ? (hi) : ((val) <= (lo) ? (lo) : (val))) @@ -44,17 +42,14 @@ typeof(val) unique_val = (val); \ typeof(lo) unique_lo = (lo); \ typeof(hi) unique_hi = (hi); \ + static_assert(!__is_constexpr((lo) > (hi)) || (lo) <= (hi), \ + "clamp() low limit " #lo " greater than high limit " #hi); \ + static_assert(__types_ok(val, lo), "clamp() 'lo' signedness error"); \ + static_assert(__types_ok(val, hi), "clamp() 'hi' signedness error"); \ __clamp(unique_val, unique_lo, unique_hi); }) -#define __clamp_input_check(lo, hi) \ - (BUILD_BUG_ON_ZERO(__builtin_choose_expr( \ - __is_constexpr((lo) > (hi)), (lo) > (hi), false))) - #define __careful_clamp(val, lo, hi) ({ \ - __clamp_input_check(lo, hi) + \ - __builtin_choose_expr(__typecheck(val, lo) && __typecheck(val, hi) && \ - __typecheck(hi, lo) && __is_constexpr(val) && \ - __is_constexpr(lo) && __is_constexpr(hi), \ + __builtin_choose_expr(__is_constexpr((val) - (lo) + (hi)), \ __clamp(val, lo, hi), \ __clamp_once(val, lo, hi, __UNIQUE_ID(__val), \ __UNIQUE_ID(__lo), __UNIQUE_ID(__hi))); }) @@ -64,14 +59,14 @@ * @x: first value * @y: second value */ -#define min(x, y) __careful_cmp(x, y, <) +#define min(x, y) __careful_cmp(min, x, y) /** * max - return maximum of two values of the same or compatible types * @x: first value * @y: second value */ -#define max(x, y) __careful_cmp(x, y, >) +#define max(x, y) __careful_cmp(max, x, y) /** * min_unsigned - return minimum of two non-negative values @@ -79,16 +74,16 @@ * @x: first value * @y: second value */ -#define min_unsigned(x, y) \ - __careful_cmp((x) + 0u + 0ul + 0ull, (y) + 0u + 0ul + 0ull, <) +#define min_unsigned(x, y) \ + __careful_cmp(min, (x) + 0u + 0ul + 0ull, (y) + 0u + 0ul + 0ull) /** * max_unsigned - return maximum of two non-negative values * @x: first value * @y: second value */ -#define max_unsigned(x, y) \ - __careful_cmp((x) + 0u + 0ul + 0ull, (y) + 0u + 0ul + 0ull, >) +#define max_unsigned(x, y) \ + __careful_cmp(max, (x) + 0u + 0ul + 0ull, (y) + 0u + 0ul + 0ull) /** * min3 - return minimum of three values @@ -140,7 +135,7 @@ * @x: first value * @y: second value */ -#define min_t(type, x, y) __careful_cmp((type)(x), (type)(y), <) +#define min_t(type, x, y) __careful_cmp(min, (type)(x), (type)(y)) /** * max_t - return maximum of two values, using the specified type @@ -148,7 +143,7 @@ * @x: first value * @y: second value */ -#define max_t(type, x, y) __careful_cmp((type)(x), (type)(y), >) +#define max_t(type, x, y) __careful_cmp(max, (type)(x), (type)(y)) /** * clamp_t - return a value clamped to a given range using a given type