[<prev] [next>] [day] [month] [year] [list]
Message-ID: <201707180801.sKHTNftJ%fengguang.wu@intel.com>
Date: Tue, 18 Jul 2017 08:55:09 +0800
From: kbuild test robot <fengguang.wu@...el.com>
To: Daniel Micay <danielmicay@...il.com>
Cc: kbuild-all@...org, linux-kernel@...r.kernel.org,
Kees Cook <keescook@...omium.org>,
Arnd Bergmann <arnd@...db.de>,
Andrew Morton <akpm@...ux-foundation.org>,
Linux Memory Management List <linux-mm@...ck.org>
Subject: fs/btrfs/ctree.c:5149: warning: 'found_key' is used uninitialized in
this function
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: cb8c65ccff7f77d0285f1b126c72d37b2572c865
commit: 6974f0c4555e285ab217cee58b6e874f776ff409 include/linux/string.h: add the option of fortified string.h functions
date: 5 days ago
config: x86_64-randconfig-v0-07180702 (attached as .config)
compiler: gcc-4.4 (Debian 4.4.7-8) 4.4.7
reproduce:
git checkout 6974f0c4555e285ab217cee58b6e874f776ff409
# save the attached .config to linux build tree
make ARCH=x86_64
All warnings (new ones prefixed by >>):
fs/btrfs/ctree.c: In function 'btrfs_search_forward':
>> fs/btrfs/ctree.c:5149: warning: 'found_key' is used uninitialized in this function
vim +/found_key +5149 fs/btrfs/ctree.c
7bb86316 Chris Mason 2007-12-11 5120
3f157a2f Chris Mason 2008-06-25 5121 /*
3f157a2f Chris Mason 2008-06-25 5122 * A helper function to walk down the tree starting at min_key, and looking
de78b51a Eric Sandeen 2013-01-31 5123 * for nodes or leaves that are have a minimum transaction id.
de78b51a Eric Sandeen 2013-01-31 5124 * This is used by the btree defrag code, and tree logging
3f157a2f Chris Mason 2008-06-25 5125 *
3f157a2f Chris Mason 2008-06-25 5126 * This does not cow, but it does stuff the starting key it finds back
3f157a2f Chris Mason 2008-06-25 5127 * into min_key, so you can call btrfs_search_slot with cow=1 on the
3f157a2f Chris Mason 2008-06-25 5128 * key and get a writable path.
3f157a2f Chris Mason 2008-06-25 5129 *
3f157a2f Chris Mason 2008-06-25 5130 * This does lock as it descends, and path->keep_locks should be set
3f157a2f Chris Mason 2008-06-25 5131 * to 1 by the caller.
3f157a2f Chris Mason 2008-06-25 5132 *
3f157a2f Chris Mason 2008-06-25 5133 * This honors path->lowest_level to prevent descent past a given level
3f157a2f Chris Mason 2008-06-25 5134 * of the tree.
3f157a2f Chris Mason 2008-06-25 5135 *
d352ac68 Chris Mason 2008-09-29 5136 * min_trans indicates the oldest transaction that you are interested
d352ac68 Chris Mason 2008-09-29 5137 * in walking through. Any nodes or leaves older than min_trans are
d352ac68 Chris Mason 2008-09-29 5138 * skipped over (without reading them).
d352ac68 Chris Mason 2008-09-29 5139 *
3f157a2f Chris Mason 2008-06-25 5140 * returns zero if something useful was found, < 0 on error and 1 if there
3f157a2f Chris Mason 2008-06-25 5141 * was nothing in the tree that matched the search criteria.
3f157a2f Chris Mason 2008-06-25 5142 */
3f157a2f Chris Mason 2008-06-25 5143 int btrfs_search_forward(struct btrfs_root *root, struct btrfs_key *min_key,
de78b51a Eric Sandeen 2013-01-31 5144 struct btrfs_path *path,
3f157a2f Chris Mason 2008-06-25 5145 u64 min_trans)
3f157a2f Chris Mason 2008-06-25 5146 {
2ff7e61e Jeff Mahoney 2016-06-22 5147 struct btrfs_fs_info *fs_info = root->fs_info;
3f157a2f Chris Mason 2008-06-25 5148 struct extent_buffer *cur;
3f157a2f Chris Mason 2008-06-25 @5149 struct btrfs_key found_key;
3f157a2f Chris Mason 2008-06-25 5150 int slot;
9652480b Yan 2008-07-24 5151 int sret;
3f157a2f Chris Mason 2008-06-25 5152 u32 nritems;
3f157a2f Chris Mason 2008-06-25 5153 int level;
3f157a2f Chris Mason 2008-06-25 5154 int ret = 1;
f98de9b9 Filipe Manana 2014-08-04 5155 int keep_locks = path->keep_locks;
3f157a2f Chris Mason 2008-06-25 5156
f98de9b9 Filipe Manana 2014-08-04 5157 path->keep_locks = 1;
3f157a2f Chris Mason 2008-06-25 5158 again:
bd681513 Chris Mason 2011-07-16 5159 cur = btrfs_read_lock_root_node(root);
3f157a2f Chris Mason 2008-06-25 5160 level = btrfs_header_level(cur);
e02119d5 Chris Mason 2008-09-05 5161 WARN_ON(path->nodes[level]);
3f157a2f Chris Mason 2008-06-25 5162 path->nodes[level] = cur;
bd681513 Chris Mason 2011-07-16 5163 path->locks[level] = BTRFS_READ_LOCK;
3f157a2f Chris Mason 2008-06-25 5164
3f157a2f Chris Mason 2008-06-25 5165 if (btrfs_header_generation(cur) < min_trans) {
3f157a2f Chris Mason 2008-06-25 5166 ret = 1;
3f157a2f Chris Mason 2008-06-25 5167 goto out;
3f157a2f Chris Mason 2008-06-25 5168 }
3f157a2f Chris Mason 2008-06-25 5169 while (1) {
3f157a2f Chris Mason 2008-06-25 5170 nritems = btrfs_header_nritems(cur);
3f157a2f Chris Mason 2008-06-25 5171 level = btrfs_header_level(cur);
9652480b Yan 2008-07-24 5172 sret = bin_search(cur, min_key, level, &slot);
3f157a2f Chris Mason 2008-06-25 5173
323ac95b Chris Mason 2008-10-01 5174 /* at the lowest level, we're done, setup the path and exit */
323ac95b Chris Mason 2008-10-01 5175 if (level == path->lowest_level) {
e02119d5 Chris Mason 2008-09-05 5176 if (slot >= nritems)
e02119d5 Chris Mason 2008-09-05 5177 goto find_next_key;
3f157a2f Chris Mason 2008-06-25 5178 ret = 0;
3f157a2f Chris Mason 2008-06-25 5179 path->slots[level] = slot;
3f157a2f Chris Mason 2008-06-25 5180 btrfs_item_key_to_cpu(cur, &found_key, slot);
3f157a2f Chris Mason 2008-06-25 5181 goto out;
3f157a2f Chris Mason 2008-06-25 5182 }
9652480b Yan 2008-07-24 5183 if (sret && slot > 0)
9652480b Yan 2008-07-24 5184 slot--;
3f157a2f Chris Mason 2008-06-25 5185 /*
de78b51a Eric Sandeen 2013-01-31 5186 * check this node pointer against the min_trans parameters.
de78b51a Eric Sandeen 2013-01-31 5187 * If it is too old, old, skip to the next one.
3f157a2f Chris Mason 2008-06-25 5188 */
3f157a2f Chris Mason 2008-06-25 5189 while (slot < nritems) {
3f157a2f Chris Mason 2008-06-25 5190 u64 gen;
e02119d5 Chris Mason 2008-09-05 5191
3f157a2f Chris Mason 2008-06-25 5192 gen = btrfs_node_ptr_generation(cur, slot);
3f157a2f Chris Mason 2008-06-25 5193 if (gen < min_trans) {
3f157a2f Chris Mason 2008-06-25 5194 slot++;
3f157a2f Chris Mason 2008-06-25 5195 continue;
3f157a2f Chris Mason 2008-06-25 5196 }
3f157a2f Chris Mason 2008-06-25 5197 break;
3f157a2f Chris Mason 2008-06-25 5198 }
e02119d5 Chris Mason 2008-09-05 5199 find_next_key:
3f157a2f Chris Mason 2008-06-25 5200 /*
3f157a2f Chris Mason 2008-06-25 5201 * we didn't find a candidate key in this node, walk forward
3f157a2f Chris Mason 2008-06-25 5202 * and find another one
3f157a2f Chris Mason 2008-06-25 5203 */
3f157a2f Chris Mason 2008-06-25 5204 if (slot >= nritems) {
e02119d5 Chris Mason 2008-09-05 5205 path->slots[level] = slot;
b4ce94de Chris Mason 2009-02-04 5206 btrfs_set_path_blocking(path);
e02119d5 Chris Mason 2008-09-05 5207 sret = btrfs_find_next_key(root, path, min_key, level,
de78b51a Eric Sandeen 2013-01-31 5208 min_trans);
e02119d5 Chris Mason 2008-09-05 5209 if (sret == 0) {
b3b4aa74 David Sterba 2011-04-21 5210 btrfs_release_path(path);
3f157a2f Chris Mason 2008-06-25 5211 goto again;
3f157a2f Chris Mason 2008-06-25 5212 } else {
3f157a2f Chris Mason 2008-06-25 5213 goto out;
3f157a2f Chris Mason 2008-06-25 5214 }
3f157a2f Chris Mason 2008-06-25 5215 }
3f157a2f Chris Mason 2008-06-25 5216 /* save our key for returning back */
3f157a2f Chris Mason 2008-06-25 5217 btrfs_node_key_to_cpu(cur, &found_key, slot);
3f157a2f Chris Mason 2008-06-25 5218 path->slots[level] = slot;
3f157a2f Chris Mason 2008-06-25 5219 if (level == path->lowest_level) {
3f157a2f Chris Mason 2008-06-25 5220 ret = 0;
3f157a2f Chris Mason 2008-06-25 5221 goto out;
3f157a2f Chris Mason 2008-06-25 5222 }
b4ce94de Chris Mason 2009-02-04 5223 btrfs_set_path_blocking(path);
2ff7e61e Jeff Mahoney 2016-06-22 5224 cur = read_node_slot(fs_info, cur, slot);
fb770ae4 Liu Bo 2016-07-05 5225 if (IS_ERR(cur)) {
fb770ae4 Liu Bo 2016-07-05 5226 ret = PTR_ERR(cur);
fb770ae4 Liu Bo 2016-07-05 5227 goto out;
fb770ae4 Liu Bo 2016-07-05 5228 }
3f157a2f Chris Mason 2008-06-25 5229
bd681513 Chris Mason 2011-07-16 5230 btrfs_tree_read_lock(cur);
b4ce94de Chris Mason 2009-02-04 5231
bd681513 Chris Mason 2011-07-16 5232 path->locks[level - 1] = BTRFS_READ_LOCK;
3f157a2f Chris Mason 2008-06-25 5233 path->nodes[level - 1] = cur;
f7c79f30 Chris Mason 2012-03-19 5234 unlock_up(path, level, 1, 0, NULL);
bd681513 Chris Mason 2011-07-16 5235 btrfs_clear_path_blocking(path, NULL, 0);
3f157a2f Chris Mason 2008-06-25 5236 }
3f157a2f Chris Mason 2008-06-25 5237 out:
f98de9b9 Filipe Manana 2014-08-04 5238 path->keep_locks = keep_locks;
f98de9b9 Filipe Manana 2014-08-04 5239 if (ret == 0) {
f98de9b9 Filipe Manana 2014-08-04 5240 btrfs_unlock_up_safe(path, path->lowest_level + 1);
b4ce94de Chris Mason 2009-02-04 5241 btrfs_set_path_blocking(path);
f98de9b9 Filipe Manana 2014-08-04 5242 memcpy(min_key, &found_key, sizeof(found_key));
f98de9b9 Filipe Manana 2014-08-04 5243 }
3f157a2f Chris Mason 2008-06-25 5244 return ret;
3f157a2f Chris Mason 2008-06-25 5245 }
3f157a2f Chris Mason 2008-06-25 5246
:::::: The code at line 5149 was first introduced by commit
:::::: 3f157a2fd2ad731e1ed9964fecdc5f459f04a4a4 Btrfs: Online btree defragmentation fixes
:::::: TO: Chris Mason <chris.mason@...cle.com>
:::::: CC: Chris Mason <chris.mason@...cle.com>
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
Download attachment ".config.gz" of type "application/gzip" (28661 bytes)
Powered by blists - more mailing lists