:::::: 
:::::: Manual check reason: "low confidence static check warning: 
fs/btrfs/send.c:6858:13: warning: Either the condition '*level==0' is redundant 
or the array 'path->nodes[8]' is accessed at index -1, which is out of bounds. 
[negativeIndex]"
:::::: 

BCC: [email protected]
CC: [email protected]
CC: [email protected]
TO: Filipe Manana <[email protected]>
CC: David Sterba <[email protected]>

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 
master
head:   568035b01cfb107af8d2e4bd2fb9aea22cf5b868
commit: d96b34248c2f4ea8cd09286090f2f6f77102eaab btrfs: make send work with 
concurrent block group relocation
date:   7 months ago
:::::: branch date: 8 hours ago
:::::: commit date: 7 months ago
compiler: powerpc-linux-gcc (GCC) 12.1.0
reproduce (cppcheck warning):
        # apt-get install cppcheck
        git checkout d96b34248c2f4ea8cd09286090f2f6f77102eaab
        cppcheck --quiet --enable=style,performance,portability --template=gcc 
FILE

If you fix the issue, kindly add following tag where applicable
Reported-by: kernel test robot <[email protected]>


cppcheck possible warnings: (new ones prefixed by >>, may not real problems)

>> fs/btrfs/send.c:6858:13: warning: Either the condition '*level==0' is 
>> redundant or the array 'path->nodes[8]' is accessed at index -1, which is 
>> out of bounds. [negativeIndex]
    path->nodes[*level - 1] = eb;
               ^
   fs/btrfs/send.c:6862:13: note: Assuming that condition '*level==0' is not 
redundant
    if (*level == 0)
               ^
   fs/btrfs/send.c:6858:13: note: Negative array index
    path->nodes[*level - 1] = eb;
               ^
>> fs/btrfs/send.c:6859:13: warning: Either the condition '*level==0' is 
>> redundant or the array 'path->slots[8]' is accessed at index -1, which is 
>> out of bounds. [negativeIndex]
    path->slots[*level - 1] = 0;
               ^
   fs/btrfs/send.c:6862:13: note: Assuming that condition '*level==0' is not 
redundant
    if (*level == 0)
               ^
   fs/btrfs/send.c:6859:13: note: Negative array index
    path->slots[*level - 1] = 0;
               ^
   fs/btrfs/send.c:2099:12: warning: Uninitialized variable: cur->ino 
[uninitvar]
     if (cur->ino == ino && cur->gen == gen)
              ^
   fs/btrfs/send.c:2095:6: note: Assuming condition is false
    if (!nce_head)
        ^
   fs/btrfs/send.c:2099:12: note: Uninitialized variable: cur->ino
     if (cur->ino == ino && cur->gen == gen)
              ^
   fs/btrfs/send.c:3135:17: warning: Uninitialized variables: cur.list, 
cur.name, cur.full_path, cur.dir, cur.dir_gen, cur.name_len [uninitvar]
     ret = dup_ref(cur, &pm->update_refs);
                   ^
   fs/btrfs/send.c:3112:6: note: Assuming condition is false
    if (!pm)
        ^
   fs/btrfs/send.c:3112:6: note: Assuming condition is false
    if (!pm)
        ^
   fs/btrfs/send.c:3112:6: note: Assuming condition is false
    if (!pm)
        ^
   fs/btrfs/send.c:3112:6: note: Assuming condition is false
    if (!pm)
        ^
   fs/btrfs/send.c:3112:6: note: Assuming condition is false
    if (!pm)
        ^
   fs/btrfs/send.c:3112:6: note: Assuming condition is false
    if (!pm)
        ^
   fs/btrfs/send.c:3135:17: note: Uninitialized variables: cur.list, cur.name, 
cur.full_path, cur.dir, cur.dir_gen, cur.name_len
     ret = dup_ref(cur, &pm->update_refs);
                   ^

vim +6858 fs/btrfs/send.c

