Message ID | b564df3f987e4371a445840df1f70561@AcuMS.aculab.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-41910-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2087:b0:106:209c:c626 with SMTP id gs7csp196289dyb; Sun, 28 Jan 2024 11:36:55 -0800 (PST) X-Google-Smtp-Source: AGHT+IHymhvfeCNvzY8Utcp7yJk9FBLdTVoOp+c2VuaphELBYIABAV6TE+YUpRxftulAytTSf/I5 X-Received: by 2002:a05:6402:35c4:b0:55d:20f2:11c9 with SMTP id z4-20020a05640235c400b0055d20f211c9mr2757860edc.25.1706470614852; Sun, 28 Jan 2024 11:36:54 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706470614; cv=pass; d=google.com; s=arc-20160816; b=TwR4KXJ6wX5NBzWYLrGKRb719y1spDa3n1R6TMD0Z+cPtl6CEPJR+itxOYAuoReKZo fKRrlSd+y1sPVwkNdWWggqQJwGFVK0ehSbLYEeFjRKYenjoLDONC2g24hMGitel645u9 J19yOJFnQMLYkIPwqeo2ufcbiUXQwslEkRBAuWtyju8vMgplYf72M0jv3gk07vbQuR0Q CtXYI62MSpN65DCaBlJuwMWLr/axE9w+G7qlo+I9o2XaoYqAw+1B8JuureBOSBA7Br+o fRM5OavZ72qSUzPYnfKeXKFO4z1YE4EPm+NhiA83Bu4ucGb/qw3LBHB7AxdjLTc/xNYq hECA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:content-language:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:accept-language :in-reply-to:references:message-id:date:thread-index:thread-topic :subject:cc:to:from; bh=QB5cBlZmX3HjIcw4VUIAA5Ehr6Qpy5RSN9Fbvir6iZk=; fh=jAOu/RGlQxfhPk7PcGNzOfYLHKZO+STAaG1daOB/TAU=; b=T8JkgILTicJaZ2IvPie9ANF7Kv8pRVcJyosiQlZ9GFxeq5a+QtG40fo0n1gUEO0Lat BvrZSh+HNd28FBeH68CgT4tsB1MxNDWorn8LYoR5UbdLunfz7xHzlw6vhXqvkozTXd3l Y/xtJTMqg8yYu93QW8VTqFUwro752iRF4wJ2KFi/A4a4EJnprEe9uxAaT/mjX6VzDy1Z KJ55Jm145JeD6/610O8lFwNVSXY99bqpiEfp6QRNohrqMnoxITZvVlAeCrk5m495Pzhh 9i5UYVNSmamNEkh/1Hq8wEd0nVlaou43GAtOEn/YSpbNDNNKbF5cqSb3NVvrjyKkzXNR 2CJQ== ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=aculab.com dmarc=pass fromdomain=aculab.com); spf=pass (google.com: domain of linux-kernel+bounces-41910-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-41910-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=aculab.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id en26-20020a056402529a00b0055d367d07desi2749078edb.4.2024.01.28.11.36.54 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 28 Jan 2024 11:36:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-41910-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=aculab.com dmarc=pass fromdomain=aculab.com); spf=pass (google.com: domain of linux-kernel+bounces-41910-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-41910-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=aculab.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 62F681F218A6 for <ouuuleilei@gmail.com>; Sun, 28 Jan 2024 19:36:54 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 34E8D3C470; Sun, 28 Jan 2024 19:36:29 +0000 (UTC) Received: from eu-smtp-delivery-151.mimecast.com (eu-smtp-delivery-151.mimecast.com [185.58.86.151]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C9B3C2E62B for <linux-kernel@vger.kernel.org>; Sun, 28 Jan 2024 19:36:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.58.86.151 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706470587; cv=none; b=H/+/ABpv4KsfQ7aGD3VNgOVWgb9nsoJWTanL+dG4TO98HPRjThk72pfp5sb0r9G29MXpx/CyISeq4u3mrijiN7iDrTeHXxzoTrR0ntvz4vsCInc7W/uR3404jivLwcLaczkuKpAeeHHGPWHAN7KvDgkIOMS/5O9SvHRlBC9xMLg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706470587; c=relaxed/simple; bh=QB5cBlZmX3HjIcw4VUIAA5Ehr6Qpy5RSN9Fbvir6iZk=; h=From:To:CC:Subject:Date:Message-ID:References:In-Reply-To: MIME-Version:Content-Type; b=BNbrlZYg0DpEfW2Lq8F1BaxXfUuaCxq0dI7glPDM5kTKXRELWsrTjaMs0hZIOVbqy5mFkGuZ4lUaVgVEfanUuWV2gSYcivMaDXWXR3Mrcr4T9L2WaUGa2EiNcm9k1QX8H6S/aTERAsn540w4+yNo1OyFnjrapsPAX+EMkAGEBQo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ACULAB.COM; spf=pass smtp.mailfrom=aculab.com; arc=none smtp.client-ip=185.58.86.151 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ACULAB.COM Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=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-253-wsGkhBltNxSy1X4pYfIzig-1; Sun, 28 Jan 2024 19:36:22 +0000 X-MC-Unique: wsGkhBltNxSy1X4pYfIzig-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 Jan 2024 19:35:38 +0000 Received: from AcuMS.Aculab.com ([::1]) by AcuMS.aculab.com ([::1]) with mapi id 15.00.1497.048; Sun, 28 Jan 2024 19:35:38 +0000 From: David Laight <David.Laight@ACULAB.COM> To: "'linux-kernel@vger.kernel.org'" <linux-kernel@vger.kernel.org>, "'Linus Torvalds'" <torvalds@linux-foundation.org>, 'Netdev' <netdev@vger.kernel.org>, "'dri-devel@lists.freedesktop.org'" <dri-devel@lists.freedesktop.org> CC: 'Andy Shevchenko' <andriy.shevchenko@linux.intel.com>, 'Andrew Morton' <akpm@linux-foundation.org>, "'Matthew Wilcox (Oracle)'" <willy@infradead.org>, 'Christoph Hellwig' <hch@infradead.org>, "'Dan Carpenter'" <dan.carpenter@linaro.org>, 'Linus Walleij' <linus.walleij@linaro.org>, "'David S . Miller'" <davem@davemloft.net>, "'linux-btrfs@vger.kernel.org'" <linux-btrfs@vger.kernel.org>, 'Jens Axboe' <axboe@kernel.dk> Subject: [PATCH next 10/11] block: Use a boolean expression instead of max() on booleans Thread-Topic: [PATCH next 10/11] block: Use a boolean expression instead of max() on booleans Thread-Index: AdpSITDgD70hEVnBTjm/gYoTnRBnpg== Date: Sun, 28 Jan 2024 19:35:38 +0000 Message-ID: <b564df3f987e4371a445840df1f70561@AcuMS.aculab.com> References: <0ca26166dd2a4ff5a674b84704ff1517@AcuMS.aculab.com> In-Reply-To: <0ca26166dd2a4ff5a674b84704ff1517@AcuMS.aculab.com> Accept-Language: en-GB, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-transport-fromentityheader: Hosted Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> 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: base64 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789364131614133074 X-GMAIL-MSGID: 1789364131614133074 |
Series |
minmax: Optimise to reduce .i line length.
|
|
Commit Message
David Laight
Jan. 28, 2024, 7:35 p.m. UTC
blk_stack_limits() contains:
t->zoned = max(t->zoned, b->zoned);
These are bool, so it is just a bitwise or.
However it generates:
error: comparison of constant ‘0’ with boolean expression is always true [-Werror=bool-compare]
inside the signedness check that max() does unless a '+ 0' is added.
It is a shame the compiler generates this warning for code that will
be optimised away.
Change so that the extra '+ 0' can be removed.
Signed-off-by: David Laight <david.laight@aculab.com>
---
block/blk-settings.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
--
2.17.1
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
Comments
On Sun, 28 Jan 2024 at 11:36, David Laight <David.Laight@aculab.com> wrote: > > However it generates: > error: comparison of constant ‘0’ with boolean expression is always true [-Werror=bool-compare] > inside the signedness check that max() does unless a '+ 0' is added. Please fix your locale. You have random garbage characters there, presumably because you have some incorrect locale setting somewhere in your toolchain. Linus
From: Linus Torvalds > Sent: 28 January 2024 19:59 > > On Sun, 28 Jan 2024 at 11:36, David Laight <David.Laight@aculab.com> wrote: > > > > However it generates: > > error: comparison of constant ‘0’ with boolean expression is always true [-Werror=bool-compare] > > inside the signedness check that max() does unless a '+ 0' is added. > > Please fix your locale. You have random garbage characters there, > presumably because you have some incorrect locale setting somewhere in > your toolchain. Hmmmm blame gcc :-) The error message displays as '0' but is e2:80:98 30 e2:80:99 I HATE UTF-8, it wouldn't be as bad if it were a bijection. Lets see if adding 'LANG=C' in the shell script I use to do kernel builds is enough. I also managed to send parts 1 to 6 without deleting the RE: (I have to cut&paste from wordpad into a 'reply-all' of the first message I send. Work uses mimecast and it has started bouncing my copy of every message I send to the lists.) Maybe I should start using telnet to send raw SMTP :-) David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)
On Sun, 28 Jan 2024 at 14:22, David Laight <David.Laight@aculab.com> wrote: > > Hmmmm blame gcc :-) I do agree that the gcc warning quoting is unnecessarily ugly (even just visually), but.. > The error message displays as '0' but is e2:80:98 30 e2:80:99 > I HATE UTF-8, it wouldn't be as bad if it were a bijection. No, that's not the problem. The UTF-8 that gcc emits is fine. And your email was also UTF-8: Content-Type: text/plain; charset=UTF-8 The problem is that you clearly then used some other tool in between that took the UTF-8 byte stream, and used it as (presumably) Latin1, which is bogus. If you just make everything use and stay as UTF-8, it all works out beautifully. But I suspect you have an editor or a MUA that is fixed in some 1980s mindset, and when you cut-and-pasted the UTF-8, it treated it as Latin1. Just make all your environment be utf-8, like it should be. It's not the 80s any more. We don't do mullets, and we don't do Latin1, ok? Linus
On Sun, 28 Jan 2024, David Laight <David.Laight@ACULAB.COM> wrote: > blk_stack_limits() contains: > t->zoned = max(t->zoned, b->zoned); > These are bool, so it is just a bitwise or. Should be a logical or, really. And || in code. BR, Jani. > However it generates: > error: comparison of constant ‘0’ with boolean expression is always true [-Werror=bool-compare] > inside the signedness check that max() does unless a '+ 0' is added. > It is a shame the compiler generates this warning for code that will > be optimised away. > > Change so that the extra '+ 0' can be removed. > > Signed-off-by: David Laight <david.laight@aculab.com> > --- > block/blk-settings.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/block/blk-settings.c b/block/blk-settings.c > index 06ea91e51b8b..9ca21fea039d 100644 > --- a/block/blk-settings.c > +++ b/block/blk-settings.c > @@ -688,7 +688,7 @@ int blk_stack_limits(struct queue_limits *t, struct queue_limits *b, > b->max_secure_erase_sectors); > t->zone_write_granularity = max(t->zone_write_granularity, > b->zone_write_granularity); > - t->zoned = max(t->zoned, b->zoned); > + t->zoned = t->zoned | b->zoned; > return ret; > } > EXPORT_SYMBOL(blk_stack_limits);
From: Jani Nikula > Sent: 29 January 2024 09:08 > > On Sun, 28 Jan 2024, David Laight <David.Laight@ACULAB.COM> wrote: > > blk_stack_limits() contains: > > t->zoned = max(t->zoned, b->zoned); > > These are bool, so it is just a bitwise or. > > Should be a logical or, really. And || in code. Not really, bitwise is fine for bool (especially for 'or') and generates better code. David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)
On Mon, 29 Jan 2024, David Laight <David.Laight@ACULAB.COM> wrote: > From: Jani Nikula >> Sent: 29 January 2024 09:08 >> >> On Sun, 28 Jan 2024, David Laight <David.Laight@ACULAB.COM> wrote: >> > blk_stack_limits() contains: >> > t->zoned = max(t->zoned, b->zoned); >> > These are bool, so it is just a bitwise or. >> >> Should be a logical or, really. And || in code. > > Not really, bitwise is fine for bool (especially for 'or') > and generates better code. Logical operations for booleans are more readable for humans than bitwise. And semantically correct. With a = b || c you know what happens regardless of the types in question. a = b | c you have to look up the types to know what's going on. To me, better code only matters if it's a hotpath. That said, not my are of maintenance, so *shrug*. BR, Jani.
On Mon, Jan 29, 2024 at 09:22:40AM +0000, David Laight wrote: > From: Jani Nikula > > Sent: 29 January 2024 09:08 > > > > On Sun, 28 Jan 2024, David Laight <David.Laight@ACULAB.COM> wrote: > > > blk_stack_limits() contains: > > > t->zoned = max(t->zoned, b->zoned); > > > These are bool, so it is just a bitwise or. > > > > Should be a logical or, really. And || in code. > > Not really, bitwise is fine for bool (especially for 'or') > and generates better code. For | vs || the type doesn't make a difference... It makes a difference for AND. "0x1 & 0x10" vs "0x1 && 0x10". regards, dan carpenter
diff --git a/block/blk-settings.c b/block/blk-settings.c index 06ea91e51b8b..9ca21fea039d 100644 --- a/block/blk-settings.c +++ b/block/blk-settings.c @@ -688,7 +688,7 @@ int blk_stack_limits(struct queue_limits *t, struct queue_limits *b, b->max_secure_erase_sectors); t->zone_write_granularity = max(t->zone_write_granularity, b->zone_write_granularity); - t->zoned = max(t->zoned, b->zoned); + t->zoned = t->zoned | b->zoned; return ret; } EXPORT_SYMBOL(blk_stack_limits);