public inbox for gfs2@lists.linux.dev
 help / color / mirror / Atom feed
* [gfs2:for-next 14/21] fs/gfs2/bmap.c:893:9: warning: variable 'ret' is used uninitialized whenever 'if' condition is false
@ 2023-10-24 13:38 kernel test robot
  0 siblings, 0 replies; only message in thread
From: kernel test robot @ 2023-10-24 13:38 UTC (permalink / raw)
  To: Andreas Gruenbacher; +Cc: llvm, oe-kbuild-all, gfs2

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/gfs2/linux-gfs2.git for-next
head:   ec6e8472a6a78f4c630fb45a07a354bbfbeb5660
commit: 2cd225820b919acde16729f05f9f8841de682eef [14/21] gfs2: Initialize metapaths outside of __gfs2_iomap_get
config: hexagon-randconfig-r033-20220828 (https://download.01.org/0day-ci/archive/20231024/202310242105.0fHmealv-lkp@intel.com/config)
compiler: clang version 16.0.4 (https://github.com/llvm/llvm-project.git ae42196bc493ffe877a7e3dff8be32035dea4d07)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231024/202310242105.0fHmealv-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202310242105.0fHmealv-lkp@intel.com/

All warnings (new ones prefixed by >>):

   In file included from fs/gfs2/bmap.c:9:
   In file included from include/linux/buffer_head.h:12:
   In file included from include/linux/blk_types.h:10:
   In file included from include/linux/bvec.h:10:
   In file included from include/linux/highmem.h:12:
   In file included from include/linux/hardirq.h:11:
   In file included from ./arch/hexagon/include/generated/asm/hardirq.h:1:
   In file included from include/asm-generic/hardirq.h:17:
   In file included from include/linux/irq.h:20:
   In file included from include/linux/io.h:13:
   In file included from arch/hexagon/include/asm/io.h:337:
   include/asm-generic/io.h:547:31: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           val = __raw_readb(PCI_IOBASE + addr);
                             ~~~~~~~~~~ ^
   include/asm-generic/io.h:560:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           val = __le16_to_cpu((__le16 __force)__raw_readw(PCI_IOBASE + addr));
                                                           ~~~~~~~~~~ ^
   include/uapi/linux/byteorder/little_endian.h:37:51: note: expanded from macro '__le16_to_cpu'
   #define __le16_to_cpu(x) ((__force __u16)(__le16)(x))
                                                     ^
   In file included from fs/gfs2/bmap.c:9:
   In file included from include/linux/buffer_head.h:12:
   In file included from include/linux/blk_types.h:10:
   In file included from include/linux/bvec.h:10:
   In file included from include/linux/highmem.h:12:
   In file included from include/linux/hardirq.h:11:
   In file included from ./arch/hexagon/include/generated/asm/hardirq.h:1:
   In file included from include/asm-generic/hardirq.h:17:
   In file included from include/linux/irq.h:20:
   In file included from include/linux/io.h:13:
   In file included from arch/hexagon/include/asm/io.h:337:
   include/asm-generic/io.h:573:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           val = __le32_to_cpu((__le32 __force)__raw_readl(PCI_IOBASE + addr));
                                                           ~~~~~~~~~~ ^
   include/uapi/linux/byteorder/little_endian.h:35:51: note: expanded from macro '__le32_to_cpu'
   #define __le32_to_cpu(x) ((__force __u32)(__le32)(x))
                                                     ^
   In file included from fs/gfs2/bmap.c:9:
   In file included from include/linux/buffer_head.h:12:
   In file included from include/linux/blk_types.h:10:
   In file included from include/linux/bvec.h:10:
   In file included from include/linux/highmem.h:12:
   In file included from include/linux/hardirq.h:11:
   In file included from ./arch/hexagon/include/generated/asm/hardirq.h:1:
   In file included from include/asm-generic/hardirq.h:17:
   In file included from include/linux/irq.h:20:
   In file included from include/linux/io.h:13:
   In file included from arch/hexagon/include/asm/io.h:337:
   include/asm-generic/io.h:584:33: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           __raw_writeb(value, PCI_IOBASE + addr);
                               ~~~~~~~~~~ ^
   include/asm-generic/io.h:594:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           __raw_writew((u16 __force)cpu_to_le16(value), PCI_IOBASE + addr);
                                                         ~~~~~~~~~~ ^
   include/asm-generic/io.h:604:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           __raw_writel((u32 __force)cpu_to_le32(value), PCI_IOBASE + addr);
                                                         ~~~~~~~~~~ ^
>> fs/gfs2/bmap.c:893:9: warning: variable 'ret' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
                                   if (flags & IOMAP_REPORT) {
                                       ^~~~~~~~~~~~~~~~~~~~
   fs/gfs2/bmap.c:950:9: note: uninitialized use occurs here
           return ret;
                  ^~~
   fs/gfs2/bmap.c:893:5: note: remove the 'if' if its condition is always true
                                   if (flags & IOMAP_REPORT) {
                                   ^~~~~~~~~~~~~~~~~~~~~~~~~~
   fs/gfs2/bmap.c:892:8: warning: variable 'ret' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
                           if (pos >= size) {
                               ^~~~~~~~~~~
   fs/gfs2/bmap.c:950:9: note: uninitialized use occurs here
           return ret;
                  ^~~
   fs/gfs2/bmap.c:892:4: note: remove the 'if' if its condition is always true
                           if (pos >= size) {
                           ^~~~~~~~~~~~~~~~~
   fs/gfs2/bmap.c:888:8: warning: variable 'ret' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
                           if (pos + length > max_size)
                               ^~~~~~~~~~~~~~~~~~~~~~~
   fs/gfs2/bmap.c:950:9: note: uninitialized use occurs here
           return ret;
                  ^~~
   fs/gfs2/bmap.c:888:4: note: remove the 'if' if its condition is always true
                           if (pos + length > max_size)
                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
   fs/gfs2/bmap.c:871:9: note: initialize the variable 'ret' to silence this warning
           int ret;
                  ^
                   = 0
   9 warnings generated.


vim +893 fs/gfs2/bmap.c

7ee66c03e40a57 Christoph Hellwig   2018-06-01  849  
3974320ca6aa68 Bob Peterson        2017-02-16  850  /**
54992257fe4bb9 Andreas Gruenbacher 2021-03-27  851   * __gfs2_iomap_get - Map blocks from an inode to disk blocks
3974320ca6aa68 Bob Peterson        2017-02-16  852   * @inode: The inode
3974320ca6aa68 Bob Peterson        2017-02-16  853   * @pos: Starting position in bytes
3974320ca6aa68 Bob Peterson        2017-02-16  854   * @length: Length to map, in bytes
3974320ca6aa68 Bob Peterson        2017-02-16  855   * @flags: iomap flags
3974320ca6aa68 Bob Peterson        2017-02-16  856   * @iomap: The iomap structure
628e366df11c0a Andreas Gruenbacher 2018-06-04  857   * @mp: The metapath
3974320ca6aa68 Bob Peterson        2017-02-16  858   *
3974320ca6aa68 Bob Peterson        2017-02-16  859   * Returns: errno
3974320ca6aa68 Bob Peterson        2017-02-16  860   */
54992257fe4bb9 Andreas Gruenbacher 2021-03-27  861  static int __gfs2_iomap_get(struct inode *inode, loff_t pos, loff_t length,
628e366df11c0a Andreas Gruenbacher 2018-06-04  862  			    unsigned flags, struct iomap *iomap,
628e366df11c0a Andreas Gruenbacher 2018-06-04  863  			    struct metapath *mp)
b3b94faa5fe596 David Teigland      2006-01-16  864  {
feaa7bba026c18 Steven Whitehouse   2006-06-14  865  	struct gfs2_inode *ip = GFS2_I(inode);
feaa7bba026c18 Steven Whitehouse   2006-06-14  866  	struct gfs2_sbd *sdp = GFS2_SB(inode);
d505a96a3b16f4 Andreas Gruenbacher 2018-06-24  867  	loff_t size = i_size_read(inode);
9b8c81d1de4994 Steven Whitehouse   2008-02-22  868  	__be64 *ptr;
3974320ca6aa68 Bob Peterson        2017-02-16  869  	sector_t lblock;
628e366df11c0a Andreas Gruenbacher 2018-06-04  870  	sector_t lblock_stop;
628e366df11c0a Andreas Gruenbacher 2018-06-04  871  	int ret;
9b8c81d1de4994 Steven Whitehouse   2008-02-22  872  	int eob;
628e366df11c0a Andreas Gruenbacher 2018-06-04  873  	u64 len;
2cd225820b919a Andreas Gruenbacher 2023-10-20  874  	struct buffer_head *bh;
9b8c81d1de4994 Steven Whitehouse   2008-02-22  875  	u8 height;
7276b3b0c77101 Steven Whitehouse   2006-09-21  876  
628e366df11c0a Andreas Gruenbacher 2018-06-04  877  	if (!length)
628e366df11c0a Andreas Gruenbacher 2018-06-04  878  		return -EINVAL;
b3b94faa5fe596 David Teigland      2006-01-16  879  
d505a96a3b16f4 Andreas Gruenbacher 2018-06-24  880  	down_read(&ip->i_rw_mutex);
d505a96a3b16f4 Andreas Gruenbacher 2018-06-24  881  
49edd5bf429c40 Andreas Gruenbacher 2018-02-06  882  	if (gfs2_is_stuffed(ip)) {
2cd225820b919a Andreas Gruenbacher 2023-10-20  883  		struct buffer_head *dibh = metapath_dibh(mp);
2cd225820b919a Andreas Gruenbacher 2023-10-20  884  
d505a96a3b16f4 Andreas Gruenbacher 2018-06-24  885  		if (flags & IOMAP_WRITE) {
d505a96a3b16f4 Andreas Gruenbacher 2018-06-24  886  			loff_t max_size = gfs2_max_stuffed_size(ip);
d505a96a3b16f4 Andreas Gruenbacher 2018-06-24  887  
d505a96a3b16f4 Andreas Gruenbacher 2018-06-24  888  			if (pos + length > max_size)
d505a96a3b16f4 Andreas Gruenbacher 2018-06-24  889  				goto unstuff;
d505a96a3b16f4 Andreas Gruenbacher 2018-06-24  890  			iomap->length = max_size;
d505a96a3b16f4 Andreas Gruenbacher 2018-06-24  891  		} else {
d505a96a3b16f4 Andreas Gruenbacher 2018-06-24  892  			if (pos >= size) {
49edd5bf429c40 Andreas Gruenbacher 2018-02-06 @893  				if (flags & IOMAP_REPORT) {
d505a96a3b16f4 Andreas Gruenbacher 2018-06-24  894  					ret = -ENOENT;
d505a96a3b16f4 Andreas Gruenbacher 2018-06-24  895  					goto unlock;
d505a96a3b16f4 Andreas Gruenbacher 2018-06-24  896  				} else {
d505a96a3b16f4 Andreas Gruenbacher 2018-06-24  897  					iomap->offset = pos;
d505a96a3b16f4 Andreas Gruenbacher 2018-06-24  898  					iomap->length = length;
566a2ab3c9005f Andreas Gruenbacher 2020-04-20  899  					goto hole_found;
d505a96a3b16f4 Andreas Gruenbacher 2018-06-24  900  				}
3974320ca6aa68 Bob Peterson        2017-02-16  901  			}
d505a96a3b16f4 Andreas Gruenbacher 2018-06-24  902  			iomap->length = size;
49edd5bf429c40 Andreas Gruenbacher 2018-02-06  903  		}
d505a96a3b16f4 Andreas Gruenbacher 2018-06-24  904  		iomap->addr = (ip->i_no_addr << inode->i_blkbits) +
d505a96a3b16f4 Andreas Gruenbacher 2018-06-24  905  			      sizeof(struct gfs2_dinode);
d505a96a3b16f4 Andreas Gruenbacher 2018-06-24  906  		iomap->type = IOMAP_INLINE;
64bc06bb32ee9c Andreas Gruenbacher 2018-06-24  907  		iomap->inline_data = dibh->b_data + sizeof(struct gfs2_dinode);
d505a96a3b16f4 Andreas Gruenbacher 2018-06-24  908  		goto out;
d505a96a3b16f4 Andreas Gruenbacher 2018-06-24  909  	}
d505a96a3b16f4 Andreas Gruenbacher 2018-06-24  910  
d505a96a3b16f4 Andreas Gruenbacher 2018-06-24  911  unstuff:
3974320ca6aa68 Bob Peterson        2017-02-16  912  	lblock = pos >> inode->i_blkbits;
3974320ca6aa68 Bob Peterson        2017-02-16  913  	iomap->offset = lblock << inode->i_blkbits;
628e366df11c0a Andreas Gruenbacher 2018-06-04  914  	lblock_stop = (pos + length - 1) >> inode->i_blkbits;
628e366df11c0a Andreas Gruenbacher 2018-06-04  915  	len = lblock_stop - lblock + 1;
d505a96a3b16f4 Andreas Gruenbacher 2018-06-24  916  	iomap->length = len << inode->i_blkbits;
20cdc1931ee8e0 Andreas Gruenbacher 2017-09-22  917  
9b8c81d1de4994 Steven Whitehouse   2008-02-22  918  	height = ip->i_height;
9a38662ba4e268 Andreas Gruenbacher 2018-04-16  919  	while ((lblock + 1) * sdp->sd_sb.sb_bsize > sdp->sd_heightsize[height])
ecc30c79157103 Steven Whitehouse   2008-01-28  920  		height++;
628e366df11c0a Andreas Gruenbacher 2018-06-04  921  	find_metapath(sdp, lblock, mp, height);
9b8c81d1de4994 Steven Whitehouse   2008-02-22  922  	if (height > ip->i_height || gfs2_is_stuffed(ip))
9b8c81d1de4994 Steven Whitehouse   2008-02-22  923  		goto do_alloc;
3974320ca6aa68 Bob Peterson        2017-02-16  924  
628e366df11c0a Andreas Gruenbacher 2018-06-04  925  	ret = lookup_metapath(ip, mp);
e8b43fe0c1e035 Andreas Gruenbacher 2017-12-08  926  	if (ret)
628e366df11c0a Andreas Gruenbacher 2018-06-04  927  		goto unlock;
3974320ca6aa68 Bob Peterson        2017-02-16  928  
628e366df11c0a Andreas Gruenbacher 2018-06-04  929  	if (mp->mp_aheight != ip->i_height)
9b8c81d1de4994 Steven Whitehouse   2008-02-22  930  		goto do_alloc;
3974320ca6aa68 Bob Peterson        2017-02-16  931  
628e366df11c0a Andreas Gruenbacher 2018-06-04  932  	ptr = metapointer(ip->i_height - 1, mp);
9b8c81d1de4994 Steven Whitehouse   2008-02-22  933  	if (*ptr == 0)
9b8c81d1de4994 Steven Whitehouse   2008-02-22  934  		goto do_alloc;
3974320ca6aa68 Bob Peterson        2017-02-16  935  
628e366df11c0a Andreas Gruenbacher 2018-06-04  936  	bh = mp->mp_bh[ip->i_height - 1];
b4bf3d5c37d404 Andreas Gruenbacher 2023-09-14  937  	len = gfs2_extent_length(bh, ptr, &eob);
3974320ca6aa68 Bob Peterson        2017-02-16  938  
628e366df11c0a Andreas Gruenbacher 2018-06-04  939  	iomap->addr = be64_to_cpu(*ptr) << inode->i_blkbits;
628e366df11c0a Andreas Gruenbacher 2018-06-04  940  	iomap->length = len << inode->i_blkbits;
628e366df11c0a Andreas Gruenbacher 2018-06-04  941  	iomap->type = IOMAP_MAPPED;
0ed91eca1130e6 Andreas Gruenbacher 2018-07-25  942  	iomap->flags |= IOMAP_F_MERGED;
9b8c81d1de4994 Steven Whitehouse   2008-02-22  943  	if (eob)
7ee66c03e40a57 Christoph Hellwig   2018-06-01  944  		iomap->flags |= IOMAP_F_GFS2_BOUNDARY;
3974320ca6aa68 Bob Peterson        2017-02-16  945  
3974320ca6aa68 Bob Peterson        2017-02-16  946  out:
628e366df11c0a Andreas Gruenbacher 2018-06-04  947  	iomap->bdev = inode->i_sb->s_bdev;
628e366df11c0a Andreas Gruenbacher 2018-06-04  948  unlock:
628e366df11c0a Andreas Gruenbacher 2018-06-04  949  	up_read(&ip->i_rw_mutex);
9b8c81d1de4994 Steven Whitehouse   2008-02-22  950  	return ret;
9b8c81d1de4994 Steven Whitehouse   2008-02-22  951  
9b8c81d1de4994 Steven Whitehouse   2008-02-22  952  do_alloc:
628e366df11c0a Andreas Gruenbacher 2018-06-04  953  	if (flags & IOMAP_REPORT) {
49edd5bf429c40 Andreas Gruenbacher 2018-02-06  954  		if (pos >= size)
3974320ca6aa68 Bob Peterson        2017-02-16  955  			ret = -ENOENT;
628e366df11c0a Andreas Gruenbacher 2018-06-04  956  		else if (height == ip->i_height)
628e366df11c0a Andreas Gruenbacher 2018-06-04  957  			ret = gfs2_hole_size(inode, lblock, len, mp, iomap);
49edd5bf429c40 Andreas Gruenbacher 2018-02-06  958  		else
f3506eee81d1f7 Andreas Gruenbacher 2021-11-06  959  			iomap->length = size - iomap->offset;
64bc06bb32ee9c Andreas Gruenbacher 2018-06-24  960  	} else if (flags & IOMAP_WRITE) {
64bc06bb32ee9c Andreas Gruenbacher 2018-06-24  961  		u64 alloc_size;
64bc06bb32ee9c Andreas Gruenbacher 2018-06-24  962  
967bcc91b04493 Andreas Gruenbacher 2018-06-19  963  		if (flags & IOMAP_DIRECT)
967bcc91b04493 Andreas Gruenbacher 2018-06-19  964  			goto out;  /* (see gfs2_file_direct_write) */
967bcc91b04493 Andreas Gruenbacher 2018-06-19  965  
64bc06bb32ee9c Andreas Gruenbacher 2018-06-24  966  		len = gfs2_alloc_size(inode, mp, len);
64bc06bb32ee9c Andreas Gruenbacher 2018-06-24  967  		alloc_size = len << inode->i_blkbits;
64bc06bb32ee9c Andreas Gruenbacher 2018-06-24  968  		if (alloc_size < iomap->length)
64bc06bb32ee9c Andreas Gruenbacher 2018-06-24  969  			iomap->length = alloc_size;
64bc06bb32ee9c Andreas Gruenbacher 2018-06-24  970  	} else {
d505a96a3b16f4 Andreas Gruenbacher 2018-06-24  971  		if (pos < size && height == ip->i_height)
d505a96a3b16f4 Andreas Gruenbacher 2018-06-24  972  			ret = gfs2_hole_size(inode, lblock, len, mp, iomap);
3974320ca6aa68 Bob Peterson        2017-02-16  973  	}
566a2ab3c9005f Andreas Gruenbacher 2020-04-20  974  hole_found:
566a2ab3c9005f Andreas Gruenbacher 2020-04-20  975  	iomap->addr = IOMAP_NULL_ADDR;
566a2ab3c9005f Andreas Gruenbacher 2020-04-20  976  	iomap->type = IOMAP_HOLE;
628e366df11c0a Andreas Gruenbacher 2018-06-04  977  	goto out;
628e366df11c0a Andreas Gruenbacher 2018-06-04  978  }
628e366df11c0a Andreas Gruenbacher 2018-06-04  979  

:::::: The code at line 893 was first introduced by commit
:::::: 49edd5bf429c405b3a7f75503845d9f66a47dd4b gfs2: Fixes to "Implement iomap for block_map"

:::::: TO: Andreas Gruenbacher <agruenba@redhat.com>
:::::: CC: Bob Peterson <rpeterso@redhat.com>

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-10-24 13:44 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-24 13:38 [gfs2:for-next 14/21] fs/gfs2/bmap.c:893:9: warning: variable 'ret' is used uninitialized whenever 'if' condition is false kernel test robot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox