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 C7B79C433E0 for ; Wed, 10 Feb 2021 13:07:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8F7C164DD8 for ; Wed, 10 Feb 2021 13:07:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230183AbhBJNGy (ORCPT ); Wed, 10 Feb 2021 08:06:54 -0500 Received: from smtprelay0010.hostedemail.com ([216.40.44.10]:43534 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S231765AbhBJNEw (ORCPT ); Wed, 10 Feb 2021 08:04:52 -0500 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: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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: [] > >  for (p = pff; p < pff + ARRAY_SIZE(pff); p++) { > > This looks a bit non-standard. IMHO, Joe was not against using index. > He proposed: > > for (i = 0; i < ARRAY_SIZE(pfl) && buf < end; i++) { > > , see > https://lore.kernel.org/lkml/e5ea9e8b1190c2a397a1b84dd55bb9c706dc7058.camel@perches.com/ > > 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. > Anyway, I like the currently used: > > for (i = 0; i < ARRAY_SIZE(pff); i++) { > > It is standard, easy to understand, and thus more safe. I am sure that > compiler will optimize it very well. true.