* [PATCH] erofs: silence warnings related to impossible m_plen
@ 2022-03-10 17:34 Gao Xiang
2022-03-11 8:23 ` Chao Yu
0 siblings, 1 reply; 2+ messages in thread
From: Gao Xiang @ 2022-03-10 17:34 UTC (permalink / raw)
To: linux-erofs, Chao Yu; +Cc: LKML, Gao Xiang, kernel test robot, Dan Carpenter
Dan reported two smatch warnings [1],
.. warn: should '1 << lclusterbits' be a 64 bit type?
.. warn: should 'm->compressedlcs << lclusterbits' be a 64 bit type?
In practice, m_plen cannot be more than 1MiB due to on-disk constraint
for the compression mode, so we're always safe here.
In order to make static analyzers happy and don't report again,
let's silence them instead.
[1] https://lore.kernel.org/r/202203091002.lJVzsX6e-lkp@intel.com
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
---
fs/erofs/zmap.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/fs/erofs/zmap.c b/fs/erofs/zmap.c
index 361b1d6e4bf9..b4059b9c3bac 100644
--- a/fs/erofs/zmap.c
+++ b/fs/erofs/zmap.c
@@ -494,7 +494,7 @@ static int z_erofs_get_extent_compressedlen(struct z_erofs_maprecorder *m,
!(vi->z_advise & Z_EROFS_ADVISE_BIG_PCLUSTER_1)) ||
((m->headtype == Z_EROFS_VLE_CLUSTER_TYPE_HEAD2) &&
!(vi->z_advise & Z_EROFS_ADVISE_BIG_PCLUSTER_2))) {
- map->m_plen = 1 << lclusterbits;
+ map->m_plen = 1ULL << lclusterbits;
return 0;
}
lcn = m->lcn + 1;
@@ -540,7 +540,7 @@ static int z_erofs_get_extent_compressedlen(struct z_erofs_maprecorder *m,
return -EFSCORRUPTED;
}
out:
- map->m_plen = m->compressedlcs << lclusterbits;
+ map->m_plen = (u64)m->compressedlcs << lclusterbits;
return 0;
err_bonus_cblkcnt:
erofs_err(m->inode->i_sb,
--
2.24.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] erofs: silence warnings related to impossible m_plen
2022-03-10 17:34 [PATCH] erofs: silence warnings related to impossible m_plen Gao Xiang
@ 2022-03-11 8:23 ` Chao Yu
0 siblings, 0 replies; 2+ messages in thread
From: Chao Yu @ 2022-03-11 8:23 UTC (permalink / raw)
To: Gao Xiang, linux-erofs; +Cc: LKML, kernel test robot, Dan Carpenter
On 2022/3/11 1:34, Gao Xiang wrote:
> Dan reported two smatch warnings [1],
> .. warn: should '1 << lclusterbits' be a 64 bit type?
> .. warn: should 'm->compressedlcs << lclusterbits' be a 64 bit type?
>
> In practice, m_plen cannot be more than 1MiB due to on-disk constraint
> for the compression mode, so we're always safe here.
>
> In order to make static analyzers happy and don't report again,
> let's silence them instead.
>
> [1] https://lore.kernel.org/r/202203091002.lJVzsX6e-lkp@intel.com
>
> Reported-by: kernel test robot <lkp@intel.com>
> Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
> Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Reviewed-by: Chao Yu <chao@kernel.org>
Thanks,
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-03-11 8:24 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-10 17:34 [PATCH] erofs: silence warnings related to impossible m_plen Gao Xiang
2022-03-11 8:23 ` Chao Yu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).