From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7A23CC433E0 for ; Wed, 10 Feb 2021 13:04:13 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id C1F7064E7C for ; Wed, 10 Feb 2021 13:04:12 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C1F7064E7C Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=perches.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 3FA346B006E; Wed, 10 Feb 2021 08:04:12 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 3D0FB6B0070; Wed, 10 Feb 2021 08:04:12 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2E6196B0071; Wed, 10 Feb 2021 08:04:12 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0061.hostedemail.com [216.40.44.61]) by kanga.kvack.org (Postfix) with ESMTP id 170C46B006E for ; Wed, 10 Feb 2021 08:04:12 -0500 (EST) Received: from smtpin29.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id D66791800EB1E for ; Wed, 10 Feb 2021 13:04:11 +0000 (UTC) X-FDA: 77802376302.29.cart72_150cd5427610 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin29.hostedemail.com (Postfix) with ESMTP id B71C3184FE9DF for ; Wed, 10 Feb 2021 13:04:11 +0000 (UTC) X-HE-Tag: cart72_150cd5427610 X-Filterd-Recvd-Size: 3848 Received: from smtprelay.hostedemail.com (smtprelay0214.hostedemail.com [216.40.44.214]) by imf13.hostedemail.com (Postfix) with ESMTP for ; Wed, 10 Feb 2021 13:04:11 +0000 (UTC) Received: from filter.hostedemail.com (clb03-v110.bra.tucows.net [216.40.38.60]) by smtprelay07.hostedemail.com (Postfix) with ESMTP id CD91318023912; Wed, 10 Feb 2021 13:04:10 +0000 (UTC) X-Session-Marker: 6A6F6540706572636865732E636F6D X-HE-Tag: fish41_140b27927610 X-Filterd-Recvd-Size: 2507 Received: from [192.168.1.159] (unknown [47.151.137.21]) (Authenticated sender: joe@perches.com) by omf15.hostedemail.com (Postfix) with ESMTPA; Wed, 10 Feb 2021 13:04:08 +0000 (UTC) Message-ID: <5e1e5415dc1bcda37df3ce07a18827172c2a5b7f.camel@perches.com> Subject: Re: [PATCH v4 3/3] vsprintf: dump full information of page flags in pGp From: Joe Perches To: Petr Mladek , Yafang Shao Cc: Matthew Wilcox , Andy Shevchenko , David Hildenbrand , Miaohe Lin , Vlastimil Babka , Christoph Lameter , penberg@kernel.org, David Rientjes , iamjoonsoo.kim@lge.com, Andrew Morton , Steven Rostedt , Sergey Senozhatsky , Linux MM , LKML Date: Wed, 10 Feb 2021 05:04:07 -0800 In-Reply-To: References: <20210209105613.42747-1-laoar.shao@gmail.com> <20210209105613.42747-4-laoar.shao@gmail.com> Content-Type: text/plain; charset="ISO-8859-1" User-Agent: Evolution 3.38.1-1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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: On Wed, 2021-02-10 at 13:51 +0100, Petr Mladek wrote: > On Wed 2021-02-10 00:21:37, Yafang Shao wrote: > > On Tue, Feb 9, 2021 at 9:53 PM Petr Mladek wrote: [] > > =A0for (p =3D pff; p < pff + ARRAY_SIZE(pff); p++) { >=20 > This looks a bit non-standard. IMHO, Joe was not against using index. > He proposed: >=20 > for (i =3D 0; i < ARRAY_SIZE(pfl) && buf < end; i++) { >=20 > , see > https://lore.kernel.org/lkml/e5ea9e8b1190c2a397a1b84dd55bb9c706dc7058.c= amel@perches.com/ >=20 > I am not sure about the (buf < end) check. It might be some > optimization or it did fit the the old code. I believe the buf < end bit was broken anyway. I believe vsprintf is supposed to return the maximum possible length of the output and the function should not restrict that. The function should not write beyond the specified end. =20 > Anyway, I like the currently used: >=20 > for (i =3D 0; i < ARRAY_SIZE(pff); i++) { >=20 > It is standard, easy to understand, and thus more safe. I am sure that > compiler will optimize it very well. true.