[SCM] Samba Shared Repository - branch master updated - be3d9990635fa31e4110285842b1ca98ed4ce53c

Volker Lendecke vlendec at samba.org
Sat Dec 13 19:04:38 GMT 2008


The branch, master has been updated
       via  be3d9990635fa31e4110285842b1ca98ed4ce53c (commit)
       via  da6be4102ed1e3d4e20f08dd8944f062d13c759a (commit)
       via  b04d00744efb2189c37c01b2c57cc3899db1e482 (commit)
      from  1b7b0e924f3064a9774fd5d46bedc3d342b39ddb (commit)

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit be3d9990635fa31e4110285842b1ca98ed4ce53c
Author: Volker Lendecke <vl at samba.org>
Date:   Sat Dec 13 16:40:25 2008 +0100

    Remove a pointless static variable
    
    Every sane compiler will only allocate "*SMBSERVER" once

commit da6be4102ed1e3d4e20f08dd8944f062d13c759a
Author: Volker Lendecke <vl at samba.org>
Date:   Sat Dec 13 17:04:12 2008 +0100

    Remove a static variable
    
    Derrell, please check!
    
    Thanks,
    
    Volker

commit b04d00744efb2189c37c01b2c57cc3899db1e482
Author: Volker Lendecke <vl at samba.org>
Date:   Sat Dec 13 16:53:17 2008 +0100

    Micro-Optimize cliconnect.c
    
    In this form, the prots array is fully read-only in the text segment and thus
    can be shared between processes.
    
    Probably pointless, but I had fun doing it :-)

-----------------------------------------------------------------------

Summary of changes:
 source3/libsmb/cliconnect.c |   63 +++++++++++++++++++++++-------------------
 source3/libsmb/libsmb_dir.c |   11 +++----
 2 files changed, 39 insertions(+), 35 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/libsmb/cliconnect.c b/source3/libsmb/cliconnect.c
index d33775f..125345f 100644
--- a/source3/libsmb/cliconnect.c
+++ b/source3/libsmb/cliconnect.c
@@ -22,22 +22,21 @@
 
 static const struct {
 	int prot;
-	const char *name;
-} prots[] = {
-	{PROTOCOL_CORE,"PC NETWORK PROGRAM 1.0"},
-	{PROTOCOL_COREPLUS,"MICROSOFT NETWORKS 1.03"},
-	{PROTOCOL_LANMAN1,"MICROSOFT NETWORKS 3.0"},
-	{PROTOCOL_LANMAN1,"LANMAN1.0"},
-	{PROTOCOL_LANMAN2,"LM1.2X002"},
-	{PROTOCOL_LANMAN2,"DOS LANMAN2.1"},
-	{PROTOCOL_LANMAN2,"LANMAN2.1"},
-	{PROTOCOL_LANMAN2,"Samba"},
-	{PROTOCOL_NT1,"NT LANMAN 1.0"},
-	{PROTOCOL_NT1,"NT LM 0.12"},
-	{-1,NULL}
+	const char name[24];
+} prots[10] = {
+	{PROTOCOL_CORE,		"PC NETWORK PROGRAM 1.0"},
+	{PROTOCOL_COREPLUS,	"MICROSOFT NETWORKS 1.03"},
+	{PROTOCOL_LANMAN1,	"MICROSOFT NETWORKS 3.0"},
+	{PROTOCOL_LANMAN1,	"LANMAN1.0"},
+	{PROTOCOL_LANMAN2,	"LM1.2X002"},
+	{PROTOCOL_LANMAN2,	"DOS LANMAN2.1"},
+	{PROTOCOL_LANMAN2,	"LANMAN2.1"},
+	{PROTOCOL_LANMAN2,	"Samba"},
+	{PROTOCOL_NT1,		"NT LANMAN 1.0"},
+	{PROTOCOL_NT1,		"NT LM 0.12"},
 };
 
-static const char *star_smbserver_name = "*SMBSERVER";
+#define STAR_SMBSERVER "*SMBSERVER"
 
 /**
  * Set the user session key for a connection
@@ -863,7 +862,7 @@ ADS_STATUS cli_session_setup_spnego(struct cli_state *cli, const char *user,
 
 		if (principal == NULL &&
 			!is_ipaddress(cli->desthost) &&
-			!strequal(star_smbserver_name,
+			!strequal(STAR_SMBSERVER,
 				cli->desthost)) {
 			char *realm = NULL;
 			char *machine = NULL;
@@ -1221,9 +1220,10 @@ void cli_negprot_send(struct cli_state *cli)
 	cli_set_message(cli->outbuf,0,0,True);
 
 	p = smb_buf(cli->outbuf);
-	for (numprots=0;
-	     prots[numprots].name && prots[numprots].prot<=cli->protocol;
-	     numprots++) {
+	for (numprots=0; numprots < ARRAY_SIZE(prots); numprots++) {
+		if (prots[numprots].prot > cli->protocol) {
+			break;
+		}
 		*p++ = 2;
 		p += clistr_push(cli, p, prots[numprots].name, -1, STR_TERMINATE);
 	}
@@ -1252,18 +1252,23 @@ bool cli_negprot(struct cli_state *cli)
 
 	memset(cli->outbuf,'\0',smb_size);
 
+	plength = 0;
+
 	/* setup the protocol strings */
