aboutsummaryrefslogtreecommitdiffstats
path: root/fs/cifs
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2007-04-02 14:47:20 -0400
committerSteve French <sfrench@us.ibm.com>2007-04-02 14:47:20 -0400
commitc33f8d32746db12ba353b0a05b25f7893a0ac344 (patch)
tree874d9ae5afa5c1d1688105974b7ef8e8c3335302 /fs/cifs
parent2e175a90047a2dbc76fde169c990164895b25dfc (diff)
[CIFS] Remove unnecessary checks
file->f_path.dentry or file->f_path.dentry.d_inode can't be NULL since at least ten years, similar for all but very few arguments passed in from the VFS. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Steve French <sfrench@us.ibm.com>
Diffstat (limited to 'fs/cifs')
-rw-r--r--fs/cifs/cifsfs.c3
-rw-r--r--fs/cifs/file.c29
-rw-r--r--fs/cifs/readdir.c27
3 files changed, 6 insertions, 53 deletions
diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
index faba4d69fe91..dd03e680f8f8 100644
--- a/fs/cifs/cifsfs.c
+++ b/fs/cifs/cifsfs.c
@@ -529,8 +529,7 @@ static loff_t cifs_llseek(struct file *file, loff_t offset, int origin)
529 /* some applications poll for the file length in this strange 529 /* some applications poll for the file length in this strange
530 way so we must seek to end on non-oplocked files by 530 way so we must seek to end on non-oplocked files by
531 setting the revalidate time to zero */ 531 setting the revalidate time to zero */
532 if(file->f_path.dentry->d_inode) 532 CIFS_I(file->f_path.dentry->d_inode)->time = 0;
533 CIFS_I(file->f_path.dentry->d_inode)->time = 0;
534 533
535 retval = cifs_revalidate(file->f_path.dentry); 534 retval = cifs_revalidate(file->f_path.dentry);
536 if (retval < 0) 535 if (retval < 0)
diff --git a/fs/cifs/file.c b/fs/cifs/file.c
index 2d3275bedb55..914b449f202e 100644
--- a/fs/cifs/file.c
+++ b/fs/cifs/file.c
@@ -792,12 +792,7 @@ ssize_t cifs_user_write(struct file *file, const char __user *write_data,
792 int xid, long_op; 792 int xid, long_op;
793 struct cifsFileInfo *open_file; 793 struct cifsFileInfo *open_file;
794 794
795 if (file->f_path.dentry == NULL)
796 return -EBADF;
797
798 cifs_sb = CIFS_SB(file->f_path.dentry->d_sb); 795 cifs_sb = CIFS_SB(file->f_path.dentry->d_sb);
799 if (cifs_sb == NULL)
800 return -EBADF;
801 796
802 pTcon = cifs_sb->tcon; 797 pTcon = cifs_sb->tcon;
803 798
@@ -807,14 +802,9 @@ ssize_t cifs_user_write(struct file *file, const char __user *write_data,
807 802
808 if (file->private_data == NULL) 803 if (file->private_data == NULL)
809 return -EBADF; 804 return -EBADF;
810 else 805 open_file = (struct cifsFileInfo *) file->private_data;
811 open_file = (struct cifsFileInfo *) file->private_data;
812 806
813 xid = GetXid(); 807 xid = GetXid();
814 if (file->f_path.dentry->d_inode == NULL) {
815 FreeXid(xid);
816 return -EBADF;
817 }
818 808
819 if (*poffset > file->f_path.dentry->d_inode->i_size) 809 if (*poffset > file->f_path.dentry->d_inode->i_size)
820 long_op = 2; /* writes past end of file can take a long time */ 810 long_op = 2; /* writes past end of file can take a long time */
@@ -908,12 +898,7 @@ static ssize_t cifs_write(struct file *file, const char *write_data,
908 int xid, long_op; 898 int xid, long_op;
909 struct cifsFileInfo *open_file; 899 struct cifsFileInfo *open_file;
910 900
911 if (file->f_path.dentry == NULL)
912 return -EBADF;
913
914 cifs_sb = CIFS_SB(file->f_path.dentry->d_sb); 901 cifs_sb = CIFS_SB(file->f_path.dentry->d_sb);
915 if (cifs_sb == NULL)
916 return -EBADF;
917 902
918 pTcon = cifs_sb->tcon; 903 pTcon = cifs_sb->tcon;
919 904
@@ -922,14 +907,9 @@ static ssize_t cifs_write(struct file *file, const char *write_data,
922 907
923 if (file->private_data == NULL) 908 if (file->private_data == NULL)
924 return -EBADF; 909 return -EBADF;
925 else 910 open_file = (struct cifsFileInfo *)file->private_data;
926 open_file = (struct cifsFileInfo *)file->private_data;
927 911
928 xid = GetXid(); 912 xid = GetXid();
929 if (file->f_path.dentry->d_inode == NULL) {
930 FreeXid(xid);
931 return -EBADF;
932 }
933 913
934 if (*poffset > file->f_path.dentry->d_inode->i_size) 914 if (*poffset > file->f_path.dentry->d_inode->i_size)
935 long_op = 2; /* writes past end of file can take a long time */ 915 long_op = 2; /* writes past end of file can take a long time */
@@ -957,11 +937,6 @@ static ssize_t cifs_write(struct file *file, const char *write_data,
957 return -EBADF; 937 return -EBADF;
958 } 938 }
959 if (open_file->invalidHandle) { 939 if (open_file->invalidHandle) {
960 if ((file->f_path.dentry == NULL) ||
961 (file->f_path.dentry->d_inode == NULL)) {
962 FreeXid(xid);
963 return total_written;
964 }
965 /* we could deadlock if we called 940 /* we could deadlock if we called
966 filemap_fdatawait from here so tell 941 filemap_fdatawait from here so tell
967 reopen_file not to flush data to 942 reopen_file not to flush data to
diff --git a/fs/cifs/readdir.c b/fs/cifs/readdir.c
index 2a374d5215ab..3fab8ed697d1 100644
--- a/fs/cifs/readdir.c
+++ b/fs/cifs/readdir.c
@@ -444,9 +444,6 @@ static int initiate_cifs_search(const int xid, struct file *file)
444 cifsFile->invalidHandle = TRUE; 444 cifsFile->invalidHandle = TRUE;
445 cifsFile->srch_inf.endOfSearch = FALSE; 445 cifsFile->srch_inf.endOfSearch = FALSE;
446 446
447 if(file->f_path.dentry == NULL)
448 return -ENOENT;
449
450 cifs_sb = CIFS_SB(file->f_path.dentry->d_sb); 447 cifs_sb = CIFS_SB(file->f_path.dentry->d_sb);
451 if(cifs_sb == NULL) 448 if(cifs_sb == NULL)
452 return -EINVAL; 449 return -EINVAL;
@@ -618,20 +615,10 @@ static int cifs_entry_is_dot(char *current_entry, struct cifsFileInfo *cfile)
618 whether we can use the cached search results from the previous search */ 615 whether we can use the cached search results from the previous search */
619static int is_dir_changed(struct file * file) 616static int is_dir_changed(struct file * file)
620{ 617{
621 struct inode * inode; 618 struct inode *inode = file->f_path.dentry->d_inode;
622 struct cifsInodeInfo *cifsInfo; 619 struct cifsInodeInfo *cifsInfo = CIFS_I(inode);
623
624 if(file->f_path.dentry == NULL)
625 return 0;
626
627 inode = file->f_path.dentry->d_inode;
628
629 if(inode == NULL)
630 return 0;
631
632 cifsInfo = CIFS_I(inode);
633 620
634 if(cifsInfo->time == 0) 621 if (cifsInfo->time == 0)
635 return 1; /* directory was changed, perhaps due to unlink */ 622 return 1; /* directory was changed, perhaps due to unlink */
636 else 623 else
637 return 0; 624 return 0;
@@ -851,9 +838,6 @@ static int cifs_filldir(char *pfindEntry, struct file *file,
851 if((scratch_buf == NULL) || (pfindEntry == NULL) || (pCifsF == NULL)) 838 if((scratch_buf == NULL) || (pfindEntry == NULL) || (pCifsF == NULL))
852 return -ENOENT; 839 return -ENOENT;
853 840
854 if(file->f_path.dentry == NULL)
855 return -ENOENT;
856
857 rc = cifs_entry_is_dot(pfindEntry,pCifsF); 841 rc = cifs_entry_is_dot(pfindEntry,pCifsF);
858 /* skip . and .. since we added them first */ 842 /* skip . and .. since we added them first */
859 if(rc != 0) 843 if(rc != 0)
@@ -997,11 +981,6 @@ int cifs_readdir(struct file *file, void *direntry, filldir_t filldir)
997 981
998 xid = GetXid(); 982 xid = GetXid();
999 983
1000 if(file->f_path.dentry == NULL) {
1001 FreeXid(xid);
1002 return -EIO;
1003 }
1004
1005 cifs_sb = CIFS_SB(file->f_path.dentry->d_sb); 984 cifs_sb = CIFS_SB(file->f_path.dentry->d_sb);
1006 pTcon = cifs_sb->tcon; 985 pTcon = cifs_sb->tcon;
1007 if(pTcon == NULL) 986 if(pTcon == NULL)