From: Hongbo Li <lihongbo22@huawei.com>
To: Gao Xiang <hsiangkao@linux.alibaba.com>,
Hongzhen Luo <hongzhen@linux.alibaba.com>,
<linux-erofs@lists.ozlabs.org>
Cc: <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2] erofs: use Z_EROFS_LCLUSTER_TYPE_MAX to simplify switches
Date: Fri, 7 Feb 2025 16:57:01 +0800 [thread overview]
Message-ID: <10e648ae-7e0b-4560-a73d-b728efbc9e15@huawei.com> (raw)
In-Reply-To: <f4319592-df8f-4468-b8fb-7fcbc51804c6@linux.alibaba.com>
On 2025/2/7 16:29, Gao Xiang wrote:
>
>
> On 2025/2/7 16:08, Hongzhen Luo wrote:
>> There's no need to enumerate each type. No logic changes.
>>
>> Signed-off-by: Hongzhen Luo <hongzhen@linux.alibaba.com>
>> ---
>> Changes since v1: Put the exception branch at the beginning.
>>
>> v1:
>> https://lore.kernel.org/all/20250207064135.2249529-1-hongzhen@linux.alibaba.com/
>> ---
>> fs/erofs/zmap.c | 65 +++++++++++++++++++++----------------------------
>> 1 file changed, 28 insertions(+), 37 deletions(-)
>>
>> diff --git a/fs/erofs/zmap.c b/fs/erofs/zmap.c
>> index 689437e99a5a..f65c76991e02 100644
>> --- a/fs/erofs/zmap.c
>> +++ b/fs/erofs/zmap.c
>> @@ -265,23 +265,22 @@ static int z_erofs_extent_lookback(struct
>> z_erofs_maprecorder *m,
>> if (err)
>> return err;
>> - switch (m->type) {
>> - case Z_EROFS_LCLUSTER_TYPE_NONHEAD:
>> + if (m->type >= Z_EROFS_LCLUSTER_TYPE_MAX) {
>> + erofs_err(sb, "unknown type %u @ lcn %lu of nid %llu",
>> + m->type, lcn, vi->nid);
>> + DBG_BUGON(1);
>> + return -EOPNOTSUPP;
>> + }
>> +
>> + if (m->type == Z_EROFS_LCLUSTER_TYPE_NONHEAD) {
>> lookback_distance = m->delta[0];
>> if (!lookback_distance)
>> goto err_bogus;
>> continue;
>> - case Z_EROFS_LCLUSTER_TYPE_PLAIN:
>> - case Z_EROFS_LCLUSTER_TYPE_HEAD1:
>> - case Z_EROFS_LCLUSTER_TYPE_HEAD2:
>> + } else if (m->type < Z_EROFS_LCLUSTER_TYPE_MAX) {
>
>
> Just `} else {` here?
>
>> m->headtype = m->type;
>> m->map->m_la = (lcn << lclusterbits) | m->clusterofs;
>> return 0;
>> - default:
>> - erofs_err(sb, "unknown type %u @ lcn %lu of nid %llu",
>> - m->type, lcn, vi->nid);
>> - DBG_BUGON(1);
>> - return -EOPNOTSUPP;
>> }
>> }
>> err_bogus:
>> @@ -329,35 +328,31 @@ static int
>> z_erofs_get_extent_compressedlen(struct z_erofs_maprecorder *m,
>> DBG_BUGON(lcn == initial_lcn &&
>> m->type == Z_EROFS_LCLUSTER_TYPE_NONHEAD);
>> - switch (m->type) {
>> - case Z_EROFS_LCLUSTER_TYPE_PLAIN:
>> - case Z_EROFS_LCLUSTER_TYPE_HEAD1:
>> - case Z_EROFS_LCLUSTER_TYPE_HEAD2:
>> + if (m->type >= Z_EROFS_LCLUSTER_TYPE_MAX) {
>> + erofs_err(sb, "cannot found CBLKCNT @ lcn %lu of nid %llu",
>> lcn, vi->nid);
>> + DBG_BUGON(1);
>> + return -EFSCORRUPTED;
>> + }
>
> No, I don't think it's equivalent, please use
> the previous version for this part instead.
I think this version doesn't consider the fallthrough case. May be just
use the goto statement can keep equivalent.
Thanks,
Hongbo
>
> Thanks,
> Gao Xiang
next prev parent reply other threads:[~2025-02-07 8:57 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-07 8:08 Hongzhen Luo
2025-02-07 8:29 ` Gao Xiang
2025-02-07 8:57 ` Hongbo Li [this message]
2025-02-07 9:10 ` Gao Xiang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=10e648ae-7e0b-4560-a73d-b728efbc9e15@huawei.com \
--to=lihongbo22@huawei.com \
--cc=hongzhen@linux.alibaba.com \
--cc=hsiangkao@linux.alibaba.com \
--cc=linux-erofs@lists.ozlabs.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®