From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) (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 CE28333FE; Sun, 2 Jun 2024 03:49:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=90.155.50.34 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717300177; cv=none; b=jePFDSloUdBfj/S48GNJ7hIiAV2JnAtiTAlzy3vVEzbY+mOtoH7spkJD6O/Xm7Q2PUN3KlDoEtDsYqW/DrmbxaXG3BoEE9cIB3tA2VEZI9khaThNy9qSqIXmSG9AJTCvKg7iWWlmiSu1OB4+TQbdYGVlVtzSQu40ybox2F0Ouog= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717300177; c=relaxed/simple; bh=nI+JdCdtSJsrLAJ8ilaI4AYR3YEqWcnZFiRDQVHYHO8=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=ChoxLPI/jGzmrT3pI1ZuLqiQWeupN6UtrJQtViWtt0FLLGrYhy+PSMlTpj4RmCHt04DradaoPJM8k8nBR+rz7qvf/RVxJNgW9EM+GcRSoz4oGibioVU/v6xTqH7qJpZ3hj0TyY06O25Vqf+UpvzjvzMCk5urhvyMf1UvhbsP9WA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org; spf=none smtp.mailfrom=infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=KbMIzHs5; arc=none smtp.client-ip=90.155.50.34 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=infradead.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="KbMIzHs5" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=o7NoMXzPthc9zQlJ66cfUGuyRStXBoiGWt66Jwklgk8=; b=KbMIzHs5gt1BcRON61TXatunNp q3vENuIK+gxN6Givz28UrOa3Uc8zlgPpsxgsGti80Yxy7URNy2r5h2EWzydq0h1qljXa/4f12VrQg ZbId0F5kiYsw/TJxH9jXcTjD6cPiXrVR1uJ+zy1Y9CX8/DG9uYpz6Q7cIezrHEx1+S9vHlqeIaLBX YnTOEv4PPHUFeMm2kqbzdqP0unuraFAlyI4W8aCeI1HYe//ziQqUpuRPYnSb0pak9t5NNgMJI4ocI zJzfF+gMyiUKkXPxzpOKUmq6YQ8G/LjvX2iKHO/eNK+9QABDKwE4OjkLk2ZuOPdCnkoFBEVihi5zw JfIiXu8g==; Received: from willy by casper.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1sDcDh-0000000D1A1-0j0Z; Sun, 02 Jun 2024 03:49:21 +0000 Date: Sun, 2 Jun 2024 04:49:21 +0100 From: Matthew Wilcox To: Keith Busch Cc: Andreas Hindborg , Jens Axboe , Christoph Hellwig , Damien Le Moal , Bart Van Assche , Hannes Reinecke , Ming Lei , "linux-block@vger.kernel.org" , Andreas Hindborg , Greg KH , Miguel Ojeda , Alex Gaynor , Wedson Almeida Filho , Boqun Feng , Gary Guo , =?iso-8859-1?Q?Bj=F6rn?= Roy Baron , Benno Lossin , Alice Ryhl , Chaitanya Kulkarni , Luis Chamberlain , Yexuan Yang <1182282462@bupt.edu.cn>, Sergio =?iso-8859-1?Q?Gonz=E1lez?= Collado , Joel Granados , "Pankaj Raghav (Samsung)" , Daniel Gomez , Niklas Cassel , Philipp Stanner , Conor Dooley , Johannes Thumshirn , Matias =?iso-8859-1?Q?Bj=F8rling?= , open list , "rust-for-linux@vger.kernel.org" , "lsf-pc@lists.linux-foundation.org" , "gost.dev@samsung.com" Subject: Re: [PATCH v4 2/3] rust: block: add rnull, Rust null_blk implementation Message-ID: References: <20240601134005.621714-1-nmi@metaspace.dk> <20240601134005.621714-3-nmi@metaspace.dk> <875xusoetn.fsf@metaspace.dk> Precedence: bulk X-Mailing-List: rust-for-linux@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: On Sat, Jun 01, 2024 at 10:01:40AM -0600, Keith Busch wrote: > It's fine, just wondering why it's there. But it also allows values like > 1536 and 3584, which are not valid block sizes, so I think you want the > check to be: > > if !(512..=4096).contains(&block_size) || ((block_size & (block_size - 1)) != 0) I'd drop the range check. We're pretty close to landing the bs>PS patches, so just if block_size & block_size - 1 != 0 should be enough of a validation. Is it considered "good style" in Rust to omit the brackets here?