[PATCH] fs/ntfs: drop unneeded assignment in ntfs_perform_write()

13 views
Skip to first unread message

Yang Li

unread,
Apr 25, 2021, 6:16:01 AM4/25/21
to an...@tuxera.com, nat...@kernel.org, ndesau...@google.com, linux-n...@lists.sourceforge.net, linux-...@vger.kernel.org, clang-bu...@googlegroups.com, Yang Li
It is not required to initialize the local variable idx in
ntfs_perform_write(), the value is never actually read from
it.

make clang-analyzer on x86_64 allyesconfig reports:

fs/ntfs/file.c:1781:15: warning: Although the value stored to 'idx' is
used in the enclosing expression, the value is never actually read from
'idx'

Simplify the code and remove unneeded assignment to make clang-analyzer
happy.

Reported-by: Abaci Robot <ab...@linux.alibaba.com>
Signed-off-by: Yang Li <yang...@linux.alibaba.com>
---
fs/ntfs/file.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/ntfs/file.c b/fs/ntfs/file.c
index e5aab26..e39a26f 100644
--- a/fs/ntfs/file.c
+++ b/fs/ntfs/file.c
@@ -1774,11 +1774,11 @@ static ssize_t ntfs_perform_write(struct file *file, struct iov_iter *i,
last_vcn = -1;
do {
VCN vcn;
- pgoff_t idx, start_idx;
+ pgoff_t start_idx;
unsigned ofs, do_pages, u;
size_t copied;

- start_idx = idx = pos >> PAGE_SHIFT;
+ start_idx = pos >> PAGE_SHIFT;
ofs = pos & ~PAGE_MASK;
bytes = PAGE_SIZE - ofs;
do_pages = 1;
--
1.8.3.1

Nick Desaulniers

unread,
Apr 27, 2021, 2:54:30 PM4/27/21
to Yang Li, Anton Altaparmakov, Nathan Chancellor, linux-n...@lists.sourceforge.net, LKML, clang-built-linux, Nathan Huckleberry
On Sun, Apr 25, 2021 at 3:16 AM Yang Li <yang...@linux.alibaba.com> wrote:
>
> It is not required to initialize the local variable idx in
> ntfs_perform_write(), the value is never actually read from
> it.
>
> make clang-analyzer on x86_64 allyesconfig reports:
>
> fs/ntfs/file.c:1781:15: warning: Although the value stored to 'idx' is
> used in the enclosing expression, the value is never actually read from
> 'idx'
>
> Simplify the code and remove unneeded assignment to make clang-analyzer
> happy.

Thank you for the patch.
Reviewed-by: Nick Desaulniers <ndesau...@google.com>
Is there someplace where I can learn more about "Abaci Robot?" I'm
happy to see it running clang-analyzer. :)

>
> Reported-by: Abaci Robot <ab...@linux.alibaba.com>
> Signed-off-by: Yang Li <yang...@linux.alibaba.com>
> ---
> fs/ntfs/file.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/fs/ntfs/file.c b/fs/ntfs/file.c
> index e5aab26..e39a26f 100644
> --- a/fs/ntfs/file.c
> +++ b/fs/ntfs/file.c
> @@ -1774,11 +1774,11 @@ static ssize_t ntfs_perform_write(struct file *file, struct iov_iter *i,
> last_vcn = -1;
> do {
> VCN vcn;
> - pgoff_t idx, start_idx;
> + pgoff_t start_idx;
> unsigned ofs, do_pages, u;
> size_t copied;
>
> - start_idx = idx = pos >> PAGE_SHIFT;
> + start_idx = pos >> PAGE_SHIFT;
> ofs = pos & ~PAGE_MASK;
> bytes = PAGE_SIZE - ofs;
> do_pages = 1;
> --
> 1.8.3.1
>
> --
> 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-li...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/clang-built-linux/1619345754-32875-1-git-send-email-yang.lee%40linux.alibaba.com.



--
Thanks,
~Nick Desaulniers

Nick Desaulniers

unread,
Apr 29, 2021, 2:03:44 PM4/29/21
to Abaci Robot, clang-built-linux, Nathan Huckleberry
On Thu, Apr 29, 2021 at 3:30 AM Abaci Robot <ab...@linux.alibaba.com> wrote:
>
> 在 2021/4/28 上午2:54, Nick Desaulniers 写道:
> > On Sun, Apr 25, 2021 at 3:16 AM Yang Li <yang...@linux.alibaba.com> wrote:
> >>
> >> It is not required to initialize the local variable idx in
> >> ntfs_perform_write(), the value is never actually read from
> >> it.
> >>
> >> make clang-analyzer on x86_64 allyesconfig reports:
> >>
> >> fs/ntfs/file.c:1781:15: warning: Although the value stored to 'idx' is
> >> used in the enclosing expression, the value is never actually read from
> >> 'idx'
> >>
> >> Simplify the code and remove unneeded assignment to make clang-analyzer
> >> happy.
> >
> > Thank you for the patch.
> > Reviewed-by: Nick Desaulniers <ndesau...@google.com>
> > Is there someplace where I can learn more about "Abaci Robot?" I'm
> > happy to see it running clang-analyzer. :)
> >
>
> Hi,
>
> Thanks for your review, and I am also very happy to see your interests
> on Abaci robot!
>
> Now Abaci robot has a simple report platform, but a user-friendly
> website will need some time to build for tracking patch status and
> community response. If you want the recent report found by
> clang-analyzer, we can send you :)

Thank you, but I can run `make clang-analyzer` myself; my intern wrote
support for that in Kbuild and I reviewed the patches, so I have a
good idea how it works and what it looks like.

But it's news to me that anyone is running it, continuously, and
fixing reports! That's great! Is there a website that describes
_what_ Abaci Robot is, or what it's running besides clang-analyzer?
--
Thanks,
~Nick Desaulniers

Abaci Robot

unread,
May 6, 2021, 8:41:04 AM5/6/21
to Nick Desaulniers, clang-built-linux, Nathan Huckleberry
Hi Nick,

I am so sorry for the late reply because we have a 5-day vacation, so I
did not check my email...

> Thank you, but I can run `make clang-analyzer` myself; my intern wrote
> support for that in Kbuild and I reviewed the patches, so I have a
> good idea how it works and what it looks like.

Thanks for your kind work to support the clang analyzer in Kbuild. It is
a nice checker and easy to use. We use it for just a few weeks, and we
hope for your guidance in our patches.

> But it's news to me that anyone is running it, continuously, and
> fixing reports! That's great! Is there a website that describes,
> _what_ Abaci Robot is

We are building the website but not complete yet. And we have some doc
in Chinese, but no English version now. We will do these work soon.

> or what it's running besides clang-analyzer?

We try to do something like lkp or hulkci, we now try to use checkers
like clang-analyzer, coccicheck, sparse, build warning...

Sorry again for my late reply.
Reply all
Reply to author
Forward
0 new messages