Skip to content

Commit e7933f5

Browse files
elfringsmfrench
authored andcommitted
smb: client: Reduce the scopes for a few variables in two functions
* 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> Acked-by: Henrique Carvalho <henrique.carvalho@suse.com> Signed-off-by: Steve French <stfrench@microsoft.com>
1 parent 63e62ba commit e7933f5

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

fs/smb/client/dir.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -678,7 +678,6 @@ cifs_lookup(struct inode *parent_dir_inode, struct dentry *direntry,
678678
const char *full_path;
679679
void *page;
680680
int retry_count = 0;
681-
struct cached_fid *cfid = NULL;
682681

683682
xid = get_xid();
684683

@@ -717,6 +716,8 @@ cifs_lookup(struct inode *parent_dir_inode, struct dentry *direntry,
717716
if (d_really_is_positive(direntry)) {
718717
cifs_dbg(FYI, "non-NULL inode in lookup\n");
719718
} else {
719+
struct cached_fid *cfid = NULL;
720+
720721
cifs_dbg(FYI, "NULL inode in lookup\n");
721722

722723
/*
@@ -785,15 +786,13 @@ static int
785786
cifs_d_revalidate(struct inode *dir, const struct qstr *name,
786787
struct dentry *direntry, unsigned int flags)
787788
{
788-
struct inode *inode = NULL;
789-
struct cached_fid *cfid;
790-
int rc;
791-
792789
if (flags & LOOKUP_RCU)
793790
return -ECHILD;
794791

795792
if (d_really_is_positive(direntry)) {
796-
inode = d_inode(direntry);
793+
int rc;
794+
struct inode *inode = d_inode(direntry);
795+
797796
if ((flags & LOOKUP_REVAL) && !CIFS_CACHE_READ(CIFS_I(inode)))
798797
CIFS_I(inode)->time = 0; /* force reval */
799798

@@ -836,6 +835,7 @@ cifs_d_revalidate(struct inode *dir, const struct qstr *name,
836835
} else {
837836
struct cifs_sb_info *cifs_sb = CIFS_SB(dir->i_sb);
838837
struct cifs_tcon *tcon = cifs_sb_master_tcon(cifs_sb);
838+
struct cached_fid *cfid;
839839

840840
if (!open_cached_dir_by_dentry(tcon, direntry->d_parent, &cfid)) {
841841
/*

0 commit comments

Comments
 (0)