public inbox for llvm@lists.linux.dev
 help / color / mirror / Atom feed
* [bcachefs:bcachefs-testing 79/139] fs/bcachefs/btree_io.c:893:6: warning: format specifies type 'unsigned long' but the argument has type 'unsigned int'
@ 2024-04-13  7:03 kernel test robot
  0 siblings, 0 replies; only message in thread
From: kernel test robot @ 2024-04-13  7:03 UTC (permalink / raw)
  To: Kent Overstreet; +Cc: llvm, oe-kbuild-all, Kent Overstreet

tree:   https://evilpiepirate.org/git/bcachefs.git bcachefs-testing
head:   c5ff0e7dfafa4898b8cc873266d71b465bb062dc
commit: efa71a63d7d88348ef4dc6421e353f5bb8dd3662 [79/139] bcachefs: Check for packed bkeys that are too big
config: hexagon-allyesconfig (https://download.01.org/0day-ci/archive/20240413/202404131536.HdAMBOVc-lkp@intel.com/config)
compiler: clang version 19.0.0git (https://github.com/llvm/llvm-project 8b3b4a92adee40483c27f26c478a384cd69c6f05)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240413/202404131536.HdAMBOVc-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/202404131536.HdAMBOVc-lkp@intel.com/

All warnings (new ones prefixed by >>):

   In file included from fs/bcachefs/btree_io.c:3:
   In file included from fs/bcachefs/bcachefs.h:188:
   In file included from include/linux/bio.h:10:
   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:10:
   In file included from include/linux/mm.h:2208:
   include/linux/vmstat.h:522:36: warning: arithmetic between different enumeration types ('enum node_stat_item' and 'enum lru_list') [-Wenum-enum-conversion]
     522 |         return node_stat_name(NR_LRU_BASE + lru) + 3; // skip "nr_"
         |                               ~~~~~~~~~~~ ^ ~~~
   In file included from fs/bcachefs/btree_io.c:3:
   In file included from fs/bcachefs/bcachefs.h:188:
   In file included from include/linux/bio.h:10:
   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:328:
   include/asm-generic/io.h:547:31: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     547 |         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]
     560 |         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'
      37 | #define __le16_to_cpu(x) ((__force __u16)(__le16)(x))
         |                                                   ^
   In file included from fs/bcachefs/btree_io.c:3:
   In file included from fs/bcachefs/bcachefs.h:188:
   In file included from include/linux/bio.h:10:
   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:328:
   include/asm-generic/io.h:573:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     573 |         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'
      35 | #define __le32_to_cpu(x) ((__force __u32)(__le32)(x))
         |                                                   ^
   In file included from fs/bcachefs/btree_io.c:3:
   In file included from fs/bcachefs/bcachefs.h:188:
   In file included from include/linux/bio.h:10:
   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:328:
   include/asm-generic/io.h:584:33: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     584 |         __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]
     594 |         __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]
     604 |         __raw_writel((u32 __force)cpu_to_le32(value), PCI_IOBASE + addr);
         |                                                       ~~~~~~~~~~ ^
