From patchwork Sun Jul 28 14:18:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Laight X-Patchwork-Id: 13744003 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 E1B19C3DA49 for ; Sun, 28 Jul 2024 14:19:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 858436B007B; Sun, 28 Jul 2024 10:19:42 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 809126B0083; Sun, 28 Jul 2024 10:19:42 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6D03E6B0085; Sun, 28 Jul 2024 10:19:42 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 52F6D6B007B for ; Sun, 28 Jul 2024 10:19:42 -0400 (EDT) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id C323516051E for ; Sun, 28 Jul 2024 14:19:41 +0000 (UTC) X-FDA: 82389369762.12.81F0CB3 Received: from eu-smtp-delivery-151.mimecast.com (eu-smtp-delivery-151.mimecast.com [185.58.85.151]) by imf11.hostedemail.com (Postfix) with ESMTP id 8D15B40007 for ; Sun, 28 Jul 2024 14:19:39 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=none; spf=pass (imf11.hostedemail.com: domain of david.laight@aculab.com designates 185.58.85.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=1722176327; 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=MuvoUgdtghS6rQkUL1LMIng5Fy8TT6pQDoAeXgc4g8Y=; b=8S+m3j/yyJ0T5IEvucs5yIe6xbL2+8S6DPVL7+vasP6XVt2LRCHJ7lQ1XQQWdFioBbYRBT HlCDilvIK8ZzOELc+nwSunZaJIzfbZIYfVPkjTvDG5wRnywXGURciOoxBlRvu6mXoKJcsW okb/yj0ul5Nyqc+dW7SfMxpYkeHsabQ= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1722176327; a=rsa-sha256; cv=none; b=0tLRjLkeYQC1SAQ6BP6frbG5fa6p1IvFDSuvH3Qn7/WnZyTwgCSWVyPG/ZtjcHbhq2sS6U uDEootD+ke1QPueHBzAlMa0nVNZR883b8bQkGltND96cVVUWgd/W0oDVRtFmWebcet0lmG 1LefN0RtS2e2RaJDCBv2bsTwa/mjpDA= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=none; spf=pass (imf11.hostedemail.com: domain of david.laight@aculab.com designates 185.58.85.151 as permitted sender) smtp.mailfrom=david.laight@aculab.com; dmarc=pass (policy=none) header.from=aculab.com 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-44-u0K9Dgy5NXe-98MhLF4xEg-1; Sun, 28 Jul 2024 15:19:32 +0100 X-MC-Unique: u0K9Dgy5NXe-98MhLF4xEg-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; Sun, 28 Jul 2024 15:18:47 +0100 Received: from AcuMS.Aculab.com ([::1]) by AcuMS.aculab.com ([::1]) with mapi id 15.00.1497.048; Sun, 28 Jul 2024 15:18:47 +0100 From: David Laight To: "'linux-kernel@vger.kernel.org'" CC: 'Linus Torvalds' , 'Jens Axboe' , "'Matthew Wilcox (Oracle)'" , 'Christoph Hellwig' , 'Andrew Morton' , 'Andy Shevchenko' , 'Dan Carpenter' , 'Arnd Bergmann' , "'Jason@zx2c4.com'" , "'pedro.falcato@gmail.com'" , 'Mateusz Guzik' , "'linux-mm@kvack.org'" , 'Lorenzo Stoakes' Subject: [PATCH v2 2/8] minmax: Use _Static_assert() instead of static_assert() Thread-Topic: [PATCH v2 2/8] minmax: Use _Static_assert() instead of static_assert() Thread-Index: Adrg+SQVeb05XypLRkeZ+5Y+23noEA== Date: Sun, 28 Jul 2024 14:18:47 +0000 Message-ID: References: <402c3c617c29465c898b1af55e3c6095@AcuMS.aculab.com> In-Reply-To: <402c3c617c29465c898b1af55e3c6095@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-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 8D15B40007 X-Stat-Signature: k9xgcn97kayc3yg5x6firpkxsnym6hkt X-HE-Tag: 1722176379-713799 X-HE-Meta: U2FsdGVkX18GH9p6+TJTOhHaBeTi1QX1c4zmwykGbaI6kb1qralCNtfsnqzID5ICUg5UfPNi+Z/MpIix7GyRAzLJ+06eOFaBHswp/1ywp96AuZsNV2dpDJlisKWWVzuaLRYdn5iHP1UE7lbzxA8fX2o0OIypb8WTcirvyejIiQA65icWIpabzYhc0uoIOfZ4qdDlZuFrnEmndQRPkhzaSY8bMp9DFWc22T/r5xvFciaDqGSc5kmHjQ0RrCg0MAhYAI6mWFKIOylyA3yumbDidZU+f4IIhDqIsqYkb1UthC7JryyIYScF0pb+Q/LuaXcNA5Go2afKiA3hNtGk0v+B7W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UWofyXg3o9vB7cps3Ujf9IBeYoOmr 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 --- v2: - No change. 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 cea63a8ac80f..ab64b2e73ae5 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) ({ \