Skip to contentSkip to conversation

fs/fscache/read_helper.c:258:2: warning: variable 'x_flags' is uninitialized when used here

PATCH Nick Desaulniers 2 participants 2 messages Nov 13, 2019 – Nov 14, 2019 1 message not in the archive

lore
Share & tools
lore
#1 lore raw
In reply to a message not in the archive
Quoted 19 lines · kbuild test robot

CC: kbuild-all(a)lists.01.org
TO: David Howells <[email protected]>

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/dhowells/linux-fs.git fscache-iter
head:   f62d2e3b55357b54ea4a541e85200ecdccfce7b4
commit: b546e3179314dd9f56dd09047dfdaf93a2baada3 [23/33] fscache: Add read helper
config: x86_64-rhel-7.6 (attached as .config)
compiler: clang version 10.0.0 (git://gitmirror/llvm_project 335ac2eb662ce5f1888e2a50310b01fba2d40d68)
reproduce:
        git checkout b546e3179314dd9f56dd09047dfdaf93a2baada3
        # save the attached .config to linux build tree
        make ARCH=x86_64

If you fix the issue, kindly add following tag

All warnings (new ones prefixed by >>):

Quoted 7 lines
Quoted 1 line
Quoted 1 line

fs/fscache/read_helper.c:258:2: warning: variable 'x_flags' is uninitialized when used here [-Wuninitialized]

           x_flags |= fscache_shape_extent(req->io_handle, extent, i_size, false);
           ^~~~~~~
   fs/fscache/read_helper.c:239:23: note: initialize the variable 'x_flags' to silence this warning
           unsigned char x_flags;
                                ^
                                 = '\0'

Hi David, 0day bot flagged this from a Clang build. Warning looks legit, can you please take a look?

Quoted 63 lines

1 warning generated.

vim +/x_flags +258 fs/fscache/read_helper.c

   209
   210  /**
   211   * fscache_read_helper - Helper to manage a read request
   212   * @req: The initialised request structure to use
   213   * @extent: The extent of the pages to access
   214   * @requested_page: Singular page to include
   215   * @pages: Unattached pages to include (readpages)
   216   * @type: FSCACHE_READ_*
   217   * @aop_flags: AOP_FLAG_*
   218   *
   219   * Read a sequence of pages appropriately sized for an fscache allocation
   220   * block.  Pages are added at both ends and to fill in the gaps as appropriate
   221   * to make it the right size.
   222   *
   223   * req->mapping should indicate the mapping to which the pages will be attached.
   224   *
   225   * The operations pointed to by req->ops will be used to issue or reissue a
   226   * read against the server in case the cache is unavailable, incomplete or
   227   * generates an error.  req->iter will be set up to point to the iterator
   228   * representing the buffer to be filled in.
   229   */
   230  int fscache_read_helper(struct fscache_io_request *req,
   231                          struct fscache_extent *extent,
   232                          struct page **requested_page,
   233                          struct list_head *pages,
   234                          enum fscache_read_type type,
   235                          unsigned int aop_flags)
   236  {
   237          struct address_space *mapping = req->mapping;
   238          struct page *page;
   239          unsigned char x_flags;
   240          pgoff_t eof, cursor, start, first_index, trailer = ULONG_MAX;
   241          loff_t i_size;
   242          int ret;
   243
   244          first_index = extent->start;
   245          _enter("{%lx,%lx}", first_index, extent->limit);
   246
   247          ASSERTIFCMP(requested_page && *requested_page,
   248                      (*requested_page)->index, ==, first_index);
   249          ASSERTIF(type == FSCACHE_READ_LOCKED_PAGE ||
   250                   type == FSCACHE_READ_FOR_WRITE,
   251                   pages == NULL);
   252          ASSERTIFCMP(pages && !list_empty(pages),
   253                      first_index, ==, lru_to_page(pages)->index);
   254
   255          i_size = i_size_read(mapping->host);
   256          eof = (i_size + PAGE_SIZE - 1) >> PAGE_SHIFT;
   257
Quoted 1 line

258 x_flags |= fscache_shape_extent(req->io_handle, extent, i_size, false);

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org Intel Corporation

--
You received this message because you are subscribed to the Google Groups "Clang Built Linux" group.
To unsubscribe from this group and stop receiving emails from it, send an email to clang-built-linux+unsubscribe(a)googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/clang-built-linux/201911140105.a5aulJde%25lkp%40intel.com.

Signature · 2 lines
Thanks,
~Nick Desaulniers
#2 lore raw
Quoted 2 lines · Nick Desaulniers

Hi David, 0day bot flagged this from a Clang build. Warning looks legit, can you please take a look?

Yep. I'm not sure why my compiler doesn't report these.

Quoted 2 lines
Quoted 2 lines
Quoted 1 line
Quoted 1 line

fs/fscache/read_helper.c:258:2: warning: variable 'x_flags' is uninitialized when used here [-Wuninitialized]

           x_flags |= fscache_shape_extent(req->io_handle, extent, i_size, false);

This should be "=" not "|=" and I've amended it accordingly, thanks.

David