From: Dan Carpenter <dan.carpenter@oracle.com>
To: hch@lst.de
Cc: linux-fsdevel@vger.kernel.org
Subject: [bug report] fsdax: decouple zeroing from the iomap buffered I/O code
Date: Wed, 8 Dec 2021 10:11:58 +0300 [thread overview]
Message-ID: <20211208071158.GA21674@kili> (raw)
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
reply other threads:[~2021-12-08 7:12 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20211208071158.GA21674@kili \
--to=dan.carpenter@oracle.com \
--cc=hch@lst.de \
--cc=linux-fsdevel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).