On Tue, Sep 19, 2023 at 10:31:16PM -0400, Kent Overstreet wrote:
> On Fri, Sep 15, 2023 at 03:57:56PM +0300, Dan Carpenter wrote:
> > Hello Kent Overstreet,
> > 
> > The patch e0750d947352: "bcachefs: Initial commit" from Mar 16, 2017
> > (linux-next), leads to the following Smatch static checker warning:
> > 
> >     fs/bcachefs/fs-io.c:1013 bch2_seek_hole()
> >     warn: error code type promoted to positive: 'next_hole'
> > 
> > fs/bcachefs/fs-io.c
> >     977 static loff_t bch2_seek_hole(struct file *file, u64 offset)
> >     978 {
> >     979         struct bch_inode_info *inode = file_bch_inode(file);
> >     980         struct bch_fs *c = inode->v.i_sb->s_fs_info;
> >     981         struct btree_trans *trans;
> >     982         struct btree_iter iter;
> >     983         struct bkey_s_c k;
> >     984         subvol_inum inum = inode_inum(inode);
> >     985         u64 isize, next_hole = MAX_LFS_FILESIZE;
> >     986         u32 snapshot;
> >     987         int ret;
> >     988 
> >     989         isize = i_size_read(&inode->v);
> >     990         if (offset >= isize)
> >     991                 return -ENXIO;
> >     992 
> >     993         trans = bch2_trans_get(c);
> >     994 retry:
> >     995         bch2_trans_begin(trans);
> >     996 
> >     997         ret = bch2_subvolume_get_snapshot(trans, inum.subvol, 
> > &snapshot);
> >     998         if (ret)
> >     999                 goto err;
> >     1000 
> >     1001         for_each_btree_key_norestart(trans, iter, BTREE_ID_extents,
> >     1002                            SPOS(inode->v.i_ino, offset >> 9, 
> > snapshot),
> >     1003                            BTREE_ITER_SLOTS, k, ret) {
> >     1004                 if (k.k->p.inode != inode->v.i_ino) {
> >     1005                         next_hole = 
> > bch2_seek_pagecache_hole(&inode->v,
> >     1006                                         offset, MAX_LFS_FILESIZE, 
> > 0, false);
> >     1007                         break;
> >     1008                 } else if (!bkey_extent_is_data(k.k)) {
> >     1009                         next_hole = 
> > bch2_seek_pagecache_hole(&inode->v,
> >     1010                                         max(offset, 
> > bkey_start_offset(k.k) << 9),
> >     1011                                         k.k->p.offset << 9, 0, 
> > false);
> >     1012 
> > 
> > bch2_seek_pagecache_hole returns llof_t.  Negatives on error.  This code
> > has no error checking?
> 
> It doesn't return an error.

It looks to the untrained eye that folio_hole_offset() can return
-ENOENT.  And __filemap_get_folio() can definitely return -ENOMEM.

regards,
dan carpenter

Reply via email to