All of lore.kernel.org
 help / color / mirror / Atom feed
* [bug report] fsdax: decouple zeroing from the iomap buffered I/O code
@ 2021-12-08  7:11 Dan Carpenter
  0 siblings, 0 replies; only message in thread
From: Dan Carpenter @ 2021-12-08  7:11 UTC (permalink / raw)
  To: hch; +Cc: linux-fsdevel

Hello Christoph Hellwig,

The patch c6f40468657d: "fsdax: decouple zeroing from the iomap
buffered I/O code" from Nov 29, 2021, leads to the following Smatch
static checker warning:

	fs/iomap/buffered-io.c:904 iomap_zero_iter()
	warn: unsigned 'bytes' is never less than zero.

fs/iomap/buffered-io.c
    879 static loff_t iomap_zero_iter(struct iomap_iter *iter, bool *did_zero)
    880 {
    881         const struct iomap *srcmap = iomap_iter_srcmap(iter);
    882         loff_t pos = iter->pos;
    883         loff_t length = iomap_length(iter);
    884         loff_t written = 0;
    885 
    886         /* already zeroed?  we're done. */
    887         if (srcmap->type == IOMAP_HOLE || srcmap->type == IOMAP_UNWRITTEN)
    888                 return length;
    889 
    890         do {
    891                 unsigned offset = offset_in_page(pos);
    892                 size_t bytes = min_t(u64, PAGE_SIZE - offset, length);
    893                 struct page *page;
    894                 int status;
    895 
    896                 status = iomap_write_begin(iter, pos, bytes, &page);
    897                 if (status)
    898                         return status;
    899 
    900                 zero_user(page, offset, bytes);
    901                 mark_page_accessed(page);
    902 
    903                 bytes = iomap_write_end(iter, pos, bytes, bytes, page);
--> 904                 if (bytes < 0)

bytes is unsigned and iomap_write_end() doesn't return negatives.

    905                         return bytes;
    906 
    907                 pos += bytes;
    908                 length -= bytes;
    909                 written += bytes;
    910                 if (did_zero)
    911                         *did_zero = true;
    912         } while (length > 0);
    913 
    914         return written;
    915 }

regards,
dan carpenter

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-12-08  7:12 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-08  7:11 [bug report] fsdax: decouple zeroing from the iomap buffered I/O code Dan Carpenter

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.