Commit d14537f1 authored by Steve French's avatar Steve French Committed by Linus Torvalds

[PATCH] cifs: remove a few redundant null pointer checks, and cleanup misc source formatting

Mostly suggested by Jesper Juhl

Signed-off-by: Steve French (sfrench@us.ibm.com)
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 6a0b4824
...@@ -284,51 +284,48 @@ cifs_create(struct inode *inode, struct dentry *direntry, int mode, ...@@ -284,51 +284,48 @@ cifs_create(struct inode *inode, struct dentry *direntry, int mode,
/* mknod case - do not leave file open */ /* mknod case - do not leave file open */
CIFSSMBClose(xid, pTcon, fileHandle); CIFSSMBClose(xid, pTcon, fileHandle);
} else if(newinode) { } else if(newinode) {
pCifsFile = (struct cifsFileInfo *) pCifsFile =
kmalloc(sizeof (struct cifsFileInfo), GFP_KERNEL); kmalloc(sizeof (struct cifsFileInfo), GFP_KERNEL);
if (pCifsFile) { if(pCifsFile == NULL)
memset((char *)pCifsFile, 0, goto cifs_create_out;
sizeof (struct cifsFileInfo)); memset((char *)pCifsFile, 0,
pCifsFile->netfid = fileHandle; sizeof (struct cifsFileInfo));
pCifsFile->pid = current->tgid; pCifsFile->netfid = fileHandle;
pCifsFile->pInode = newinode; pCifsFile->pid = current->tgid;
pCifsFile->invalidHandle = FALSE; pCifsFile->pInode = newinode;
pCifsFile->closePend = FALSE; pCifsFile->invalidHandle = FALSE;
init_MUTEX(&pCifsFile->fh_sem); pCifsFile->closePend = FALSE;
/* put the following in at open now */ init_MUTEX(&pCifsFile->fh_sem);
/* pCifsFile->pfile = file; */ /* set the following in open now
write_lock(&GlobalSMBSeslock); pCifsFile->pfile = file; */
list_add(&pCifsFile->tlist,&pTcon->openFileList); write_lock(&GlobalSMBSeslock);
pCifsInode = CIFS_I(newinode); list_add(&pCifsFile->tlist,&pTcon->openFileList);
if(pCifsInode) { pCifsInode = CIFS_I(newinode);
if(pCifsInode) {
/* if readable file instance put first in list*/ /* if readable file instance put first in list*/
if (write_only == TRUE) { if (write_only == TRUE) {
list_add_tail(&pCifsFile->flist, list_add_tail(&pCifsFile->flist,
&pCifsInode->openFileList); &pCifsInode->openFileList);
} else { } else {
list_add(&pCifsFile->flist, list_add(&pCifsFile->flist,
&pCifsInode->openFileList); &pCifsInode->openFileList);
}
if((oplock & 0xF) == OPLOCK_EXCLUSIVE) {
pCifsInode->clientCanCacheAll = TRUE;
pCifsInode->clientCanCacheRead = TRUE;
cFYI(1,("Exclusive Oplock granted on inode %p",
newinode));
} else if((oplock & 0xF) == OPLOCK_READ)
pCifsInode->clientCanCacheRead = TRUE;
} }
write_unlock(&GlobalSMBSeslock); if((oplock & 0xF) == OPLOCK_EXCLUSIVE) {
pCifsInode->clientCanCacheAll = TRUE;
pCifsInode->clientCanCacheRead = TRUE;
cFYI(1,("Exclusive Oplock for inode %p",
newinode));
} else if((oplock & 0xF) == OPLOCK_READ)
pCifsInode->clientCanCacheRead = TRUE;
} }
write_unlock(&GlobalSMBSeslock);
} }
} }
cifs_create_out:
if (buf) kfree(buf);
kfree(buf); kfree(full_path);
if (full_path)
kfree(full_path);
FreeXid(xid); FreeXid(xid);
return rc; return rc;
} }
...@@ -375,10 +372,8 @@ int cifs_mknod(struct inode *inode, struct dentry *direntry, int mode, dev_t dev ...@@ -375,10 +372,8 @@ int cifs_mknod(struct inode *inode, struct dentry *direntry, int mode, dev_t dev
} }
} }
if (full_path) kfree(full_path);
kfree(full_path);
FreeXid(xid); FreeXid(xid);
return rc; return rc;
} }
...@@ -447,8 +442,7 @@ cifs_lookup(struct inode *parent_dir_inode, struct dentry *direntry, struct name ...@@ -447,8 +442,7 @@ cifs_lookup(struct inode *parent_dir_inode, struct dentry *direntry, struct name
if file exists or not but no access BB */ if file exists or not but no access BB */
} }
if (full_path) kfree(full_path);
kfree(full_path);
FreeXid(xid); FreeXid(xid);
return ERR_PTR(rc); return ERR_PTR(rc);
} }
...@@ -478,8 +472,7 @@ cifs_dir_open(struct inode *inode, struct file *file) ...@@ -478,8 +472,7 @@ cifs_dir_open(struct inode *inode, struct file *file)
cFYI(1, ("inode = 0x%p and full path is %s", inode, full_path)); cFYI(1, ("inode = 0x%p and full path is %s", inode, full_path));
if (full_path) kfree(full_path);
kfree(full_path);
FreeXid(xid); FreeXid(xid);
return rc; return rc;
} }
......
...@@ -22,94 +22,155 @@ ...@@ -22,94 +22,155 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
#define SUCCESS 0 /* The request was successful. */ #define SUCCESS 0x00 /* The request was successful. */
#define ERRDOS 0x01 /* Error is from the core DOS operating system set */ #define ERRDOS 0x01 /* Error is from the core DOS operating system set */
#define ERRSRV 0x02 /* Error is generated by the file server daemon */ #define ERRSRV 0x02 /* Error is generated by the file server daemon */
#define ERRHRD 0x03 /* Error is a hardware error. */ #define ERRHRD 0x03 /* Error is a hardware error. */
#define ERRCMD 0xFF /* Command was not in the "SMB" format. */ #define ERRCMD 0xFF /* Command was not in the "SMB" format. */
/* The following error codes may be generated with the SUCCESS error class.*/ /* The following error codes may be generated with the SUCCESS error class.*/
#define SUCCESS 0 /* The request was successful. */ /*#define SUCCESS 0 The request was successful. */
/* The following error codes may be generated with the ERRDOS error class.*/ /* The following error codes may be generated with the ERRDOS error class.*/
#define ERRbadfunc 1 /* Invalid function. The server did not recognize or could not perform a system call generated by the server, e.g., set the DIRECTORY attribute on a data file, invalid seek mode. */ #define ERRbadfunc 1 /* Invalid function. The server did not
#define ERRbadfile 2 /*File not found. The last component of a file's pathname could not be found. */ recognize or could not perform a
#define ERRbadpath 3 /* Directory invalid. A directory component in a pathname could not be found. */ system call generated by the server,
#define ERRnofids 4 /* Too many open files. The server has no file handles available. */ e.g., set the DIRECTORY attribute on
#define ERRnoaccess 5 /* Access denied, the client's context does not permit the requested function. This includes the following conditions: invalid rename command, write to Fid open for read only, read on Fid open for write only, attempt to delete a non-empty directory */ a data file, invalid seek mode. */
#define ERRbadfid 6 /* Invalid file handle. The file handle specified was not recognized by the server. */ #define ERRbadfile 2 /* File not found. The last component
#define ERRbadmcb 7 /* Memory control blocks destroyed. */ of a file's pathname could not be
#define ERRnomem 8 /* Insufficient server memory to perform the requested function. */ found. */
#define ERRbadmem 9 /* Invalid memory block address. */ #define ERRbadpath 3 /* Directory invalid. A directory
#define ERRbadenv 10 /* Invalid environment. */ component in a pathname could not be
#define ERRbadformat 11 /* Invalid format. */ found. */
#define ERRbadaccess 12 /* Invalid open mode. */ #define ERRnofids 4 /* Too many open files. The server has
#define ERRbaddata 13 /* Invalid data (generated only by IOCTL calls within the server). */ no file handles available. */
#define ERRbaddrive 15 /* Invalid drive specified. */ #define ERRnoaccess 5 /* Access denied, the client's context
#define ERRremcd 16 /* A Delete Directory request attempted to remove the server's current directory. */ does not permit the requested
#define ERRdiffdevice 17 /* Not same device (e.g., a cross volume rename was attempted */ function. This includes the
#define ERRnofiles 18 /* A File Search command can find no more files matching the specified criteria. */ following conditions: invalid rename
#define ERRgeneral 31 command, write to Fid open for read
#define ERRbadshare 32 /* The sharing mode specified for an Open conflicts with existing FIDs on the file. */ only, read on Fid open for write
#define ERRlock 33 /* A Lock request conflicted with an existing lock or specified an invalid mode, or an Unlock requested attempted to remove a lock held by another process. */ only, attempt to delete a non-empty
#define ERRunsup 50 directory */
#define ERRnosuchshare 67 #define ERRbadfid 6 /* Invalid file handle. The file handle
#define ERRfilexists 80 /* The file named in the request already exists. */ specified was not recognized by the
#define ERRinvparm 87 server. */
#define ERRdiskfull 112 #define ERRbadmcb 7 /* Memory control blocks destroyed. */
#define ERRinvname 123 #define ERRnomem 8 /* Insufficient server memory to
#define ERRinvlevel 124 perform the requested function. */
#define ERRdirnotempty 145 #define ERRbadmem 9 /* Invalid memory block address. */
#define ERRnotlocked 158 #define ERRbadenv 10 /* Invalid environment. */
#define ERRalreadyexists 183 #define ERRbadformat 11 /* Invalid format. */
#define ERRbadpipe 230 #define ERRbadaccess 12 /* Invalid open mode. */
#define ERRpipebusy 231 #define ERRbaddata 13 /* Invalid data (generated only by
#define ERRpipeclosing 232 IOCTL calls within the server). */
#define ERRnotconnected 233 #define ERRbaddrive 15 /* Invalid drive specified. */
#define ERRmoredata 234 #define ERRremcd 16 /* A Delete Directory request attempted
#define ERReasnotsupported 282 to remove the server's current
#define ErrQuota 0x200 /* The operation would cause a quota limit to be exceeded. */ directory. */
#define ErrNotALink 0x201 /* A link operation was performed on a pathname that #define ERRdiffdevice 17 /* Not same device (e.g., a cross
was not a link. */ volume rename was attempted */
#define ERRnofiles 18 /* A File Search command can find no
more files matching the specified
criteria. */
#define ERRgeneral 31
#define ERRbadshare 32 /* The sharing mode specified for an
Open conflicts with existing FIDs on
the file. */
#define ERRlock 33 /* A Lock request conflicted with an
existing lock or specified an
invalid mode, or an Unlock requested
attempted to remove a lock held by
another process. */
#define ERRunsup 50
#define ERRnosuchshare 67
#define ERRfilexists 80 /* The file named in the request
already exists. */
#define ERRinvparm 87
#define ERRdiskfull 112
#define ERRinvname 123
#define ERRinvlevel 124
#define ERRdirnotempty 145
#define ERRnotlocked 158
#define ERRalreadyexists 183
#define ERRbadpipe 230
#define ERRpipebusy 231
#define ERRpipeclosing 232
#define ERRnotconnected 233
#define ERRmoredata 234
#define ERReasnotsupported 282
#define ErrQuota 0x200 /* The operation would cause a quota
limit to be exceeded. */
#define ErrNotALink 0x201 /* A link operation was performed on a
pathname that was not a link. */
/* Following error codes may be generated with the ERRSRV error /* Following error codes may be generated with the ERRSRV error class.*/
class.*/
#define ERRerror 1 /* Non-specific error code. It is returned under the following conditions: resource other than disk space exhausted (e.g. TIDs), first SMB command was not negotiate, multiple negotiates attempted, and internal server error. */ #define ERRerror 1 /* Non-specific error code. It is
#define ERRbadpw 2 /* Bad password - name/password pair in a TreeConnect or Session Setup are invalid. */ returned under the following
#define ERRbadtype 3 /* used for indicating DFS referral needed */ conditions: resource other than disk
#define ERRaccess 4 /* The client does not have the necessary access rights within the specified context for requested function. */ space exhausted (e.g. TIDs), first
#define ERRinvtid 5 /* The Tid specified in a command was invalid. */ SMB command was not negotiate,
#define ERRinvnetname 6 /* Invalid network name in tree connect. */ multiple negotiates attempted, and
#define ERRinvdevice 7 /* Invalid device - printer request made to non-printer connection or non-printer request made to printer connection. */ internal server error. */
#define ERRqfull 49 /* Print queue full (files) -- returned by open print file. */ #define ERRbadpw 2 /* Bad password - name/password pair in
#define ERRqtoobig 50 /* Print queue full -- no space. */ a TreeConnect or Session Setup are
#define ERRqeof 51 /* EOF on print queue dump */ invalid. */
#define ERRinvpfid 52 /* Invalid print file FID. */ #define ERRbadtype 3 /* used for indicating DFS referral
#define ERRsmbcmd 64 /* The server did not recognize the command received. */ needed */
#define ERRsrverror 65 /* The server encountered an internal error, e.g., system file unavailable. */ #define ERRaccess 4 /* The client does not have the
#define ERRbadBID 66 /* (obsolete) */ necessary access rights within the
#define ERRfilespecs 67 /* The Fid and pathname parameters contained an invalid combination of values. */ specified context for requested
#define ERRbadLink 68 /* (obsolete) */ function. */
#define ERRbadpermits 69 /* The access permissions specified for a file or directory are not a valid combination. */ #define ERRinvtid 5 /* The Tid specified in a command was
#define ERRbadPID 70 invalid. */
#define ERRsetattrmode 71 /* attribute (mode) is invalid */ #define ERRinvnetname 6 /* Invalid network name in tree
#define ERRpaused 81 /* Server is paused */ connect. */
#define ERRmsgoff 82 /* reserved - messaging off */ #define ERRinvdevice 7 /* Invalid device - printer request
#define ERRnoroom 83 /* reserved - no room for message */ made to non-printer connection or
#define ERRrmuns 87 /* reserved - too many remote names */ non-printer request made to printer
#define ERRtimeout 88 /* operation timed out */ connection. */
#define ERRnoresource 89 /* No resources available for request */ #define ERRqfull 49 /* Print queue full (files) -- returned
#define ERRtoomanyuids 90 /* Too many UIDs active on this session */ by open print file. */
#define ERRbaduid 91 /* The UID is not known as a valid user */ #define ERRqtoobig 50 /* Print queue full -- no space. */
#define ERRusempx 250 /* temporarily unable to use raw */ #define ERRqeof 51 /* EOF on print queue dump */
#define ERRusestd 251 /* temporarily unable to use either raw or mpx */ #define ERRinvpfid 52 /* Invalid print file FID. */
#define ERR_NOTIFY_ENUM_DIR 1024 #define ERRsmbcmd 64 /* The server did not recognize the
#define ERRaccountexpired 2239 command received. */
#define ERRbadclient 2240 #define ERRsrverror 65 /* The server encountered an internal
#define ERRbadLogonTime 2241 error, e.g., system file
#define ERRpasswordExpired 2242 unavailable. */
#define ERRnetlogonNotStarted 2455 #define ERRbadBID 66 /* (obsolete) */
#define ERRnosupport 0xFFFF #define ERRfilespecs 67 /* The Fid and pathname parameters
contained an invalid combination of
values. */
#define ERRbadLink 68 /* (obsolete) */
#define ERRbadpermits 69 /* The access permissions specified for
a file or directory are not a valid
combination. */
#define ERRbadPID 70
#define ERRsetattrmode 71 /* attribute (mode) is invalid */
#define ERRpaused 81 /* Server is paused */
#define ERRmsgoff 82 /* reserved - messaging off */
#define ERRnoroom 83 /* reserved - no room for message */
#define ERRrmuns 87 /* reserved - too many remote names */
#define ERRtimeout 88 /* operation timed out */
#define ERRnoresource 89 /* No resources available for request
*/
#define ERRtoomanyuids 90 /* Too many UIDs active on this session
*/
#define ERRbaduid 91 /* The UID is not known as a valid user
*/
#define ERRusempx 250 /* temporarily unable to use raw */
#define ERRusestd 251 /* temporarily unable to use either raw
or mpx */
#define ERR_NOTIFY_ENUM_DIR 1024
#define ERRaccountexpired 2239
#define ERRbadclient 2240
#define ERRbadLogonTime 2241
#define ERRpasswordExpired 2242
#define ERRnetlogonNotStarted 2455
#define ERRnosupport 0xFFFF
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment