lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aTpqizefLFrDlxbS@google.com>
Date: Thu, 11 Dec 2025 14:54:03 +0800
From: Kuan-Wei Chiu <visitorckw@...il.com>
To: Pycode <pycode42@...il.com>
Cc: Jeff Layton <jlayton@...nel.org>, Trond Myklebust <trondmy@...nel.org>,
	Anna Schumaker <anna@...nel.org>, linux-nfs@...r.kernel.org,
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH] Removed unused variable

On Thu, Dec 11, 2025 at 06:57:54AM +0100, Pycode wrote:
> On Thu, Dec 11, 2025 at 08:10:25AM +0900, Jeff Layton wrote:
> > A more descriptive title is preferred: "Remove unused variable from
> > nfs4_ff_alloc_deviceid_node()"
> > 
> 
> Thanks for the advices!
> 
> > On Wed, 2025-12-10 at 21:59 +0100, Pycode wrote:
> > > Signed-off-by: Pycode <pycode42@...il.com>
> > > 
> > > Removed the unused variable ret in
> > > fs/nfs/flexfilelayout/flexfilelayoutdev.c
> > > 
> > > (Disclaimer this is my first patch, be sorry if I have done anything
> > > wrong!)
> > > ---
> > >  fs/nfs/flexfilelayout/flexfilelayoutdev.c | 4 +---
> > >  1 file changed, 1 insertion(+), 3 deletions(-)
> > > 
> > > diff --git a/fs/nfs/flexfilelayout/flexfilelayoutdev.c b/fs/nfs/flexfilelayout/flexfilelayoutdev.c
> > > index c55ea8fa3bfa..9cd04e85d52f 100644
> > > --- a/fs/nfs/flexfilelayout/flexfilelayoutdev.c
> > > +++ b/fs/nfs/flexfilelayout/flexfilelayoutdev.c
> > > @@ -53,7 +53,7 @@ nfs4_ff_alloc_deviceid_node(struct nfs_server *server, struct pnfs_device *pdev,
> > >  	u32 mp_count;
> > >  	u32 version_count;
> > >  	__be32 *p;
> > > -	int i, ret = -ENOMEM;
> > > +	int i = -ENOMEM;
> > >  
> > 
> > No need to initialize this.
> > 
> > >  	/* set up xdr stream */
> > >  	scratch = folio_alloc(gfp_flags, 0);
> > > @@ -88,7 +88,6 @@ nfs4_ff_alloc_deviceid_node(struct nfs_server *server, struct pnfs_device *pdev,
> > >  	if (list_empty(&dsaddrs)) {
> > >  		dprintk("%s: no suitable DS addresses found\n",
> > >  			__func__);
> > > -		ret = -ENOMEDIUM;
> > >  		goto out_err_drain_dsaddrs;
> > >  	}
> > >  
> > > @@ -134,7 +133,6 @@ nfs4_ff_alloc_deviceid_node(struct nfs_server *server, struct pnfs_device *pdev,
> > >  			dprintk("%s: [%d] unsupported ds version %d-%d\n", __func__,
> > >  				i, ds_versions[i].version,
> > >  				ds_versions[i].minor_version);
> > > -			ret = -EPROTONOSUPPORT;
> > >  			goto out_err_drain_dsaddrs;
> > >  		}
> > >  
> > 
> > What about the dprintk() at the bottom of this function? Does this
> > actually build?
> 
> There is no dprintk() at the bottom that used the variable.

At the bottom of this function, there is a dprintk call that refers to ret:

	dprintk("%s ERROR: returning %d\n", __func__, ret);
	return NULL;

This causes the build to fail:

In file included from ./include/asm-generic/bug.h:31,
                 from ./arch/x86/include/asm/bug.h:193,
                 from ./arch/x86/include/asm/alternative.h:9,
                 from ./arch/x86/include/asm/barrier.h:5,
                 from ./include/asm-generic/bitops/generic-non-atomic.h:7,
                 from ./include/linux/bitops.h:28,
                 from ./include/linux/kernel.h:23,
                 from ./include/linux/uio.h:8,
                 from ./include/linux/socket.h:8,
                 from ./include/uapi/linux/in.h:25,
                 from ./include/linux/in.h:19,
                 from ./include/linux/nfs_fs.h:22,
                 from fs/nfs/flexfilelayout/flexfilelayoutdev.c:10:
fs/nfs/flexfilelayout/flexfilelayoutdev.c: In function ‘nfs4_ff_alloc_deviceid_node’:
fs/nfs/flexfilelayout/flexfilelayoutdev.c:182:55: error: ‘ret’ undeclared (first use in this function); did you mean ‘net’?
  182 |         dprintk("%s ERROR: returning %d\n", __func__, ret);
      |                                                       ^~~
./include/linux/printk.h:484:33: note: in definition of macro ‘printk_index_wrap’
  484 |                 _p_func(_fmt, ##__VA_ARGS__);                           \
      |                                 ^~~~~~~~~~~
./include/linux/sunrpc/debug.h:36:41: note: in expansion of macro ‘printk’
   36 | #  define __sunrpc_printk(fmt, ...)     printk(KERN_DEFAULT fmt, ##__VA_ARGS__)
      |                                         ^~~~~~
./include/linux/sunrpc/debug.h:42:17: note: in expansion of macro ‘__sunrpc_printk’
   42 |                 __sunrpc_printk(fmt, ##__VA_ARGS__);                    \
      |                 ^~~~~~~~~~~~~~~
./include/linux/sunrpc/debug.h:25:9: note: in expansion of macro ‘dfprintk’
   25 |         dfprintk(FACILITY, fmt, ##__VA_ARGS__)
      |         ^~~~~~~~
fs/nfs/flexfilelayout/flexfilelayoutdev.c:182:9: note: in expansion of macro ‘dprintk’
  182 |         dprintk("%s ERROR: returning %d\n", __func__, ret);
      |         ^~~~~~~
fs/nfs/flexfilelayout/flexfilelayoutdev.c:182:55: note: each undeclared identifier is reported only once for each function it appears in
  182 |         dprintk("%s ERROR: returning %d\n", __func__, ret);
      |                                                       ^~~
./include/linux/printk.h:484:33: note: in definition of macro ‘printk_index_wrap’
  484 |                 _p_func(_fmt, ##__VA_ARGS__);                           \
      |                                 ^~~~~~~~~~~
./include/linux/sunrpc/debug.h:36:41: note: in expansion of macro ‘printk’
   36 | #  define __sunrpc_printk(fmt, ...)     printk(KERN_DEFAULT fmt, ##__VA_ARGS__)
      |                                         ^~~~~~
./include/linux/sunrpc/debug.h:42:17: note: in expansion of macro ‘__sunrpc_printk’
   42 |                 __sunrpc_printk(fmt, ##__VA_ARGS__);                    \
      |                 ^~~~~~~~~~~~~~~
./include/linux/sunrpc/debug.h:25:9: note: in expansion of macro ‘dfprintk’
   25 |         dfprintk(FACILITY, fmt, ##__VA_ARGS__)
      |         ^~~~~~~~
fs/nfs/flexfilelayout/flexfilelayoutdev.c:182:9: note: in expansion of macro ‘dprintk’
  182 |         dprintk("%s ERROR: returning %d\n", __func__, ret);
      |         ^~~~~~~
make[5]: *** [scripts/Makefile.build:287: fs/nfs/flexfilelayout/flexfilelayoutdev.o] Error 1
make[4]: *** [scripts/Makefile.build:556: fs/nfs/flexfilelayout] Error 2
make[3]: *** [scripts/Makefile.build:556: fs/nfs] Error 2
make[2]: *** [scripts/Makefile.build:556: fs] Error 2

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