diff mbox series

nfs: direct: drop useless initializer in nfs_direct_write_completion()

Message ID 416219f5-7983-484b-b5a7-5fb7da9561f7@omp.ru (mailing list archive)
State Handled Elsewhere
Headers show
Series nfs: direct: drop useless initializer in nfs_direct_write_completion() | expand

Commit Message

Sergey Shtylyov April 8, 2025, 8:53 p.m. UTC
In nfs_direct_write_completion(), the local variable req isn't used outside
the *while* loop and is assigned to right at the start of that loop's body,
so its initializer appears useless -- drop it; then move the declaration to
the loop body (which happens to have a pointless empty line anyway)...

Found by Linux Verification Center (linuxtesting.org) with the Svace static
analysis tool.

Signed-off-by: Sergey Shtylyov <s.shtylyov@omp.ru>

---
This patch is against the linux-next branch of Trond Myklebust's linux-nfs.git
repo.

 fs/nfs/direct.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Sergey Shtylyov April 9, 2025, 8:40 p.m. UTC | #1
Hello!

   Oops, used an old Trond's email. :-/ Do I need to repost?

MBR, Sergey
Benjamin Coddington April 11, 2025, 11:04 a.m. UTC | #2
On 8 Apr 2025, at 16:53, Sergey Shtylyov wrote:

> In nfs_direct_write_completion(), the local variable req isn't used outside
> the *while* loop and is assigned to right at the start of that loop's body,
> so its initializer appears useless -- drop it; then move the declaration to
> the loop body (which happens to have a pointless empty line anyway)...
>
> Found by Linux Verification Center (linuxtesting.org) with the Svace static
> analysis tool.
>
> Signed-off-by: Sergey Shtylyov <s.shtylyov@omp.ru>

Reviewed-by: Benjamin Coddington <bcodding@redhat.com>

Ben
diff mbox series

Patch

Index: linux-nfs/fs/nfs/direct.c
===================================================================
--- linux-nfs.orig/fs/nfs/direct.c
+++ linux-nfs/fs/nfs/direct.c
@@ -757,7 +757,6 @@  static void nfs_direct_write_completion(
 {
 	struct nfs_direct_req *dreq = hdr->dreq;
 	struct nfs_commit_info cinfo;
-	struct nfs_page *req = nfs_list_entry(hdr->pages.next);
 	struct inode *inode = dreq->inode;
 	int flags = NFS_ODIRECT_DONE;
 
@@ -786,6 +785,7 @@  static void nfs_direct_write_completion(
 	spin_unlock(&inode->i_lock);
 
 	while (!list_empty(&hdr->pages)) {
+		struct nfs_page *req;
 
 		req = nfs_list_entry(hdr->pages.next);
 		nfs_list_remove_request(req);