>> fs/bcachefs/btree_io.c:893:6: warning: format specifies type 'unsigned long' but the argument has type 'unsigned int' [-Wformat]
     887 |                 if (btree_err_on(!bkeyp_u64s_valid(&b->format, k),
         |                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     888 |                                  -BCH_ERR_btree_node_read_err_fixable,
         |                                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     889 |                                  c, NULL, b, i,
         |                                  ~~~~~~~~~~~~~~
     890 |                                  btree_node_bkey_bad_u64s,
         |                                  ~~~~~~~~~~~~~~~~~~~~~~~~~
     891 |                                  "bad k->u64s %u (min %u max %lu)", k->u64s,
         |                                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
         |                                                              %u
     892 |                                  bkeyp_key_u64s(&b->format, k),
         |                                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     893 |                                  U8_MAX - BKEY_U64s + bkeyp_key_u64s(&b->format, k)))
         |                                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/limits.h:15:17: note: expanded from macro 'U8_MAX'
      15 | #define U8_MAX          ((u8)~0U)
         |                         ^
   fs/bcachefs/btree_io.c:613:53: note: expanded from macro 'btree_err_on'
     613 | #define btree_err_on(cond, ...) ((cond) ? btree_err(__VA_ARGS__) : false)
         |                                           ~~~~~~~~~~^~~~~~~~~~~~
   fs/bcachefs/btree_io.c:603:18: note: expanded from macro 'btree_err'
     603 |                                msg, ##__VA_ARGS__);                     \
         |                                ~~~    ^~~~~~~~~~~
   fs/bcachefs/btree_io.c:1870:36: warning: bitwise operation between different enumeration types ('enum bch_watermark' and 'enum bch_trans_commit_flags') [-Wenum-enum-conversion]
    1870 |                                         BCH_WATERMARK_interior_updates|
         |                                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
    1871 |                                         BCH_TRANS_COMMIT_journal_reclaim|
         |                                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   fs/bcachefs/btree_update.h:188:71: note: expanded from macro 'bch2_trans_do'
     188 |         bch2_trans_run(_c, commit_do(trans, _disk_res, _journal_seq, _flags, _do))
         |                                                                              ^~~
   fs/bcachefs/btree_update.h:172:25: note: expanded from macro 'commit_do'
     172 |         lockrestart_do(_trans, _do ?: bch2_trans_commit(_trans, (_disk_res),\
         |                                ^~~
   fs/bcachefs/btree_iter.h:662:11: note: expanded from macro 'lockrestart_do'
     662 |         _ret2 = (_do);                                                  \
         |                  ^~~
   fs/bcachefs/btree_update.h:182:14: note: expanded from macro 'bch2_trans_run'
     182 |         int _ret = (_do);                                               \
         |                     ^~~
   9 warnings generated.


vim +893 fs/bcachefs/btree_io.c

   853	
   854	static int validate_bset_keys(struct bch_fs *c, struct btree *b,
   855				 struct bset *i, int write,
   856				 bool have_retry, bool *saw_error)
   857	{
   858		unsigned version = le16_to_cpu(i->version);
   859		struct bkey_packed *k, *prev = NULL;
   860		struct printbuf buf = PRINTBUF;
   861		bool updated_range = b->key.k.type == KEY_TYPE_btree_ptr_v2 &&
   862			BTREE_PTR_RANGE_UPDATED(&bkey_i_to_btree_ptr_v2(&b->key)->v);
   863		int ret = 0;
   864	
   865		for (k = i->start;
   866		     k != vstruct_last(i);) {
   867			struct bkey_s u;
   868			struct bkey tmp;
   869			unsigned next_good_key;
   870	
   871			if (btree_err_on(bkey_p_next(k) > vstruct_last(i),
   872					 -BCH_ERR_btree_node_read_err_fixable,
   873					 c, NULL, b, i,
   874					 btree_node_bkey_past_bset_end,
   875					 "key extends past end of bset")) {
   876				i->u64s = cpu_to_le16((u64 *) k - i->_data);
   877				break;
   878			}
   879	
   880			if (btree_err_on(k->format > KEY_FORMAT_CURRENT,
   881					 -BCH_ERR_btree_node_read_err_fixable,
   882					 c, NULL, b, i,
   883					 btree_node_bkey_bad_format,
   884					 "invalid bkey format %u", k->format))
   885				goto drop_this_key;
   886	
   887			if (btree_err_on(!bkeyp_u64s_valid(&b->format, k),
   888					 -BCH_ERR_btree_node_read_err_fixable,
   889					 c, NULL, b, i,
   890					 btree_node_bkey_bad_u64s,
   891					 "bad k->u64s %u (min %u max %lu)", k->u64s,
   892					 bkeyp_key_u64s(&b->format, k),
 > 893					 U8_MAX - BKEY_U64s + bkeyp_key_u64s(&b->format, k)))
   894				goto drop_this_key;
   895	
   896			if (!write)
   897				bch2_bkey_compat(b->c.level, b->c.btree_id, version,
   898					    BSET_BIG_ENDIAN(i), write,
   899					    &b->format, k);
   900	
   901			u = __bkey_disassemble(b, k, &tmp);
   902	
   903			printbuf_reset(&buf);
   904			if (bset_key_invalid(c, b, u.s_c, updated_range, write, &buf)) {
   905				printbuf_reset(&buf);
   906				bset_key_invalid(c, b, u.s_c, updated_range, write, &buf);
   907				prt_printf(&buf, "\n  ");
   908				bch2_bkey_val_to_text(&buf, c, u.s_c);
   909	
   910				btree_err(-BCH_ERR_btree_node_read_err_fixable,
   911					  c, NULL, b, i,
   912					  btree_node_bad_bkey,
   913					  "invalid bkey: %s", buf.buf);
   914				goto drop_this_key;
   915			}
   916	
   917			if (write)
   918				bch2_bkey_compat(b->c.level, b->c.btree_id, version,
   919					    BSET_BIG_ENDIAN(i), write,
   920					    &b->format, k);
   921	
   922			if (prev && bkey_iter_cmp(b, prev, k) > 0) {
   923				struct bkey up = bkey_unpack_key(b, prev);
   924	
   925				printbuf_reset(&buf);
   926				prt_printf(&buf, "keys out of order: ");
   927				bch2_bkey_to_text(&buf, &up);
   928				prt_printf(&buf, " > ");
   929				bch2_bkey_to_text(&buf, u.k);
   930	
   931				if (btree_err(-BCH_ERR_btree_node_read_err_fixable,
   932					      c, NULL, b, i,
   933					      btree_node_bkey_out_of_order,
   934					      "%s", buf.buf))
   935					goto drop_this_key;
   936			}
   937	
   938			prev = k;
   939			k = bkey_p_next(k);
   940			continue;
   941	drop_this_key:
   942			next_good_key = k->u64s;
   943	
   944			if (!next_good_key ||
   945			    (BSET_BIG_ENDIAN(i) == CPU_BIG_ENDIAN &&
   946			     version >= bcachefs_metadata_version_snapshot)) {
   947				/*
   948				 * only do scanning if bch2_bkey_compat() has nothing to
   949				 * do
   950				 */
   951	
   952				if (!bkey_packed_valid(c, b, i, (void *) ((u64 *) k + next_good_key))) {
   953					for (next_good_key = 1;
   954					     next_good_key < (u64 *) vstruct_last(i) - (u64 *) k;
   955					     next_good_key++)
   956						if (bkey_packed_valid(c, b, i, (void *) ((u64 *) k + next_good_key)))
   957							goto got_good_key;
   958				}
   959	
   960				/*
   961				 * didn't find a good key, have to truncate the rest of
   962				 * the bset
   963				 */
   964				next_good_key = (u64 *) vstruct_last(i) - (u64 *) k;
   965			}
   966	got_good_key:
   967			le16_add_cpu(&i->u64s, -next_good_key);
   968			memmove_u64s_down(k, bkey_p_next(k), (u64 *) vstruct_end(i) - (u64 *) k);
   969		}
   970	fsck_err:
   971		printbuf_exit(&buf);
   972		return ret;
   973	}
   974	

-- 
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:[~2024-04-13  7:04 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-04-13  7:03 [bcachefs:bcachefs-testing 79/139] fs/bcachefs/btree_io.c:893:6: warning: format specifies type 'unsigned long' but the argument has type 'unsigned int' 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