-	for (plength=0,numprots=0;
-	     prots[numprots].name && prots[numprots].prot<=cli->protocol;
-	     numprots++)
+	for (numprots=0; numprots < ARRAY_SIZE(prots); numprots++) {
+		if (prots[numprots].prot > cli->protocol) {
+			break;
+		}
 		plength += strlen(prots[numprots].name)+2;
+	}
 
 	cli_set_message(cli->outbuf,0,plength,True);
 
 	p = smb_buf(cli->outbuf);
-	for (numprots=0;
-	     prots[numprots].name && prots[numprots].prot<=cli->protocol;
-	     numprots++) {
+	for (numprots=0; numprots < ARRAY_SIZE(prots); numprots++) {
+		if (prots[numprots].prot > cli->protocol) {
+			break;
+		}
 		*p++ = 2;
 		p += clistr_push(cli, p, prots[numprots].name, -1, STR_TERMINATE);
 	}
@@ -1495,7 +1500,7 @@ NTSTATUS cli_connect(struct cli_state *cli,
 
 	/* reasonable default hostname */
 	if (!host) {
-		host = star_smbserver_name;
+		host = STAR_SMBSERVER;
 	}
 
 	fstrcpy(cli->desthost, host);
@@ -1643,8 +1648,8 @@ again:
 			*p = 0;
 			goto again;
 		}
-		if (strcmp(called.name, star_smbserver_name)) {
-			make_nmb_name(&called , star_smbserver_name, 0x20);
+		if (strcmp(called.name, STAR_SMBSERVER)) {
+			make_nmb_name(&called , STAR_SMBSERVER, 0x20);
 			goto again;
 		}
 		return NT_STATUS_BAD_NETWORK_NAME;
@@ -1774,7 +1779,7 @@ bool attempt_netbios_session_request(struct cli_state **ppcli, const char *srcho
 	 */
 
 	if(is_ipaddress(desthost)) {
-		make_nmb_name(&called, star_smbserver_name, 0x20);
+		make_nmb_name(&called, STAR_SMBSERVER, 0x20);
 	} else {
 		make_nmb_name(&called, desthost, 0x20);
 	}
@@ -1783,7 +1788,7 @@ bool attempt_netbios_session_request(struct cli_state **ppcli, const char *srcho
 		NTSTATUS status;
 		struct nmb_name smbservername;
 
-		make_nmb_name(&smbservername, star_smbserver_name, 0x20);
+		make_nmb_name(&smbservername, STAR_SMBSERVER, 0x20);
 
 		/*
 		 * If the name wasn't *SMBSERVER then
diff --git a/source3/libsmb/libsmb_dir.c b/source3/libsmb/libsmb_dir.c
index aa313f2..d12e748 100644
--- a/source3/libsmb/libsmb_dir.c
+++ b/source3/libsmb/libsmb_dir.c
@@ -1193,8 +1193,6 @@ SMBC_mkdir_ctx(SMBCCTX *context,
  * Our list function simply checks to see if a directory is not empty
  */
 
-static int smbc_rmdir_dirempty = True;
-
 static void
 rmdir_list_fn(const char *mnt,
               file_info *finfo,
@@ -1203,7 +1201,8 @@ rmdir_list_fn(const char *mnt,
 {
 	if (strncmp(finfo->name, ".", 1) != 0 &&
             strncmp(finfo->name, "..", 2) != 0) {
-		smbc_rmdir_dirempty = False;
+		bool *smbc_rmdir_dirempty = (bool *)state;
+		*smbc_rmdir_dirempty = false;
         }
 }
 
@@ -1292,8 +1291,7 @@ SMBC_rmdir_ctx(SMBCCTX *context,
 
                         /* Local storage to avoid buffer overflows */
 			char *lpath;
-
-			smbc_rmdir_dirempty = True;  /* Make this so ... */
+			bool smbc_rmdir_dirempty = true;
 
 			lpath = talloc_asprintf(frame, "%s\\*",
 						targetpath);
@@ -1305,7 +1303,8 @@ SMBC_rmdir_ctx(SMBCCTX *context,
 
 			if (cli_list(targetcli, lpath,
                                      aDIR | aSYSTEM | aHIDDEN,
-                                     rmdir_list_fn, NULL) < 0) {
+                                     rmdir_list_fn,
+				     &smbc_rmdir_dirempty) < 0) {
 
 				/* Fix errno to ignore latest error ... */
 				DEBUG(5, ("smbc_rmdir: "


-- 
Samba Shared Repository


More information about the samba-cvs mailing list