Linux CIFS filesystem development
 help / color / mirror / Atom feed
* [PATCH] smb: client: Reduce the scopes for a few variables in two functions
@ 2025-10-05 17:10 Markus Elfring
  2025-10-06 14:09 ` Henrique Carvalho
  0 siblings, 1 reply; 3+ messages in thread
From: Markus Elfring @ 2025-10-05 17:10 UTC (permalink / raw)
  To: Henrique Carvalho, linux-cifs, samba-technical, Bharath SM,
	Paulo Alcantara, Ronnie Sahlberg, Shyam Prasad N, Steve French,
	Tom Talpey
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 5 Oct 2025 19:01:48 +0200

* cifs_lookup():
  Move the definition for the local variable “cfid” into an else branch
  so that the corresponding setting will only be performed if a NULL inode
  was detected during lookup by this function.

* cifs_d_revalidate():
  Move the definition for the local variables “inode” and “rc” into
  an if branch so that the corresponding setting will only be performed
  after a d_really_is_positive() call.

  Move the definition for the local variable “cfid” into an else branch
  so that the corresponding setting will only be performed if further data
  processing will be needed for an open_cached_dir_by_dentry() call.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 fs/smb/client/dir.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/fs/smb/client/dir.c b/fs/smb/client/dir.c
index fc67a6441c96..7472fddadd4f 100644
--- a/fs/smb/client/dir.c
+++ b/fs/smb/client/dir.c
@@ -678,7 +678,6 @@ cifs_lookup(struct inode *parent_dir_inode, struct dentry *direntry,
 	const char *full_path;
 	void *page;
 	int retry_count = 0;
-	struct cached_fid *cfid = NULL;
 
 	xid = get_xid();
 
@@ -717,6 +716,8 @@ cifs_lookup(struct inode *parent_dir_inode, struct dentry *direntry,
 	if (d_really_is_positive(direntry)) {
 		cifs_dbg(FYI, "non-NULL inode in lookup\n");
 	} else {
+		struct cached_fid *cfid = NULL;
+
 		cifs_dbg(FYI, "NULL inode in lookup\n");
 
 		/*
@@ -785,15 +786,13 @@ static int
 cifs_d_revalidate(struct inode *dir, const struct qstr *name,
 		  struct dentry *direntry, unsigned int flags)
 {
-	struct inode *inode = NULL;
-	struct cached_fid *cfid;
-	int rc;
-
 	if (flags & LOOKUP_RCU)
 		return -ECHILD;
 
 	if (d_really_is_positive(direntry)) {
-		inode = d_inode(direntry);
+		int rc;
+		struct inode *inode = d_inode(direntry);
+
 		if ((flags & LOOKUP_REVAL) && !CIFS_CACHE_READ(CIFS_I(inode)))
 			CIFS_I(inode)->time = 0; /* force reval */
 
@@ -836,6 +835,7 @@ cifs_d_revalidate(struct inode *dir, const struct qstr *name,
 	} else {
 		struct cifs_sb_info *cifs_sb = CIFS_SB(dir->i_sb);
 		struct cifs_tcon *tcon = cifs_sb_master_tcon(cifs_sb);
+		struct cached_fid *cfid;
 
 		if (!open_cached_dir_by_dentry(tcon, direntry->d_parent, &cfid)) {
 			/*
-- 
2.51.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] smb: client: Reduce the scopes for a few variables in two functions
  2025-10-05 17:10 [PATCH] smb: client: Reduce the scopes for a few variables in two functions Markus Elfring
@ 2025-10-06 14:09 ` Henrique Carvalho
  2025-10-06 17:07   ` Steve French
  0 siblings, 1 reply; 3+ messages in thread
From: Henrique Carvalho @ 2025-10-06 14:09 UTC (permalink / raw)
  To: Markus Elfring, linux-cifs, samba-technical, Bharath SM,
	Paulo Alcantara, Ronnie Sahlberg, Shyam Prasad N, Steve French,
	Tom Talpey
  Cc: LKML, kernel-janitors

Acked-by: Henrique Carvalho <henrique.carvalho@suse.com>

On 10/5/25 2:10 PM, Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sun, 5 Oct 2025 19:01:48 +0200
> 
> * cifs_lookup():
>   Move the definition for the local variable “cfid” into an else branch
>   so that the corresponding setting will only be performed if a NULL inode
>   was detected during lookup by this function.
> 
> * cifs_d_revalidate():
>   Move the definition for the local variables “inode” and “rc” into
>   an if branch so that the corresponding setting will only be performed
>   after a d_really_is_positive() call.
> 
>   Move the definition for the local variable “cfid” into an else branch
>   so that the corresponding setting will only be performed if further data
>   processing will be needed for an open_cached_dir_by_dentry() call.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  fs/smb/client/dir.c | 12 ++++++------
>  1 file changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/fs/smb/client/dir.c b/fs/smb/client/dir.c
> index fc67a6441c96..7472fddadd4f 100644
> --- a/fs/smb/client/dir.c
> +++ b/fs/smb/client/dir.c
> @@ -678,7 +678,6 @@ cifs_lookup(struct inode *parent_dir_inode, struct dentry *direntry,
>  	const char *full_path;
>  	void *page;
>  	int retry_count = 0;
> -	struct cached_fid *cfid = NULL;
>  
>  	xid = get_xid();
>  
> @@ -717,6 +716,8 @@ cifs_lookup(struct inode *parent_dir_inode, struct dentry *direntry,
>  	if (d_really_is_positive(direntry)) {
>  		cifs_dbg(FYI, "non-NULL inode in lookup\n");
>  	} else {
> +		struct cached_fid *cfid = NULL;
> +
>  		cifs_dbg(FYI, "NULL inode in lookup\n");
>  
>  		/*
> @@ -785,15 +786,13 @@ static int
>  cifs_d_revalidate(struct inode *dir, const struct qstr *name,
>  		  struct dentry *direntry, unsigned int flags)
>  {
> -	struct inode *inode = NULL;
> -	struct cached_fid *cfid;
> -	int rc;
> -
>  	if (flags & LOOKUP_RCU)
>  		return -ECHILD;
>  
>  	if (d_really_is_positive(direntry)) {
> -		inode = d_inode(direntry);
> +		int rc;
> +		struct inode *inode = d_inode(direntry);
> +
>  		if ((flags & LOOKUP_REVAL) && !CIFS_CACHE_READ(CIFS_I(inode)))
>  			CIFS_I(inode)->time = 0; /* force reval */
>  
> @@ -836,6 +835,7 @@ cifs_d_revalidate(struct inode *dir, const struct qstr *name,
>  	} else {
>  		struct cifs_sb_info *cifs_sb = CIFS_SB(dir->i_sb);
>  		struct cifs_tcon *tcon = cifs_sb_master_tcon(cifs_sb);
> +		struct cached_fid *cfid;
>  
>  		if (!open_cached_dir_by_dentry(tcon, direntry->d_parent, &cfid)) {
>  			/*

-- 
Henrique
SUSE Labs

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] smb: client: Reduce the scopes for a few variables in two functions
  2025-10-06 14:09 ` Henrique Carvalho
