[<prev] [next>] [day] [month] [year] [list]
Message-ID: <202206302311.Gx0KZCgq-lkp@intel.com>
Date: Thu, 30 Jun 2022 23:21:12 +0800
From: kernel test robot <lkp@...el.com>
To: David Howells <dhowells@...hat.com>
Cc: llvm@...ts.linux.dev, kbuild-all@...ts.01.org,
GNU/Weeb Mailing List <gwml@...r.gnuweeb.org>,
linux-kernel@...r.kernel.org
Subject: [ammarfaizi2-block:dhowells/linux-fs/netfs-linked-list 55/55]
fs/netfs/truncate.c:202:18: warning: variable 'to' is uninitialized when
used here
tree: https://github.com/ammarfaizi2/linux-block dhowells/linux-fs/netfs-linked-list
head: e0aed6defb4fe6c570e77e8fd8d899651b40366e
commit: e0aed6defb4fe6c570e77e8fd8d899651b40366e [55/55] netfs: Implement truncation
config: x86_64-randconfig-a012 (https://download.01.org/0day-ci/archive/20220630/202206302311.Gx0KZCgq-lkp@intel.com/config)
compiler: clang version 15.0.0 (https://github.com/llvm/llvm-project a774ba7f60d1fef403b5507b1b1a7475d3684d71)
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/ammarfaizi2/linux-block/commit/e0aed6defb4fe6c570e77e8fd8d899651b40366e
git remote add ammarfaizi2-block https://github.com/ammarfaizi2/linux-block
git fetch --no-tags ammarfaizi2-block dhowells/linux-fs/netfs-linked-list
git checkout e0aed6defb4fe6c570e77e8fd8d899651b40366e
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=x86_64 SHELL=/bin/bash fs/netfs/
If you fix the issue, kindly add following tag where applicable
Reported-by: kernel test robot <lkp@...el.com>
All warnings (new ones prefixed by >>):
>> fs/netfs/truncate.c:202:18: warning: variable 'to' is uninitialized when used here [-Wuninitialized]
} while (from < to);
^~
fs/netfs/truncate.c:149:18: note: initialize the variable 'to' to silence this warning
pgoff_t from, to, fto;
^
= 0
>> fs/netfs/truncate.c:170:6: warning: variable 'from' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
if (ret < 0)
^~~~~~~
fs/netfs/truncate.c:176:45: note: uninitialized use occurs here
folio = read_mapping_folio(treq->mapping, from, NULL);
^~~~
fs/netfs/truncate.c:170:2: note: remove the 'if' if its condition is always true
if (ret < 0)
^~~~~~~~~~~~
fs/netfs/truncate.c:149:14: note: initialize the variable 'from' to silence this warning
pgoff_t from, to, fto;
^
= 0
2 warnings generated.
vim +/to +202 fs/netfs/truncate.c
133
134 /*
135 * Set up a pair of buffers with which we can perform an RMW cycle to
136 * reconstitute the block containing the EOF marker. One buffer will hold the
137 * proposed modification in unencrypted form, the other will hold the
138 * encrypted/compressed data.
139 *
140 * We don't want to make our proposed changes to the pagecache yet as we would
141 * have to back them out if an error occurs.
142 */
143 static int netfs_prepare_trunc_buffers(struct netfs_io_request *treq)
144 {
145 struct netfs_inode *ctx = netfs_inode(treq->inode);
146 struct iov_iter iter;
147 struct folio *folio;
148 unsigned long long base;
149 pgoff_t from, to, fto;
150 size_t offset, seg;
151 size_t bsize = max_t(size_t, 1UL << ctx->min_bshift, PAGE_SIZE);
152 int ret;
153
154 /* We want to hold the entire replacement block, but we round that out
155 * to a multiple of pages.
156 */
157 base = round_down(treq->trunc_i_size, bsize);
158 treq->start = base;
159 treq->len = bsize;
160 treq->first = base / PAGE_SIZE;
161 treq->last = (base + bsize + 1) / PAGE_SIZE;
162
163 ret = netfs_add_folios_to_buffer(&treq->buffer, treq->first, treq->last,
164 GFP_KERNEL);
165 if (ret < 0)
166 return ret;
167
168 ret = netfs_add_folios_to_buffer(&treq->bounce, treq->first, treq->last,
169 GFP_KERNEL);
> 170 if (ret < 0)
171 return ret;
172
173 /* We need to fill the buffer. */
174 iov_iter_xarray(&iter, READ, &treq->buffer, base, base + bsize);
175 do {
176 folio = read_mapping_folio(treq->mapping, from, NULL);
177 if (IS_ERR(folio))
178 return PTR_ERR(folio);
179 if (folio->index > from ||
180 folio->index + folio_nr_pages(folio) <= folio->index) {
181 folio_put(folio);
182 kleave("-EIO [unexpected folio %lx != %lx]", folio->index, from);
183 return -EIO;
184 }
185
186 offset = (from - folio->index);
187 fto = folio->index + folio_nr_pages(folio) - 1;
188 seg = min(to, fto);
189 seg = (seg - from) + 1;
190 kdebug("buf=%lx-%lx fol=%lx-%lx s=%lx@%lx",
191 from, to, folio->index, fto, seg, offset);
192 if (copy_folio_to_iter(folio, offset * PAGE_SIZE, seg * PAGE_SIZE, &iter)) {
193 folio_put(folio);
194 kleave(" = -EIO [copy failure]");
195 return -EIO;
196 }
197
198 /* We keep the refs to discard later - we don't want read
199 * interfering with what we're up to.
200 */
201 from = fto;
> 202 } while (from < to);
203
204 /* Lock the folios and clear the uptodate flag. Read must wait. */
205
206 /* Clear the region after the new EOF */
207 iov_iter_xarray(&iter, READ, &treq->buffer, base, base + bsize);
208 iov_iter_advance(&iter, treq->trunc_i_size - treq->start);
209 iov_iter_zero(iov_iter_count(&iter), &iter);
210 return 0;
211 }
212
--
0-DAY CI Kernel Test Service
https://01.org/lkp
Powered by blists - more mailing lists