From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934591AbbCQJwe (ORCPT ); Tue, 17 Mar 2015 05:52:34 -0400 Received: from szxga02-in.huawei.com ([119.145.14.65]:52548 "EHLO szxga02-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933016AbbCQJwb (ORCPT ); Tue, 17 Mar 2015 05:52:31 -0400 From: Wang Long To: , , , CC: , , , , , , Subject: [PATCH] fs/pstore: Optimization function ramoops_init_przs Date: Tue, 17 Mar 2015 09:31:24 +0000 Message-ID: <1426584684-187152-1-git-send-email-long.wanglong@huawei.com> X-Mailer: git-send-email 1.8.3.4 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.107.197.200] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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