svn commit: samba r20843 - in branches: SAMBA_3_0/source/smbd SAMBA_3_0_24/source/smbd

jra at samba.org jra at samba.org
Tue Jan 16 21:04:31 GMT 2007


Author: jra
Date: 2007-01-16 21:04:30 +0000 (Tue, 16 Jan 2007)
New Revision: 20843

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=20843

Log:
Get rid of last BOOL ok.
Jeremy.

Modified:
   branches/SAMBA_3_0/source/smbd/reply.c
   branches/SAMBA_3_0_24/source/smbd/reply.c


Changeset:
Modified: branches/SAMBA_3_0/source/smbd/reply.c
===================================================================
--- branches/SAMBA_3_0/source/smbd/reply.c	2007-01-16 20:53:50 UTC (rev 20842)
+++ branches/SAMBA_3_0/source/smbd/reply.c	2007-01-16 21:04:30 UTC (rev 20843)
@@ -895,14 +895,12 @@
 	unsigned int maxentries = 0;
 	BOOL finished = False;
 	char *p;
-	BOOL ok = False;
 	int status_len;
 	pstring path;
 	char status[21];
 	int dptr_num= -1;
 	BOOL check_descend = False;
 	BOOL expect_close = False;
-	BOOL can_open = True;
 	NTSTATUS nt_status;
 	BOOL mask_contains_wcard = False;
 	BOOL allow_long_path_components = (SVAL(inbuf,smb_flg2) & FLAGS2_LONG_PATH_COMPONENTS) ? True : False;
@@ -917,8 +915,9 @@
 	*mask = *directory = *fname = 0;
 
 	/* If we were called as SMBffirst then we must expect close. */
-	if(CVAL(inbuf,smb_com) == SMBffirst)
+	if(CVAL(inbuf,smb_com) == SMBffirst) {
 		expect_close = True;
+	}
   
 	outsize = set_message(outbuf,1,3,True);
 	maxentries = SVAL(inbuf,smb_vwv0); 
@@ -951,8 +950,10 @@
 		}
 		unix_format(dir2);
 
-		if (!check_name(directory,conn))
-			can_open = False;
+		if (!check_name(directory,conn)) {
+			END_PROFILE(SMBsearch);
+			return UNIXERROR(ERRDOS, ERRnoaccess);
+		}
 
 		p = strrchr_m(dir2,'/');
 		if (p == NULL) {
@@ -964,13 +965,15 @@
 		}
 
 		p = strrchr_m(directory,'/');
-		if (!p) 
+		if (!p) {
 			*directory = 0;
-		else
+		} else {
 			*p = 0;
+		}
 
-		if (strlen(directory) == 0)
+		if (strlen(directory) == 0) {
 			pstrcpy(directory,".");
+		}
 		memset((char *)status,'\0',21);
 		SCVAL(status,0,(dirtype & 0x1F));
 	} else {
@@ -978,83 +981,81 @@
 
 		memcpy(status,p,21);
 		status_dirtype = CVAL(status,0) & 0x1F;
-		if (status_dirtype != (dirtype & 0x1F))
+		if (status_dirtype != (dirtype & 0x1F)) {
 			dirtype = status_dirtype;
+		}
 
 		conn->dirptr = dptr_fetch(status+12,&dptr_num);      
-		if (!conn->dirptr)
+		if (!conn->dirptr) {
 			goto SearchEmpty;
+		}
 		string_set(&conn->dirpath,dptr_path(dptr_num));
 		pstrcpy(mask, dptr_wcard(dptr_num));
 	}
 