d96b34248c2f4ea Filipe Manana 2021-11-22  6826  
2ce73c633573f14 Filipe Manana 2021-03-01  6827  static int 
tree_move_down(struct btrfs_path *path, int *level, u64 reada_min_gen)
18d0f5c6e16ce76 David Sterba  2019-08-21  6828  {
18d0f5c6e16ce76 David Sterba  2019-08-21  6829          struct extent_buffer 
*eb;
2ce73c633573f14 Filipe Manana 2021-03-01  6830          struct extent_buffer 
*parent = path->nodes[*level];
2ce73c633573f14 Filipe Manana 2021-03-01  6831          int slot = 
path->slots[*level];
2ce73c633573f14 Filipe Manana 2021-03-01  6832          const int nritems = 
btrfs_header_nritems(parent);
2ce73c633573f14 Filipe Manana 2021-03-01  6833          u64 reada_max;
2ce73c633573f14 Filipe Manana 2021-03-01  6834          u64 reada_done = 0;
18d0f5c6e16ce76 David Sterba  2019-08-21  6835  
d96b34248c2f4ea Filipe Manana 2021-11-22  6836          
lockdep_assert_held_read(&parent->fs_info->commit_root_sem);
d96b34248c2f4ea Filipe Manana 2021-11-22  6837  
18d0f5c6e16ce76 David Sterba  2019-08-21  6838          BUG_ON(*level == 0);
2ce73c633573f14 Filipe Manana 2021-03-01  6839          eb = 
btrfs_read_node_slot(parent, slot);
18d0f5c6e16ce76 David Sterba  2019-08-21  6840          if (IS_ERR(eb))
18d0f5c6e16ce76 David Sterba  2019-08-21  6841                  return 
PTR_ERR(eb);
18d0f5c6e16ce76 David Sterba  2019-08-21  6842  
2ce73c633573f14 Filipe Manana 2021-03-01  6843          /*
2ce73c633573f14 Filipe Manana 2021-03-01  6844           * Trigger readahead 
for the next leaves we will process, so that it is
2ce73c633573f14 Filipe Manana 2021-03-01  6845           * very likely that 
when we need them they are already in memory and we
2ce73c633573f14 Filipe Manana 2021-03-01  6846           * will not block on 
disk IO. For nodes we only do readahead for one,
2ce73c633573f14 Filipe Manana 2021-03-01  6847           * since the time 
window between processing nodes is typically larger.
2ce73c633573f14 Filipe Manana 2021-03-01  6848           */
2ce73c633573f14 Filipe Manana 2021-03-01  6849          reada_max = (*level == 
1 ? SZ_128K : eb->fs_info->nodesize);
2ce73c633573f14 Filipe Manana 2021-03-01  6850  
2ce73c633573f14 Filipe Manana 2021-03-01  6851          for (slot++; slot < 
nritems && reada_done < reada_max; slot++) {
2ce73c633573f14 Filipe Manana 2021-03-01  6852                  if 
(btrfs_node_ptr_generation(parent, slot) > reada_min_gen) {
2ce73c633573f14 Filipe Manana 2021-03-01  6853                          
btrfs_readahead_node_child(parent, slot);
2ce73c633573f14 Filipe Manana 2021-03-01  6854                          
reada_done += eb->fs_info->nodesize;
2ce73c633573f14 Filipe Manana 2021-03-01  6855                  }
2ce73c633573f14 Filipe Manana 2021-03-01  6856          }
2ce73c633573f14 Filipe Manana 2021-03-01  6857  
18d0f5c6e16ce76 David Sterba  2019-08-21 @6858          path->nodes[*level - 1] 
= eb;
18d0f5c6e16ce76 David Sterba  2019-08-21 @6859          path->slots[*level - 1] 
= 0;
18d0f5c6e16ce76 David Sterba  2019-08-21  6860          (*level)--;
d96b34248c2f4ea Filipe Manana 2021-11-22  6861  
d96b34248c2f4ea Filipe Manana 2021-11-22  6862          if (*level == 0)
d96b34248c2f4ea Filipe Manana 2021-11-22  6863                  return 
replace_node_with_clone(path, 0);
d96b34248c2f4ea Filipe Manana 2021-11-22  6864  
18d0f5c6e16ce76 David Sterba  2019-08-21  6865          return 0;
18d0f5c6e16ce76 David Sterba  2019-08-21  6866  }
18d0f5c6e16ce76 David Sterba  2019-08-21  6867  

:::::: The code at line 6858 was first introduced by commit
:::::: 18d0f5c6e16ce762f92ab7879c30ff2e37cd9cef btrfs: move functions for tree 
compare to send.c

:::::: TO: David Sterba <[email protected]>
:::::: CC: David Sterba <[email protected]>

-- 
0-DAY CI Kernel Test Service
https://01.org/lkp
_______________________________________________
kbuild mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to