aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorSteve French <smfrench@austin.rr.com>2005-04-29 01:41:05 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-29 01:41:05 -0400
commitd14537f103bf746ca766f739f9f5a5bf7a8b4806 (patch)
tree421be78e49566536638effd2fa3f222686cf27fd /fs
parent6a0b48245a135cd132e747815854e3999967f8a7 (diff)
[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: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'fs')
-rw-r--r--fs/cifs/dir.c83
-rw-r--r--fs/cifs/smberr.h227
2 files changed, 182 insertions, 128 deletions
diff --git a/fs/cifs/dir.c b/fs/cifs/dir.c
index f54e1866f0f4..12ba81d7b07f 100644
--- a/fs/cifs/dir.c
+++ b/fs/cifs/dir.c
@@ -284,51 +284,48 @@ cifs_create(struct inode *inode, struct dentry *direntry, int mode,
284 /* mknod case - do not leave file open */ 284 /* mknod case - do not leave file open */
285 CIFSSMBClose(xid, pTcon, fileHandle); 285 CIFSSMBClose(xid, pTcon, fileHandle);
286 } else if(newinode) { 286 } else if(newinode) {
287 pCifsFile = (struct cifsFileInfo *) 287 pCifsFile =
288 kmalloc(sizeof (struct cifsFileInfo), GFP_KERNEL); 288 kmalloc(sizeof (struct cifsFileInfo), GFP_KERNEL);
289 289
290 if (pCifsFile) { 290 if(pCifsFile == NULL)
291 memset((char *)pCifsFile, 0, 291 goto cifs_create_out;
292 sizeof (struct cifsFileInfo)); 292 memset((char *)pCifsFile, 0,
293 pCifsFile->netfid = fileHandle; 293 sizeof (struct cifsFileInfo));
294 pCifsFile->pid = current->tgid; 294 pCifsFile->netfid = fileHandle;
295 pCifsFile->pInode = newinode; 295 pCifsFile->pid = current->tgid;
296 pCifsFile->invalidHandle = FALSE; 296 pCifsFile->pInode = newinode;
297 pCifsFile->closePend = FALSE; 297 pCifsFile->invalidHandle = FALSE;
298 init_MUTEX(&pCifsFile->fh_sem); 298 pCifsFile->closePend = FALSE;
299 /* put the following in at open now */ 299 init_MUTEX(&pCifsFile->fh_sem);
300 /* pCifsFile->pfile = file; */ 300 /* set the following in open now
301 write_lock(&GlobalSMBSeslock); 301 pCifsFile->pfile = file; */
302 list_add(&pCifsFile->tlist,&pTcon->openFileList); 302 write_lock(&GlobalSMBSeslock);
303 pCifsInode = CIFS_I(newinode); 303 list_add(&pCifsFile->tlist,&pTcon->openFileList);
304 if(pCifsInode) { 304 pCifsInode = CIFS_I(newinode);
305 if(pCifsInode) {
305 /* if readable file instance put first in list*/ 306 /* if readable file instance put first in list*/
306 if (write_only == TRUE) { 307 if (write_only == TRUE) {
307 list_add_tail(&pCifsFile->flist, 308 list_add_tail(&pCifsFile->flist,
308 &pCifsInode->openFileList); 309 &pCifsInode->openFileList);
309 } else { 310 } else {
310 list_add(&pCifsFile->flist, 311 list_add(&pCifsFile->flist,
311 &pCifsInode->openFileList); 312 &pCifsInode->openFileList);
312 }
313 if((oplock & 0xF) == OPLOCK_EXCLUSIVE) {
314 pCifsInode->clientCanCacheAll = TRUE;
315 pCifsInode->clientCanCacheRead = TRUE;
316 cFYI(1,("Exclusive Oplock granted on inode %p",
317 newinode));
318 } else if((oplock & 0xF) == OPLOCK_READ)
319 pCifsInode->clientCanCacheRead = TRUE;
320 } 313 }
321 write_unlock(&GlobalSMBSeslock); 314 if((oplock & 0xF) == OPLOCK_EXCLUSIVE) {
315 pCifsInode->clientCanCacheAll = TRUE;
316 pCifsInode->clientCanCacheRead = TRUE;
317 cFYI(1,("Exclusive Oplock for inode %p",
318 newinode));
319 } else if((oplock & 0xF) == OPLOCK_READ)
320 pCifsInode->clientCanCacheRead = TRUE;
322 } 321 }
322 write_unlock(&GlobalSMBSeslock);
323 } 323 }
324 } 324 }
325 325cifs_create_out:
326 if (buf) 326 kfree(buf);
327 kfree(buf); 327 kfree(full_path);
328 if (full_path)
329 kfree(full_path);
330 FreeXid(xid); 328 FreeXid(xid);
331
332 return rc; 329 return rc;
333} 330}
334 331
@@ -375,10 +372,8 @@ int cifs_mknod(struct inode *inode, struct dentry *direntry, int mode, dev_t dev
375 } 372 }
376 } 373 }
377 374
378 if (full_path) 375 kfree(full_path);
379 kfree(full_path);
380 FreeXid(xid); 376 FreeXid(xid);
381
382 return rc; 377 return rc;
383} 378}
384 379
@@ -447,8 +442,7 @@ cifs_lookup(struct inode *parent_dir_inode, struct dentry *direntry, struct name
447 if file exists or not but no access BB */ 442 if file exists or not but no access BB */
448 } 443 }
449 444
450 if (full_path) 445 kfree(full_path);
451 kfree(full_path);
452 FreeXid(xid); 446 FreeXid(xid);
453 return ERR_PTR(rc); 447 return ERR_PTR(rc);
454} 448}
@@ -478,8 +472,7 @@ cifs_dir_open(struct inode *inode, struct file *file)
478 472
479 cFYI(1, ("inode = 0x%p and full path is %s", inode, full_path)); 473 cFYI(1, ("inode = 0x%p and full path is %s", inode, full_path));
480 474
481 if (full_path) 475 kfree(full_path);
482 kfree(full_path);
483 FreeXid(xid); 476 FreeXid(xid);
484 return rc; 477 return rc;
485} 478}
diff --git a/fs/cifs/smberr.h b/fs/cifs/smberr.h
index e21f1384661f..1b53dcd0f2eb 100644
--- a/fs/cifs/smberr.h
+++ b/fs/cifs/smberr.h
@@ -22,94 +22,155 @@
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 */ 23 */
24 24
25#define SUCCESS 0 /* The request was successful. */ 25#define SUCCESS 0x00 /* The request was successful. */
26#define ERRDOS 0x01 /* Error is from the core DOS operating system set */ 26#define ERRDOS 0x01 /* Error is from the core DOS operating system set */
27#define ERRSRV 0x02 /* Error is generated by the file server daemon */ 27#define ERRSRV 0x02 /* Error is generated by the file server daemon */
28#define ERRHRD 0x03 /* Error is a hardware error. */ 28#define ERRHRD 0x03 /* Error is a hardware error. */
29#define ERRCMD 0xFF /* Command was not in the "SMB" format. */ 29#define ERRCMD 0xFF /* Command was not in the "SMB" format. */
30 30
31/* The following error codes may be generated with the SUCCESS error class.*/ 31/* The following error codes may be generated with the SUCCESS error class.*/
32 32
33#define SUCCESS 0 /* The request was successful. */ 33/*#define SUCCESS 0 The request was successful. */
34 34
35/* The following error codes may be generated with the ERRDOS error class.*/ 35/* The following error codes may be generated with the ERRDOS error class.*/
36 36
37#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. */ 37#define ERRbadfunc 1 /* Invalid function. The server did not
38#define ERRbadfile 2 /*File not found. The last component of a file's pathname could not be found. */ 38 recognize or could not perform a
39#define ERRbadpath 3 /* Directory invalid. A directory component in a pathname could not be found. */ 39 system call generated by the server,
40#define ERRnofids 4 /* Too many open files. The server has no file handles available. */ 40 e.g., set the DIRECTORY attribute on
41#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 */ 41 a data file, invalid seek mode. */
42#define ERRbadfid 6 /* Invalid file handle. The file handle specified was not recognized by the server. */ 42#define ERRbadfile 2 /* File not found. The last component
43#define ERRbadmcb 7 /* Memory control blocks destroyed. */ 43 of a file's pathname could not be
44#define ERRnomem 8 /* Insufficient server memory to perform the requested function. */ 44 found. */
45#define ERRbadmem 9 /* Invalid memory block address. */ 45#define ERRbadpath 3 /* Directory invalid. A directory
46#define ERRbadenv 10 /* Invalid environment. */ 46 component in a pathname could not be
47#define ERRbadformat 11 /* Invalid format. */ 47 found. */
48#define ERRbadaccess 12 /* Invalid open mode. */ 48#define ERRnofids 4 /* Too many open files. The server has
49#define ERRbaddata 13 /* Invalid data (generated only by IOCTL calls within the server). */ 49 no file handles available. */
50#define ERRbaddrive 15 /* Invalid drive specified. */ 50#define ERRnoaccess 5 /* Access denied, the client's context
51#define ERRremcd 16 /* A Delete Directory request attempted to remove the server's current directory. */ 51 does not permit the requested
52#define ERRdiffdevice 17 /* Not same device (e.g., a cross volume rename was attempted */ 52 function. This includes the
53#define ERRnofiles 18 /* A File Search command can find no more files matching the specified criteria. */ 53 following conditions: invalid rename
54#define ERRgeneral 31 54 command, write to Fid open for read
55#define ERRbadshare 32 /* The sharing mode specified for an Open conflicts with existing FIDs on the file. */ 55 only, read on Fid open for write
56#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. */ 56 only, attempt to delete a non-empty
57#define ERRunsup 50 57 directory */
58#define ERRnosuchshare 67 58#define ERRbadfid 6 /* Invalid file handle. The file handle
59#define ERRfilexists 80 /* The file named in the request already exists. */ 59 specified was not recognized by the
60#define ERRinvparm 87 60 server. */
61#define ERRdiskfull 112 61#define ERRbadmcb 7 /* Memory control blocks destroyed. */
62#define ERRinvname 123 62#define ERRnomem 8 /* Insufficient server memory to
63#define ERRinvlevel 124 63 perform the requested function. */
64#define ERRdirnotempty 145 64#define ERRbadmem 9 /* Invalid memory block address. */
65#define ERRnotlocked 158 65#define ERRbadenv 10 /* Invalid environment. */
66#define ERRalreadyexists 183 66#define ERRbadformat 11 /* Invalid format. */
67#define ERRbadpipe 230 67#define ERRbadaccess 12 /* Invalid open mode. */
68#define ERRpipebusy 231 68#define ERRbaddata 13 /* Invalid data (generated only by
69#define ERRpipeclosing 232 69 IOCTL calls within the server). */
70#define ERRnotconnected 233 70#define ERRbaddrive 15 /* Invalid drive specified. */
71#define ERRmoredata 234 71#define ERRremcd 16 /* A Delete Directory request attempted
72#define ERReasnotsupported 282 72 to remove the server's current
73#define ErrQuota 0x200 /* The operation would cause a quota limit to be exceeded. */ 73 directory. */
74#define ErrNotALink 0x201 /* A link operation was performed on a pathname that 74#define ERRdiffdevice 17 /* Not same device (e.g., a cross
75 was not a link. */ 75 volume rename was attempted */
76#define ERRnofiles 18 /* A File Search command can find no
77 more files matching the specified
78 criteria. */
79#define ERRgeneral 31
80#define ERRbadshare 32 /* The sharing mode specified for an
81 Open conflicts with existing FIDs on
82 the file. */
83#define ERRlock 33 /* A Lock request conflicted with an
84 existing lock or specified an
85 invalid mode, or an Unlock requested
86 attempted to remove a lock held by
87 another process. */
88#define ERRunsup 50
89#define ERRnosuchshare 67
90#define ERRfilexists 80 /* The file named in the request
91 already exists. */
92#define ERRinvparm 87
93#define ERRdiskfull 112
94#define ERRinvname 123
95#define ERRinvlevel 124
96#define ERRdirnotempty 145
97#define ERRnotlocked 158
98#define ERRalreadyexists 183
99#define ERRbadpipe 230
100#define ERRpipebusy 231
101#define ERRpipeclosing 232
102#define ERRnotconnected 233
103#define ERRmoredata 234
104#define ERReasnotsupported 282
105#define ErrQuota 0x200 /* The operation would cause a quota
106 limit to be exceeded. */
107#define ErrNotALink 0x201 /* A link operation was performed on a
108 pathname that was not a link. */
76 109
77/* Following error codes may be generated with the ERRSRV error 110/* Following error codes may be generated with the ERRSRV error class.*/
78class.*/
79 111
80#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. */ 112#define ERRerror 1 /* Non-specific error code. It is
81#define ERRbadpw 2 /* Bad password - name/password pair in a TreeConnect or Session Setup are invalid. */ 113 returned under the following
82#define ERRbadtype 3 /* used for indicating DFS referral needed */ 114 conditions: resource other than disk
83#define ERRaccess 4 /* The client does not have the necessary access rights within the specified context for requested function. */ 115 space exhausted (e.g. TIDs), first
84#define ERRinvtid 5 /* The Tid specified in a command was invalid. */ 116 SMB command was not negotiate,
85#define ERRinvnetname 6 /* Invalid network name in tree connect. */ 117 multiple negotiates attempted, and
86#define ERRinvdevice 7 /* Invalid device - printer request made to non-printer connection or non-printer request made to printer connection. */ 118 internal server error. */
87#define ERRqfull 49 /* Print queue full (files) -- returned by open print file. */ 119#define ERRbadpw 2 /* Bad password - name/password pair in
88#define ERRqtoobig 50 /* Print queue full -- no space. */ 120 a TreeConnect or Session Setup are
89#define ERRqeof 51 /* EOF on print queue dump */ 121 invalid. */
90#define ERRinvpfid 52 /* Invalid print file FID. */ 122#define ERRbadtype 3 /* used for indicating DFS referral
91#define ERRsmbcmd 64 /* The server did not recognize the command received. */ 123 needed */
92#define ERRsrverror 65 /* The server encountered an internal error, e.g., system file unavailable. */ 124#define ERRaccess 4 /* The client does not have the
93#define ERRbadBID 66 /* (obsolete) */ 125 necessary access rights within the
94#define ERRfilespecs 67 /* The Fid and pathname parameters contained an invalid combination of values. */ 126 specified context for requested
95#define ERRbadLink 68 /* (obsolete) */ 127 function. */
96#define ERRbadpermits 69 /* The access permissions specified for a file or directory are not a valid combination. */ 128#define ERRinvtid 5 /* The Tid specified in a command was
97#define ERRbadPID 70 129 invalid. */
98#define ERRsetattrmode 71 /* attribute (mode) is invalid */ 130#define ERRinvnetname 6 /* Invalid network name in tree
99#define ERRpaused 81 /* Server is paused */ 131 connect. */
100#define ERRmsgoff 82 /* reserved - messaging off */ 132#define ERRinvdevice 7 /* Invalid device - printer request
101#define ERRnoroom 83 /* reserved - no room for message */ 133 made to non-printer connection or
102#define ERRrmuns 87 /* reserved - too many remote names */ 134 non-printer request made to printer
103#define ERRtimeout 88 /* operation timed out */ 135 connection. */
104#define ERRnoresource 89 /* No resources available for request */ 136#define ERRqfull 49 /* Print queue full (files) -- returned
105#define ERRtoomanyuids 90 /* Too many UIDs active on this session */ 137 by open print file. */
106#define ERRbaduid 91 /* The UID is not known as a valid user */ 138#define ERRqtoobig 50 /* Print queue full -- no space. */
107#define ERRusempx 250 /* temporarily unable to use raw */ 139#define ERRqeof 51 /* EOF on print queue dump */
108#define ERRusestd 251 /* temporarily unable to use either raw or mpx */ 140#define ERRinvpfid 52 /* Invalid print file FID. */
109#define ERR_NOTIFY_ENUM_DIR 1024 141#define ERRsmbcmd 64 /* The server did not recognize the
110#define ERRaccountexpired 2239 142 command received. */
111#define ERRbadclient 2240 143#define ERRsrverror 65 /* The server encountered an internal
112#define ERRbadLogonTime 2241 144 error, e.g., system file
113#define ERRpasswordExpired 2242 145 unavailable. */
114#define ERRnetlogonNotStarted 2455 146#define ERRbadBID 66 /* (obsolete) */
115#define ERRnosupport 0xFFFF 147#define ERRfilespecs 67 /* The Fid and pathname parameters
148 contained an invalid combination of
149 values. */
150#define ERRbadLink 68 /* (obsolete) */
151#define ERRbadpermits 69 /* The access permissions specified for
152 a file or directory are not a valid
153 combination. */
154#define ERRbadPID 70
155#define ERRsetattrmode 71 /* attribute (mode) is invalid */
156#define ERRpaused 81 /* Server is paused */
157#define ERRmsgoff 82 /* reserved - messaging off */
158#define ERRnoroom 83 /* reserved - no room for message */
159#define ERRrmuns 87 /* reserved - too many remote names */
160#define ERRtimeout 88 /* operation timed out */
161#define ERRnoresource 89 /* No resources available for request
162 */
163#define ERRtoomanyuids 90 /* Too many UIDs active on this session
164 */
165#define ERRbaduid 91 /* The UID is not known as a valid user
166 */
167#define ERRusempx 250 /* temporarily unable to use raw */
168#define ERRusestd 251 /* temporarily unable to use either raw
169 or mpx */
170#define ERR_NOTIFY_ENUM_DIR 1024
171#define ERRaccountexpired 2239
172#define ERRbadclient 2240
173#define ERRbadLogonTime 2241
174#define ERRpasswordExpired 2242
175#define ERRnetlogonNotStarted 2455
176#define ERRnosupport 0xFFFF