-	if (can_open) {
-		p = smb_buf(outbuf) + 3;
-		ok = True;
+	p = smb_buf(outbuf) + 3;
      
-		if (status_len == 0) {
-			dptr_num = dptr_create(conn,directory,True,expect_close,SVAL(inbuf,smb_pid), mask, mask_contains_wcard, dirtype);
-			if (dptr_num < 0) {
-				if(dptr_num == -2) {
-					END_PROFILE(SMBsearch);
-					return UNIXERROR(ERRDOS, ERRnofids);
-				}
+	if (status_len == 0) {
+		dptr_num = dptr_create(conn,directory,True,expect_close,SVAL(inbuf,smb_pid), mask, mask_contains_wcard, dirtype);
+		if (dptr_num < 0) {
+			if(dptr_num == -2) {
 				END_PROFILE(SMBsearch);
-				return ERROR_DOS(ERRDOS,ERRnofids);
+				return UNIXERROR(ERRDOS, ERRnofids);
 			}
+			END_PROFILE(SMBsearch);
+			return ERROR_DOS(ERRDOS,ERRnofids);
+		}
+	} else {
+		dirtype = dptr_attr(dptr_num);
+	}
+
+	DEBUG(4,("dptr_num is %d\n",dptr_num));
+
+	if ((dirtype&0x1F) == aVOLID) {	  
+		memcpy(p,status,21);
+		make_dir_struct(p,"???????????",volume_label(SNUM(conn)),
+				0,aVOLID,0,!allow_long_path_components);
+		dptr_fill(p+12,dptr_num);
+		if (dptr_zero(p+12) && (status_len==0)) {
+			numentries = 1;
 		} else {
-			dirtype = dptr_attr(dptr_num);
+			numentries = 0;
 		}
+		p += DIR_STRUCT_SIZE;
+	} else {
+		unsigned int i;
+		maxentries = MIN(maxentries, ((BUFFER_SIZE - (p - outbuf))/DIR_STRUCT_SIZE));
 
-		DEBUG(4,("dptr_num is %d\n",dptr_num));
+		DEBUG(8,("dirpath=<%s> dontdescend=<%s>\n",
+			conn->dirpath,lp_dontdescend(SNUM(conn))));
+		if (in_list(conn->dirpath, lp_dontdescend(SNUM(conn)),True)) {
+			check_descend = True;
+		}
 
-		if (ok) {
-			if ((dirtype&0x1F) == aVOLID) {	  
+		for (i=numentries;(i<maxentries) && !finished;i++) {
+			finished = !get_dir_entry(conn,mask,dirtype,fname,&size,&mode,&date,check_descend);
+			if (!finished) {
 				memcpy(p,status,21);
-				make_dir_struct(p,"???????????",volume_label(SNUM(conn)),
-						0,aVOLID,0,!allow_long_path_components);
-				dptr_fill(p+12,dptr_num);
-				if (dptr_zero(p+12) && (status_len==0))
-					numentries = 1;
-				else
-					numentries = 0;
+				make_dir_struct(p,mask,fname,size, mode,date,
+						!allow_long_path_components);
+				if (!dptr_fill(p+12,dptr_num)) {
+					break;
+				}
+				numentries++;
 				p += DIR_STRUCT_SIZE;
-			} else {
-				unsigned int i;
-				maxentries = MIN(maxentries, ((BUFFER_SIZE - (p - outbuf))/DIR_STRUCT_SIZE));
-
-				DEBUG(8,("dirpath=<%s> dontdescend=<%s>\n",
-				conn->dirpath,lp_dontdescend(SNUM(conn))));
-				if (in_list(conn->dirpath, lp_dontdescend(SNUM(conn)),True))
-					check_descend = True;
-
-				for (i=numentries;(i<maxentries) && !finished;i++) {
-					finished = !get_dir_entry(conn,mask,dirtype,fname,&size,&mode,&date,check_descend);
-					if (!finished) {
-						memcpy(p,status,21);
-						make_dir_struct(p,mask,fname,size, mode,date,
-								!allow_long_path_components);
-						if (!dptr_fill(p+12,dptr_num)) {
-							break;
-						}
-						numentries++;
-						p += DIR_STRUCT_SIZE;
-					}
-				}
 			}
-		} /* if (ok ) */
+		}
 	}
 
-
   SearchEmpty:
 
 	/* If we were called as SMBffirst with smb_search_id == NULL
 		and no entries were found then return error and close dirptr 
 		(X/Open spec) */
 
-	if (numentries == 0 || !ok) {
+	if (numentries == 0) {
 		dptr_close(&dptr_num);
-	} else if(ok && expect_close && status_len == 0) {
+	} else if(expect_close && status_len == 0) {
 		/* Close the dptr - we know it's gone */
 		dptr_close(&dptr_num);
 	}

Modified: branches/SAMBA_3_0_24/source/smbd/reply.c
===================================================================
--- branches/SAMBA_3_0_24/source/smbd/reply.c	2007-01-16 20:53:50 UTC (rev 20842)
+++ branches/SAMBA_3_0_24/source/smbd/reply.c	2007-01-16 21:04:30 UTC (rev 20843)
@@ -894,14 +894,12 @@
 	unsigned int maxentries = 0;
 	BOOL finished = False;
 	char *p;
-	BOOL ok = False;
 	int status_len;
 	pstring path;
 	char status[21];
 	int dptr_num= -1;
 	BOOL check_descend = False;
 	BOOL expect_close = False;
-	BOOL can_open = True;
 	NTSTATUS nt_status;
 	BOOL mask_contains_wcard = False;
 	BOOL allow_long_path_components = (SVAL(inbuf,smb_flg2) & FLAGS2_LONG_PATH_COMPONENTS) ? True : False;
@@ -916,8 +914,9 @@
 	*mask = *directory = *fname = 0;
 
 	/* If we were called as SMBffirst then we must expect close. */
-	if(CVAL(inbuf,smb_com) == SMBffirst)
+	if(CVAL(inbuf,smb_com) == SMBffirst) {
 		expect_close = True;
+	}
   
 	outsize = set_message(outbuf,1,3,True);
 	maxentries = SVAL(inbuf,smb_vwv0); 
@@ -950,8 +949,10 @@
 		}
 		unix_format(dir2);
 
-		if (!check_name(directory,conn))
-			can_open = False;
+		if (!check_name(directory,conn)) {
+			END_PROFILE(SMBsearch);
+			return UNIXERROR(ERRDOS, ERRnoaccess);
+		}
 
 		p = strrchr_m(dir2,'/');
 		if (p == NULL) {
@@ -963,13 +964,15 @@
 		}
 
 		p = strrchr_m(directory,'/');
-		if (!p) 
+		if (!p) {
 			*directory = 0;
-		else
+		} else {
 			*p = 0;
+		}
 
-		if (strlen(directory) == 0)
+		if (strlen(directory) == 0) {
 			pstrcpy(directory,".");
+		}
 		memset((char *)status,'\0',21);
 		SCVAL(status,0,(dirtype & 0x1F));
 	} else {
@@ -977,83 +980,81 @@
 
 		memcpy(status,p,21);
 		status_dirtype = CVAL(status,0) & 0x1F;
-		if (status_dirtype != (dirtype & 0x1F))
+		if (status_dirtype != (dirtype & 0x1F)) {
 			dirtype = status_dirtype;
+		}
 
 		conn->dirptr = dptr_fetch(status+12,&dptr_num);      
-		if (!conn->dirptr)
+		if (!conn->dirptr) {
 			goto SearchEmpty;
+		}
 		string_set(&conn->dirpath,dptr_path(dptr_num));
 		pstrcpy(mask, dptr_wcard(dptr_num));
 	}
 
-	if (can_open) {
-		p = smb_buf(outbuf) + 3;
-		ok = True;
+	p = smb_buf(outbuf) + 3;
      
-		if (status_len == 0) {
-			dptr_num = dptr_create(conn,directory,True,expect_close,SVAL(inbuf,smb_pid), mask, mask_contains_wcard, dirtype);
-			if (dptr_num < 0) {
-				if(dptr_num == -2) {
-					END_PROFILE(SMBsearch);
-					return UNIXERROR(ERRDOS, ERRnofids);
-				}
+	if (status_len == 0) {
+		dptr_num = dptr_create(conn,directory,True,expect_close,SVAL(inbuf,smb_pid), mask, mask_contains_wcard, dirtype);
+		if (dptr_num < 0) {
+			if(dptr_num == -2) {
 				END_PROFILE(SMBsearch);
-				return ERROR_DOS(ERRDOS,ERRnofids);
+				return UNIXERROR(ERRDOS, ERRnofids);
 			}
+			END_PROFILE(SMBsearch);
+			return ERROR_DOS(ERRDOS,ERRnofids);
+		}
+	} else {
+		dirtype = dptr_attr(dptr_num);
+	}
+
+	DEBUG(4,("dptr_num is %d\n",dptr_num));
+
+	if ((dirtype&0x1F) == aVOLID) {	  
+		memcpy(p,status,21);
+		make_dir_struct(p,"???????????",volume_label(SNUM(conn)),
+				0,aVOLID,0,!allow_long_path_components);
+		dptr_fill(p+12,dptr_num);
+		if (dptr_zero(p+12) && (status_len==0)) {
+			numentries = 1;
 		} else {
-			dirtype = dptr_attr(dptr_num);
+			numentries = 0;
 		}
+		p += DIR_STRUCT_SIZE;
+	} else {
+		unsigned int i;
+		maxentries = MIN(maxentries, ((BUFFER_SIZE - (p - outbuf))/DIR_STRUCT_SIZE));
 
-		DEBUG(4,("dptr_num is %d\n",dptr_num));
+		DEBUG(8,("dirpath=<%s> dontdescend=<%s>\n",
+			conn->dirpath,lp_dontdescend(SNUM(conn))));
+		if (in_list(conn->dirpath, lp_dontdescend(SNUM(conn)),True)) {
+			check_descend = True;
+		}
 
-		if (ok) {
-			if ((dirtype&0x1F) == aVOLID) {	  
+		for (i=numentries;(i<maxentries) && !finished;i++) {
+			finished = !get_dir_entry(conn,mask,dirtype,fname,&size,&mode,&date,check_descend);
+			if (!finished) {
 				memcpy(p,status,21);
-				make_dir_struct(p,"???????????",volume_label(SNUM(conn)),
-						0,aVOLID,0,!allow_long_path_components);
-				dptr_fill(p+12,dptr_num);
-				if (dptr_zero(p+12) && (status_len==0))
-					numentries = 1;
-				else
-					numentries = 0;
+				make_dir_struct(p,mask,fname,size, mode,date,
+						!allow_long_path_components);
+				if (!dptr_fill(p+12,dptr_num)) {
+					break;
+				}
+				numentries++;
 				p += DIR_STRUCT_SIZE;
-			} else {
-				unsigned int i;
-				maxentries = MIN(maxentries, ((BUFFER_SIZE - (p - outbuf))/DIR_STRUCT_SIZE));
-
-				DEBUG(8,("dirpath=<%s> dontdescend=<%s>\n",
-				conn->dirpath,lp_dontdescend(SNUM(conn))));
-				if (in_list(conn->dirpath, lp_dontdescend(SNUM(conn)),True))
-					check_descend = True;
-
-				for (i=numentries;(i<maxentries) && !finished;i++) {
-					finished = !get_dir_entry(conn,mask,dirtype,fname,&size,&mode,&date,check_descend);
-					if (!finished) {
-						memcpy(p,status,21);
-						make_dir_struct(p,mask,fname,size, mode,date,
-								!allow_long_path_components);
-						if (!dptr_fill(p+12,dptr_num)) {
-							break;
-						}
-						numentries++;
-						p += DIR_STRUCT_SIZE;
-					}
-				}
 			}
-		} /* if (ok ) */
+		}
 	}
 
-
   SearchEmpty:
 
 	/* If we were called as SMBffirst with smb_search_id == NULL
 		and no entries were found then return error and close dirptr 
 		(X/Open spec) */
 
-	if (numentries == 0 || !ok) {
+	if (numentries == 0) {
 		dptr_close(&dptr_num);
-	} else if(ok && expect_close && status_len == 0) {
+	} else if(expect_close && status_len == 0) {
 		/* Close the dptr - we know it's gone */
 		dptr_close(&dptr_num);
 	}



More information about the samba-cvs mailing list