From patchwork Wed Jul 24 14:29:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Laight X-Patchwork-Id: 13741013 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8952CC3DA61 for ; Wed, 24 Jul 2024 14:29:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 059BA6B0088; Wed, 24 Jul 2024 10:29:48 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0094A6B0089; Wed, 24 Jul 2024 10:29:47 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DEC9F6B008A; Wed, 24 Jul 2024 10:29:47 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id BFDBC6B0088 for ; Wed, 24 Jul 2024 10:29:47 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 7005A1609FB for ; Wed, 24 Jul 2024 14:29:47 +0000 (UTC) X-FDA: 82374880014.01.3F430BC Received: from eu-smtp-delivery-151.mimecast.com (eu-smtp-delivery-151.mimecast.com [185.58.86.151]) by imf13.hostedemail.com (Postfix) with ESMTP id 314B620011 for ; Wed, 24 Jul 2024 14:29:44 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=none; spf=pass (imf13.hostedemail.com: domain of david.laight@aculab.com designates 185.58.86.151 as permitted sender) smtp.mailfrom=david.laight@aculab.com; dmarc=pass (policy=none) header.from=aculab.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1721831361; a=rsa-sha256; cv=none; b=irQS1AjP+fMxlCXpWt1mLNSV6sRgHrBH/JrmQ27g/m/Ew5sOPsAl0MCoZUvGFnmw5eOml7 jsfS2Wuf+vOaUT4SXWkJ64jAJxvDzdQ/JbJaUzf8pzV9AiyhMTfg+rZboIfFEblrY24MGP h/qYeUpZui9pXs/CBZhUGzBop+xMH9c= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=none; spf=pass (imf13.hostedemail.com: domain of david.laight@aculab.com designates 185.58.86.151 as permitted sender) smtp.mailfrom=david.laight@aculab.com; dmarc=pass (policy=none) header.from=aculab.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1721831361; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=EhqLrJgqYxdlTb2Zl2yShcG1KzJBygJskqHd8w4qHqo=; b=WuLBAe1z4hOw+As8cgkqSivEkPQQ+jemh0oGaQD1597dF5oSA1tGfj6+7aQLpldRBjOP1P tbJ3qL4ALy905myWTSxsotWBwQXWUvcfPLTwlBKTO7Q6nGcfmBKDWXdHlkdfsVcX1vnb/A SXncVM29n8p+eYbCGt6XL6vj+8CEq6k= 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-267-KJPviE2xP9qjIHrECg06Og-1; Wed, 24 Jul 2024 15:29:42 +0100 X-MC-Unique: KJPviE2xP9qjIHrECg06Og-1 Received: from AcuMS.Aculab.com (10.202.163.4) by AcuMS.aculab.com (10.202.163.4) with Microsoft SMTP Server (TLS) id 15.0.1497.48; Wed, 24 Jul 2024 15:29:02 +0100 Received: from AcuMS.Aculab.com ([::1]) by AcuMS.aculab.com ([::1]) with mapi id 15.00.1497.048; Wed, 24 Jul 2024 15:29:02 +0100 From: David Laight To: "'linux-kernel@vger.kernel.org'" , "'Linus Torvalds'" CC: "'Matthew Wilcox (Oracle)'" , 'Christoph Hellwig' , 'Andrew Morton' , "'Andy Shevchenko'" , 'Dan Carpenter' , 'Arnd Bergmann' , "'Jason@zx2c4.com'" , "'hch@infradead.org'" , "'pedro.falcato@gmail.com'" , 'Mateusz Guzik' , "'linux-mm@kvack.org'" Subject: [PATCH 2/7] minmax: Use _Static_assert() instead of static_assert() Thread-Topic: [PATCH 2/7] minmax: Use _Static_assert() instead of static_assert() Thread-Index: Adrd1elaiPvTR2LWQ4qjY5Mia/iOEQ== Date: Wed, 24 Jul 2024 14:29:02 +0000 Message-ID: <171c2c31e16841bca0c4fbb085877d7e@AcuMS.aculab.com> References: <23bdb6fc8d884ceebeb6e8b8653b8cfe@AcuMS.aculab.com> In-Reply-To: <23bdb6fc8d884ceebeb6e8b8653b8cfe@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 X-Stat-Signature: z4hsxe48wbqtq35ibt8r5i8abgkecrqj X-Rspamd-Queue-Id: 314B620011 X-Rspam-User: X-Rspamd-Server: rspam10 X-HE-Tag: 1721831384-286681 X-HE-Meta: U2FsdGVkX18nKYP6h0NkCUfd004D+r+YsYDB/HQC6D5wJsilDJ7wx3JxVqvQQNddU8l5PggWS4fSEjnfrJ5TajideFG1AZj5cd5D0gAAEr8RTPh+rfBkxLfq9IZxfEThs7j9Tc8sk6X5F2b4AH2h3WJJ6yPL1fc13ASr9X/SV3+nL7ciudT8HTlQcFGDLkM1Ia2S1/0FggWi3/71Hbc3LcVu+BbAF+PrjJreTe8T9imsUV0wVseZJFMJ20Rb8mR/2Egg7P6Ygn8WV3XIsF/biqlHgzi6jgVF1z+6IpVJhn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fsNQ/EGGQ7csrksGmNZfDoktPoCkqBICCWN2Qjdp3ZkmNr0No5jXh+/0XdkJd+bJhYZ7rQqXpxnz8FJ5Y X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: The static_assert() wrapper provides the text of the expression as the error message, this isn't needed here as an explicit message is provided. If there is an error (quite likely for min/max) the wrapper also adds two more lines of error output that just make it harder to read. Since it gives no benefit and actually makes things worse directly using _Static_assert() is much better. Signed-off-by: David Laight --- include/linux/minmax.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/include/linux/minmax.h b/include/linux/minmax.h index 63c45865b48a..900eec7a28e5 100644 --- a/include/linux/minmax.h +++ b/include/linux/minmax.h @@ -48,7 +48,7 @@ #define __cmp_once(op, x, y, unique_x, unique_y) ({ \ typeof(x) unique_x = (x); \ typeof(y) unique_y = (y); \ - static_assert(__types_ok(x, y), \ + _Static_assert(__types_ok(x, y), \ #op "(" #x ", " #y ") signedness error, fix types or consider u" #op "() before " #op "_t()"); \ __cmp(op, unique_x, unique_y); }) @@ -137,11 +137,11 @@ typeof(val) unique_val = (val); \ typeof(lo) unique_lo = (lo); \ typeof(hi) unique_hi = (hi); \ - static_assert(__builtin_choose_expr(__is_constexpr((lo) > (hi)), \ + _Static_assert(__builtin_choose_expr(__is_constexpr((lo) > (hi)), \ (lo) <= (hi), true), \ "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"); \ + _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 __careful_clamp(val, lo, hi) ({ \