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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 62005C4332F for ; Fri, 10 Nov 2023 01:41:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345552AbjKJBl1 (ORCPT ); Thu, 9 Nov 2023 20:41:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34388 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234633AbjKJBlY (ORCPT ); Thu, 9 Nov 2023 20:41:24 -0500 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2EBCA44A6 for ; Thu, 9 Nov 2023 17:41:22 -0800 (PST) Received: from dggpemm500020.china.huawei.com (unknown [172.30.72.56]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4SRM3n51R2zfb83; Fri, 10 Nov 2023 09:41:09 +0800 (CST) Received: from [10.174.176.88] (10.174.176.88) by dggpemm500020.china.huawei.com (7.185.36.49) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.31; Fri, 10 Nov 2023 09:41:20 +0800 Message-ID: Date: Fri, 10 Nov 2023 09:41:19 +0800 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH -next V2] erofs: code clean up for function erofs_read_inode() To: Gao Xiang , , CC: , , , References: <20231109194821.1719430-1-wozizhi@huawei.com> <4d4202a7-6648-9d2c-3f0b-079a165c2ebf@linux.alibaba.com> <89069fa4-7347-4364-8793-1ce705a00b92@huawei.com> <872a459d-449d-c057-625e-98c7c8b697ab@linux.alibaba.com> From: Zizhi Wo In-Reply-To: <872a459d-449d-c057-625e-98c7c8b697ab@linux.alibaba.com> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 8bit X-Originating-IP: [10.174.176.88] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To dggpemm500020.china.huawei.com (7.185.36.49) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 在 2023/11/9 23:42, Gao Xiang 写道: > > > On 2023/11/9 21:45, Zizhi Wo wrote: >> >> >> 在 2023/11/9 21:14, Gao Xiang 写道: >>> Hi, >>> >>> On 2023/11/10 03:48, WoZ1zh1 wrote: >>>> Because variables "die" and "copied" only appear in case >>>> EROFS_INODE_LAYOUT_EXTENDED, move them from the outer space into this >>>> case. Also, call "kfree(copied)" earlier to avoid double free in the >>>> "error_out" branch. Some cleanups, no logic changes. >>>> >>>> Signed-off-by: WoZ1zh1 >>> >>> Please help use your real name here... Oh, I'm sorry for the confusion I caused you. I have changed my name on .gitconfig. >>> >>>> --- >>>>   fs/erofs/inode.c | 6 +++--- >>>>   1 file changed, 3 insertions(+), 3 deletions(-) >>>> >>>> diff --git a/fs/erofs/inode.c b/fs/erofs/inode.c >>>> index b8ad05b4509d..a388c93eec34 100644 >>>> --- a/fs/erofs/inode.c >>>> +++ b/fs/erofs/inode.c >>>> @@ -19,7 +19,6 @@ static void *erofs_read_inode(struct erofs_buf *buf, >>>>       erofs_blk_t blkaddr, nblks = 0; >>>>       void *kaddr; >>>>       struct erofs_inode_compact *dic; >>>> -    struct erofs_inode_extended *die, *copied = NULL; >>>>       unsigned int ifmt; >>>>       int err; >>>> @@ -53,6 +52,8 @@ static void *erofs_read_inode(struct erofs_buf *buf, >>>>       switch (erofs_inode_version(ifmt)) { >>>>       case EROFS_INODE_LAYOUT_EXTENDED: >>>> +        struct erofs_inode_extended *die, *copied = NULL; >>> >>> Thanks for the patch, but in my own opinion: >>> >>> 1) It doesn't simplify the code >> OK, I'm sorry for the noise(;´༎ຶД༎ຶ`) >>> >>> 2) We'd like to avoid defining variables like this (in the >>>     switch block), and I even don't think this patch can compile. >> I tested this patch with gcc-12.2.1 locally and it compiled >> successfully. I'm not sure if this patch will fail in other environment >> with different compiler... > > For example, it fails as below on gcc 10.2.1: > > fs/erofs/inode.c: In function 'erofs_read_inode': > fs/erofs/inode.c:55:3: error: a label can only be part of a statement > and a declaration is not a statement >    55 |   struct erofs_inode_extended *die, *copied = NULL; >       |   ^~~~~~ > Oh, I'm sorry about that! I still need to learn more. Thank you for your assistance! Thanks, Zizhi Wo >> >>> 3) The logic itself is also broken... > > Maybe I was missing something, but this usage makes > me uneasy... > > Thanks, > Gao Xiang > >> >> Sorry, but I just don't understand why the logic itself is broken, and >> can you please explain more? >> >> Thanks, >> Zizhi Wo >> >>> Thanks, >>> Gao Xiang >