lkml.org 
[lkml]   [2021]   [Aug]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    Subject[xiang-linux:erofs/chunk 8/8] fs/erofs/data.c:136:25: sparse: sparse: cast to restricted __le32
    tree:   https://git.kernel.org/pub/scm/linux/kernel/git/xiang/linux.git erofs/chunk
    head: a915f0e209270389efab942fcd446e31a98c4062
    commit: a915f0e209270389efab942fcd446e31a98c4062 [8/8] erofs: support reading chunk-based files
    config: x86_64-randconfig-s021-20210816 (attached as .config)
    compiler: gcc-9 (Debian 9.3.0-22) 9.3.0
    reproduce:
    # apt-get install sparse
    # sparse version: v0.6.3-348-gf0e6938b-dirty
    # https://git.kernel.org/pub/scm/linux/kernel/git/xiang/linux.git/commit/?id=a915f0e209270389efab942fcd446e31a98c4062
    git remote add xiang-linux https://git.kernel.org/pub/scm/linux/kernel/git/xiang/linux.git
    git fetch --no-tags xiang-linux erofs/chunk
    git checkout a915f0e209270389efab942fcd446e31a98c4062
    # save the attached .config to linux build tree
    make W=1 C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' O=build_dir ARCH=x86_64 SHELL=/bin/bash fs/erofs/

    If you fix the issue, kindly add following tag as appropriate
    Reported-by: kernel test robot <lkp@intel.com>


    sparse warnings: (new ones prefixed by >>)
    >> fs/erofs/data.c:136:25: sparse: sparse: cast to restricted __le32
    >> fs/erofs/data.c:136:25: sparse: sparse: cast from restricted __le16

    vim +136 fs/erofs/data.c

    80
    81 static int erofs_map_blocks(struct inode *inode,
    82 struct erofs_map_blocks *map, int flags)
    83 {
    84 struct super_block *sb = inode->i_sb;
    85 struct erofs_inode *vi = EROFS_I(inode);
    86 struct erofs_inode_chunk_index *idx;
    87 struct page *page;
    88 u64 chunknr;
    89 unsigned int unit;
    90 erofs_off_t pos;
    91 int err;
    92
    93 if (map->m_la >= inode->i_size) {
    94 map->m_flags = 0;
    95 map->m_plen = 0;
    96 goto out;
    97 }
    98
    99 if (vi->datalayout != EROFS_INODE_CHUNK_BASED)
    100 return erofs_map_blocks_flatmode(inode, map, flags);
    101
    102 if (vi->chunkformat & EROFS_CHUNK_FORMAT_INDEXES)
    103 unit = sizeof(*idx); /* chunk index */
    104 else
    105 unit = 4; /* chunk index */
    106
    107 chunknr = map->m_la >> vi->chunkbits;
    108 pos = ALIGN(iloc(EROFS_SB(sb), vi->nid) + vi->inode_isize +
    109 vi->xattr_isize, unit) + unit * chunknr;
    110
    111 page = erofs_get_meta_page(inode->i_sb, erofs_blknr(pos));
    112 if (IS_ERR(page))
    113 return PTR_ERR(page);
    114
    115 err = 0;
    116 map->m_plen = min_t(erofs_off_t, 1 << vi->chunkbits,
    117 inode->i_size - map->m_la);
    118 if (!(vi->chunkformat & EROFS_CHUNK_FORMAT_INDEXES)) {
    119 __le32 *blkaddr = page_address(page) + erofs_blkoff(pos);
    120
    121 if (le32_to_cpu(*blkaddr) == EROFS_NULL_ADDR) {
    122 map->m_flags = 0;
    123 } else {
    124 map->m_pa = blknr_to_addr(le32_to_cpu(*blkaddr));
    125 map->m_flags = EROFS_MAP_MAPPED;
    126 }
    127 goto out_unlock;
    128 }
    129 idx = page_address(page) + erofs_blkoff(pos);
    130 switch (le32_to_cpu(idx->blkaddr)) {
    131 case EROFS_NULL_ADDR:
    132 map->m_flags = 0;
    133 break;
    134 default:
    135 if (idx->device_id) {
    > 136 erofs_err(sb, "invalid device %u @ %llu for nid %llu",
    137 le32_to_cpu(idx->device_id),
    138 chunknr, vi->nid);
    139 err = -EINVAL;
    140 goto out;
    141 }
    142 map->m_pa = blknr_to_addr(le32_to_cpu(idx->blkaddr));
    143 map->m_flags = EROFS_MAP_MAPPED;
    144 break;
    145 }
    146 out_unlock:
    147 unlock_page(page);
    148 put_page(page);
    149 out:
    150 map->m_llen = map->m_plen;
    151 return err;
    152 }
    153

    ---
    0-DAY CI Kernel Test Service, Intel Corporation
    https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
    [unhandled content-type:application/gzip]
    \
     
     \ /
      Last update: 2021-08-16 03:38    [W:5.145 / U:0.004 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site