@ 2025-10-06 17:07   ` Steve French
  0 siblings, 0 replies; 3+ messages in thread
From: Steve French @ 2025-10-06 17:07 UTC (permalink / raw)
  To: Henrique Carvalho
  Cc: Markus Elfring, linux-cifs, Bharath SM, Paulo Alcantara,
	Shyam Prasad N, LKML, kernel-janitors

merged into cifs-2.6.git for-next

On Mon, Oct 6, 2025 at 9:11 AM Henrique Carvalho
<henrique.carvalho@suse.com> wrote:
>
> Acked-by: Henrique Carvalho <henrique.carvalho@suse.com>
>
> On 10/5/25 2:10 PM, Markus Elfring wrote:
> > From: Markus Elfring <elfring@users.sourceforge.net>
> > Date: Sun, 5 Oct 2025 19:01:48 +0200
> >
> > * cifs_lookup():
> >   Move the definition for the local variable “cfid” into an else branch
> >   so that the corresponding setting will only be performed if a NULL inode
> >   was detected during lookup by this function.
> >
> > * cifs_d_revalidate():
> >   Move the definition for the local variables “inode” and “rc” into
> >   an if branch so that the corresponding setting will only be performed
> >   after a d_really_is_positive() call.
> >
> >   Move the definition for the local variable “cfid” into an else branch
> >   so that the corresponding setting will only be performed if further data
> >   processing will be needed for an open_cached_dir_by_dentry() call.
> >
> > Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> > ---
> >  fs/smb/client/dir.c | 12 ++++++------
> >  1 file changed, 6 insertions(+), 6 deletions(-)
> >
> > diff --git a/fs/smb/client/dir.c b/fs/smb/client/dir.c
> > index fc67a6441c96..7472fddadd4f 100644
> > --- a/fs/smb/client/dir.c
> > +++ b/fs/smb/client/dir.c
> > @@ -678,7 +678,6 @@ cifs_lookup(struct inode *parent_dir_inode, struct dentry *direntry,
> >       const char *full_path;
> >       void *page;
> >       int retry_count = 0;
> > -     struct cached_fid *cfid = NULL;
> >
> >       xid = get_xid();
> >
> > @@ -717,6 +716,8 @@ cifs_lookup(struct inode *parent_dir_inode, struct dentry *direntry,
> >       if (d_really_is_positive(direntry)) {
> >               cifs_dbg(FYI, "non-NULL inode in lookup\n");
> >       } else {
> > +             struct cached_fid *cfid = NULL;
> > +
> >               cifs_dbg(FYI, "NULL inode in lookup\n");
> >
> >               /*
> > @@ -785,15 +786,13 @@ static int
> >  cifs_d_revalidate(struct inode *dir, const struct qstr *name,
> >                 struct dentry *direntry, unsigned int flags)
> >  {
> > -     struct inode *inode = NULL;
> > -     struct cached_fid *cfid;
> > -     int rc;
> > -
> >       if (flags & LOOKUP_RCU)
> >               return -ECHILD;
> >
> >       if (d_really_is_positive(direntry)) {
> > -             inode = d_inode(direntry);
> > +             int rc;
> > +             struct inode *inode = d_inode(direntry);
> > +
> >               if ((flags & LOOKUP_REVAL) && !CIFS_CACHE_READ(CIFS_I(inode)))
> >                       CIFS_I(inode)->time = 0; /* force reval */
> >
> > @@ -836,6 +835,7 @@ cifs_d_revalidate(struct inode *dir, const struct qstr *name,
> >       } else {
> >               struct cifs_sb_info *cifs_sb = CIFS_SB(dir->i_sb);
> >               struct cifs_tcon *tcon = cifs_sb_master_tcon(cifs_sb);
> > +             struct cached_fid *cfid;
> >
> >               if (!open_cached_dir_by_dentry(tcon, direntry->d_parent, &cfid)) {
> >                       /*
>
> --
> Henrique
> SUSE Labs
>


-- 
Thanks,

Steve

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-10-06 17:07 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-05 17:10 [PATCH] smb: client: Reduce the scopes for a few variables in two functions Markus Elfring
2025-10-06 14:09 ` Henrique Carvalho
2025-10-06 17:07   ` Steve French

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox