From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932873AbbCRBfS (ORCPT ); Tue, 17 Mar 2015 21:35:18 -0400 Received: from szxga03-in.huawei.com ([119.145.14.66]:57681 "EHLO szxga03-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932788AbbCRBfO (ORCPT ); Tue, 17 Mar 2015 21:35:14 -0400 Message-ID: <5508D638.6080804@huawei.com> Date: Wed, 18 Mar 2015 09:34:48 +0800 From: "long.wanglong" User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:16.0) Gecko/20121010 Thunderbird/16.0.1 MIME-Version: 1.0 To: Kees Cook CC: Anton Vorontsov , Colin Cross , "Tony Luck" , LKML , peifeiyue , Marco Stornelli , "Anton Vorontsov" , Mark Salyzyn , Sergiu Iordache Subject: Re: [PATCH] fs/pstore: Optimization function ramoops_init_przs References: <1426584684-187152-1-git-send-email-long.wanglong@huawei.com> In-Reply-To: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.111.88.174] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020202.5508D647.00F2,ss=1,re=0.001,recu=0.000,reip=0.000,cl=1,cld=1,fgs=0, ip=0.0.0.0, so=2013-05-26 15:14:31, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: ed58e8f3b5a4b1a32cf6b588d8e95787 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2015/3/18 1:39, Kees Cook wrote: > On Tue, Mar 17, 2015 at 2:31 AM, Wang Long wrote: >> The value of cxt->record_size does not change in the loop, >> so this patch optimize the assign statement by moving >> it to outer. >> >> Signed-off-by: Wang Long >> --- >> fs/pstore/ram.c | 4 ++-- >> 1 file changed, 2 insertions(+), 2 deletions(-) >> >> diff --git a/fs/pstore/ram.c b/fs/pstore/ram.c >> index 44a549b..2105a16 100644 >> --- a/fs/pstore/ram.c >> +++ b/fs/pstore/ram.c >> @@ -373,6 +373,7 @@ static int ramoops_init_przs(struct device *dev, struct ramoops_context *cxt, >> { >> int err = -ENOMEM; >> int i; >> + size_t sz; >> >> if (!cxt->record_size) >> return 0; >> @@ -393,9 +394,8 @@ static int ramoops_init_przs(struct device *dev, struct ramoops_context *cxt, >> goto fail_prz; >> } >> >> + sz = cxt->record_size; >> for (i = 0; i < cxt->max_dump_cnt; i++) { >> - size_t sz = cxt->record_size; >> - >> cxt->przs[i] = persistent_ram_new(*paddr, sz, 0, >> &cxt->ecc_info, >> cxt->memtype); >> -- >> 1.8.3.4 >> > > Actually, can't we drop sz entirely and just use cxt->record_size in its place? > > -Kees > I agree with you. drop sz entirely and use cxt->record_size in its place can improve readability. I will send another patch. Best Regards Wang Long