svn commit: samba r25047 - in branches/SAMBA_4_0: . source/auth source/lib/messaging source/lib/registry source/lib/util source/libcli source/nsswitch source/param source/utils

jelmer at samba.org jelmer at samba.org
Sun Sep 9 19:34:36 GMT 2007


Author: jelmer
Date: 2007-09-09 19:34:30 +0000 (Sun, 09 Sep 2007)
New Revision: 25047

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

Log:
Fix more warnings.
Modified:
   branches/SAMBA_4_0/
   branches/SAMBA_4_0/source/auth/auth.c
   branches/SAMBA_4_0/source/lib/messaging/messaging.c
   branches/SAMBA_4_0/source/lib/registry/local.c
   branches/SAMBA_4_0/source/lib/registry/patchfile_preg.c
   branches/SAMBA_4_0/source/lib/registry/regf.c
   branches/SAMBA_4_0/source/lib/util/ms_fnmatch.c
   branches/SAMBA_4_0/source/lib/util/util.h
   branches/SAMBA_4_0/source/lib/util/util_pw.c
   branches/SAMBA_4_0/source/lib/util/util_str.c
   branches/SAMBA_4_0/source/libcli/libcli.h
   branches/SAMBA_4_0/source/nsswitch/wb_common.c
   branches/SAMBA_4_0/source/param/loadparm.c
   branches/SAMBA_4_0/source/param/share.c
   branches/SAMBA_4_0/source/utils/testparm.c


Changeset:

Property changes on: branches/SAMBA_4_0
___________________________________________________________________
Name: bzr:revision-info
...skipped...
Name: bzr:revision-id:v3-trunk0
...skipped...

Modified: branches/SAMBA_4_0/source/auth/auth.c
===================================================================
--- branches/SAMBA_4_0/source/auth/auth.c	2007-09-09 12:02:51 UTC (rev 25046)
+++ branches/SAMBA_4_0/source/auth/auth.c	2007-09-09 19:34:30 UTC (rev 25047)
@@ -455,13 +455,14 @@
 		return NT_STATUS_OBJECT_NAME_COLLISION;
 	}
 
-	backends = realloc_p(backends, struct auth_backend, num_backends+1);
-	if (!backends) {
-		return NT_STATUS_NO_MEMORY;
-	}
+	backends = talloc_realloc(talloc_autofree_context(), backends, 
+				  struct auth_backend, num_backends+1);
+	NT_STATUS_HAVE_NO_MEMORY(backends);
 
-	new_ops = smb_xmemdup(ops, sizeof(*ops));
-	new_ops->name = smb_xstrdup(ops->name);
+	new_ops = talloc_memdup(backends, ops, sizeof(*ops));
+	NT_STATUS_HAVE_NO_MEMORY(new_ops);
+	new_ops->name = talloc_strdup(new_ops, ops->name);
+	NT_STATUS_HAVE_NO_MEMORY(new_ops->name);
 
 	backends[num_backends].ops = new_ops;
 

Modified: branches/SAMBA_4_0/source/lib/messaging/messaging.c
===================================================================
--- branches/SAMBA_4_0/source/lib/messaging/messaging.c	2007-09-09 12:02:51 UTC (rev 25046)
+++ branches/SAMBA_4_0/source/lib/messaging/messaging.c	2007-09-09 19:34:30 UTC (rev 25047)
@@ -137,7 +137,8 @@
 
 	/* temporary IDs use an idtree, the rest use a array of pointers */
 	if (rec->header->msg_type >= MSG_TMP_BASE) {
-		d = idr_find(msg->dispatch_tree, rec->header->msg_type);
+		d = (struct dispatch_fn *)idr_find(msg->dispatch_tree, 
+						   rec->header->msg_type);
 	} else if (rec->header->msg_type < msg->num_types) {
 		d = msg->dispatch[rec->header->msg_type];
 	} else {
@@ -417,7 +418,8 @@
 	struct dispatch_fn *d, *next;
 
 	if (msg_type >= msg->num_types) {
-		d = idr_find(msg->dispatch_tree, msg_type);
+		d = (struct dispatch_fn *)idr_find(msg->dispatch_tree, 
+						   msg_type);
 		if (!d) return;
 		idr_remove(msg->dispatch_tree, msg_type);
 		talloc_free(d);
@@ -666,7 +668,7 @@
 {
 	struct irpc_request *irpc;
 
-	irpc = idr_find(msg_ctx->idr, m->header.callid);
+	irpc = (struct irpc_request *)idr_find(msg_ctx->idr, m->header.callid);
 	if (irpc == NULL) return;
 
 	/* parse the reply data */

Modified: branches/SAMBA_4_0/source/lib/registry/local.c
===================================================================
--- branches/SAMBA_4_0/source/lib/registry/local.c	2007-09-09 12:02:51 UTC (rev 25046)
+++ branches/SAMBA_4_0/source/lib/registry/local.c	2007-09-09 19:34:30 UTC (rev 25047)
@@ -126,7 +126,8 @@
 WERROR local_get_predefined_key (const struct registry_context *ctx, 
 	  uint32_t key_id, struct registry_key **key) 
 {	
-	struct registry_local *rctx = talloc_get_type(ctx, struct registry_local);
+	struct registry_local *rctx = talloc_get_type(ctx, 
+						      struct registry_local);
 	struct mountpoint *mp;
 
 	for (mp = rctx->mountpoints; mp != NULL; mp = mp->next) {

Modified: branches/SAMBA_4_0/source/lib/registry/patchfile_preg.c
===================================================================
--- branches/SAMBA_4_0/source/lib/registry/patchfile_preg.c	2007-09-09 12:02:51 UTC (rev 25046)
+++ branches/SAMBA_4_0/source/lib/registry/patchfile_preg.c	2007-09-09 19:34:30 UTC (rev 25047)
@@ -211,8 +211,7 @@
 			close(fd);
 			return WERR_GENERAL_FAILURE;
 		}
-		data.length = length;
-		data.data = talloc_memdup(mem_ctx, buf, length);
+		data = data_blob_talloc(mem_ctx, buf, length);
 		
 		/* Check if delimiter is in place (whine if it isn't) */
 		buf_ptr = buf;

Modified: branches/SAMBA_4_0/source/lib/registry/regf.c
===================================================================
--- branches/SAMBA_4_0/source/lib/registry/regf.c	2007-09-09 12:02:51 UTC (rev 25046)
+++ branches/SAMBA_4_0/source/lib/registry/regf.c	2007-09-09 19:34:30 UTC (rev 25047)
@@ -1664,7 +1664,7 @@
 			DATA_BLOB value_list;
 
 			value_list.length = (nk->num_values+1)*4;
-			value_list.data = talloc_array(private_data, uint32_t, nk->num_values+1);
+			value_list.data = (uint8_t *)talloc_array(private_data, uint32_t, nk->num_values+1);
 			W_ERROR_HAVE_NO_MEMORY(value_list.data);
 			memcpy(value_list.data, values.data, nk->num_values * 4);
 

Modified: branches/SAMBA_4_0/source/lib/util/ms_fnmatch.c
===================================================================
--- branches/SAMBA_4_0/source/lib/util/ms_fnmatch.c	2007-09-09 12:02:51 UTC (rev 25046)
+++ branches/SAMBA_4_0/source/lib/util/ms_fnmatch.c	2007-09-09 19:34:30 UTC (rev 25047)
@@ -201,11 +201,10 @@
 		if (pattern[i] == '*' || pattern[i] == '<') count++;
 	}
 
-	max_n = talloc_array(NULL, struct max_n, count);
-	if (!max_n) {
+	max_n = talloc_zero_array(NULL, struct max_n, count);
+	if (max_n == NULL) {
 		return -1;
 	}
-	memset(max_n, 0, sizeof(struct max_n) * count);
 
 	ret = ms_fnmatch_core(pattern, string, max_n, strrchr(string, '.'));
 

Modified: branches/SAMBA_4_0/source/lib/util/util.h
===================================================================
--- branches/SAMBA_4_0/source/lib/util/util.h	2007-09-09 12:02:51 UTC (rev 25046)
+++ branches/SAMBA_4_0/source/lib/util/util.h	2007-09-09 19:34:30 UTC (rev 25047)
@@ -28,7 +28,6 @@
  * @brief Helpful macros
  */
 
-struct substitute_context;
 struct smbsrv_tcon;
 
 extern const char *logfile;
@@ -73,7 +72,7 @@
  */
 #define SMB_ASSERT(b) do { if (!(b)) { \
 	DEBUG(0,("PANIC: assert failed at %s(%d)\n", __FILE__, __LINE__)); \
-	smb_panic("assert failed"); abort(); }} while (0)
+	smb_panic("assert failed"); }} while (0)
 
 #ifndef SAFE_FREE /* Oh no this is also defined in tdb.h */
 /**
@@ -371,12 +370,6 @@
 _PUBLIC_ char *hex_encode_talloc(TALLOC_CTX *mem_ctx, const unsigned char *buff_in, size_t len);
 
 /**
- Set a string value, deallocating any existing space, and allocing the space
- for the string
-**/
-_PUBLIC_ bool string_set(TALLOC_CTX *mem_ctx, char **dest, const char *src);
-
-/**
  Substitute a string for a pattern in another string. Make sure there is 
  enough room!
 
@@ -780,8 +773,6 @@
 	PROTOCOL_SMB2
 };
 
-
-
 int ms_fnmatch(const char *pattern, const char *string, enum protocol_types protocol);
 
 /** a generic fnmatch function - uses for non-CIFS pattern matching */
@@ -838,6 +829,6 @@
 /**
  Become a daemon, discarding the controlling terminal.
 **/
-_PUBLIC_ void become_daemon(bool Fork);
+_PUBLIC_ void become_daemon(bool fork);
 
 #endif /* _SAMBA_UTIL_H_ */

Modified: branches/SAMBA_4_0/source/lib/util/util_pw.c
===================================================================
--- branches/SAMBA_4_0/source/lib/util/util_pw.c	2007-09-09 12:02:51 UTC (rev 25046)
+++ branches/SAMBA_4_0/source/lib/util/util_pw.c	2007-09-09 19:34:30 UTC (rev 25047)
@@ -21,38 +21,27 @@
 
 #include "includes.h"
 
-static struct passwd *alloc_copy_passwd(const struct passwd *from) 
+static struct passwd *alloc_copy_passwd(TALLOC_CTX *mem_ctx, 
+					const struct passwd *from) 
 {
-	struct passwd *ret = smb_xmalloc_p(struct passwd);
-	ZERO_STRUCTP(ret);
-	ret->pw_name = smb_xstrdup(from->pw_name);
-	ret->pw_passwd = smb_xstrdup(from->pw_passwd);
+	struct passwd *ret = talloc_zero(mem_ctx, struct passwd);
+
+	if (ret == NULL)
+		return NULL;
+
+	ret->pw_name = talloc_strdup(ret, from->pw_name);
+	ret->pw_passwd = talloc_strdup(ret, from->pw_passwd);
 	ret->pw_uid = from->pw_uid;
 	ret->pw_gid = from->pw_gid;
-	ret->pw_gecos = smb_xstrdup(from->pw_gecos);
-	ret->pw_dir = smb_xstrdup(from->pw_dir);
-	ret->pw_shell = smb_xstrdup(from->pw_shell);
+	ret->pw_gecos = talloc_strdup(ret, from->pw_gecos);
+	ret->pw_dir = talloc_strdup(ret, from->pw_dir);
+	ret->pw_shell = talloc_strdup(ret, from->pw_shell);
+
 	return ret;
 }
 
-void passwd_free (struct passwd **buf)
+struct passwd *getpwnam_alloc(TALLOC_CTX *mem_ctx, const char *name) 
 {
-	if (!*buf) {
-		DEBUG(0, ("attempted double-free of allocated passwd\n"));
-		return;
-	}
-
-	SAFE_FREE((*buf)->pw_name);
-	SAFE_FREE((*buf)->pw_passwd);
-	SAFE_FREE((*buf)->pw_gecos);
-	SAFE_FREE((*buf)->pw_dir);
-	SAFE_FREE((*buf)->pw_shell);
-
-	SAFE_FREE(*buf);
-}
-
-struct passwd *getpwnam_alloc(const char *name) 
-{
 	struct passwd *temp;
 
 	temp = sys_getpwnam(name);
@@ -66,10 +55,10 @@
 		return NULL;
 	}
 
-	return alloc_copy_passwd(temp);
+	return alloc_copy_passwd(mem_ctx, temp);
 }
 
-struct passwd *getpwuid_alloc(uid_t uid) 
+struct passwd *getpwuid_alloc(TALLOC_CTX *mem_ctx, uid_t uid) 
 {
 	struct passwd *temp;
 
@@ -84,5 +73,5 @@
 		return NULL;
 	}
 
-	return alloc_copy_passwd(temp);
+	return alloc_copy_passwd(mem_ctx, temp);
 }

Modified: branches/SAMBA_4_0/source/lib/util/util_str.c
===================================================================
--- branches/SAMBA_4_0/source/lib/util/util_str.c	2007-09-09 12:02:51 UTC (rev 25046)
+++ branches/SAMBA_4_0/source/lib/util/util_str.c	2007-09-09 19:34:30 UTC (rev 25047)
@@ -260,26 +260,6 @@
 }
 
 /**
- Set a string value, deallocating any existing space, and allocing the space
- for the string
-**/
-_PUBLIC_ bool string_set(TALLOC_CTX *mem_ctx, char **dest, const char *src)
-{
-	talloc_free(*dest);
-
-	if (src == NULL) 
-		src = "";
-
-	*dest = talloc_strdup(mem_ctx, src);
-	if ((*dest) == NULL) {
-		DEBUG(0,("Out of memory in string_init\n"));
-		return false;
-	}
-
-	return true;
-}
-
-/**
  Substitute a string for a pattern in another string. Make sure there is 
  enough room!
 

Modified: branches/SAMBA_4_0/source/libcli/libcli.h
===================================================================
--- branches/SAMBA_4_0/source/libcli/libcli.h	2007-09-09 12:02:51 UTC (rev 25046)
+++ branches/SAMBA_4_0/source/libcli/libcli.h	2007-09-09 19:34:30 UTC (rev 25047)
@@ -23,6 +23,8 @@
 
 #include "librpc/gen_ndr/nbt.h"
 
+struct substitute_context;
+
 /* 
    smbcli_state: internal state used in libcli library for single-threaded callers, 
    i.e. a single session on a single socket. 

Modified: branches/SAMBA_4_0/source/nsswitch/wb_common.c
===================================================================
--- branches/SAMBA_4_0/source/nsswitch/wb_common.c	2007-09-09 12:02:51 UTC (rev 25046)
+++ branches/SAMBA_4_0/source/nsswitch/wb_common.c	2007-09-09 19:34:30 UTC (rev 25047)
@@ -613,13 +613,13 @@
  enable them
  ************************************************************************/
  
-BOOL winbind_off( void )
+bool winbind_off( void )
 {
 	setenv(WINBINDD_DONT_ENV, "1", 1);
 	return True;
 }
 
-BOOL winbind_on( void )
+bool winbind_on( void )
 {
 	setenv(WINBINDD_DONT_ENV, "0", 1);
 	return True;

Modified: branches/SAMBA_4_0/source/param/loadparm.c
===================================================================
--- branches/SAMBA_4_0/source/param/loadparm.c	2007-09-09 12:02:51 UTC (rev 25046)
+++ branches/SAMBA_4_0/source/param/loadparm.c	2007-09-09 19:34:30 UTC (rev 25047)
@@ -1030,6 +1030,28 @@
 	return pservice;
 }
 
+/**
+ Set a string value, deallocating any existing space, and allocing the space
+ for the string
+**/
+static bool string_set(TALLOC_CTX *mem_ctx, char **dest, const char *src)
+{
+	talloc_free(*dest);
+
+	if (src == NULL) 
+		src = "";
+
+	*dest = talloc_strdup(mem_ctx, src);
+	if ((*dest) == NULL) {
+		DEBUG(0,("Out of memory in string_init\n"));
+		return false;
+	}
+
+	return true;
+}
+
+
+
 /***************************************************************************
  Add a new service to the services array initialising it with the given 
  service. 
@@ -2495,20 +2517,22 @@
  Return the max number of services.
 ***************************************************************************/
 
-int lp_numservices(struct loadparm_context *lp_ctx)
+int lp_numservices(void)
 {
-	return lp_ctx->iNumServices;
+	return loadparm.iNumServices;
 }
 
 /***************************************************************************
 Display the contents of the services array in human-readable form.
 ***************************************************************************/
 
-void lp_dump(FILE *f, bool show_defaults, int maxtoprint, 
-	     struct loadparm_context *lp_ctx)
+void lp_dump(FILE *f, bool show_defaults, int maxtoprint)
 {
+	struct loadparm_context *lp_ctx;
 	int iService;
 
+	lp_ctx = &loadparm;
+
 	if (show_defaults)
 		defaults_saved = false;
 

Modified: branches/SAMBA_4_0/source/param/share.c
===================================================================
--- branches/SAMBA_4_0/source/param/share.c	2007-09-09 12:02:51 UTC (rev 25046)
+++ branches/SAMBA_4_0/source/param/share.c	2007-09-09 19:34:30 UTC (rev 25047)
@@ -116,12 +116,7 @@
 		smb_panic("out of memory in share_register");
 	}
 
-	backends[i] = malloc(sizeof(struct share_ops));
-	if (!backends[i]) {
-		smb_panic("out of memory in share_register");
-	}
-
-	backends[i] = smb_xmemdup(ops, sizeof(*ops));
+	backends[i] = (struct share_ops *)smb_xmemdup(ops, sizeof(*ops));
 	backends[i]->name = smb_xstrdup(ops->name);
 
 	backends[i + 1] = NULL;

Modified: branches/SAMBA_4_0/source/utils/testparm.c
===================================================================
--- branches/SAMBA_4_0/source/utils/testparm.c	2007-09-09 12:02:51 UTC (rev 25046)
+++ branches/SAMBA_4_0/source/utils/testparm.c	2007-09-09 19:34:30 UTC (rev 25047)
@@ -151,7 +151,7 @@
 	ret = do_global_checks();
 
 	for (s=0;s<lp_numservices();s++) {
-		struct service *service = lp_servicebynum(s);
+		struct loadparm_service *service = lp_servicebynum(s);
 		if (service != NULL)
 			if (strlen(lp_servicename(lp_servicebynum(s))) > 12) {
 				fprintf(stderr, "WARNING: You have some share names that are longer than 12 characters.\n" );
@@ -162,7 +162,7 @@
 	}
 
 	for (s=0;s<lp_numservices();s++) {
-		struct service *service = lp_servicebynum(s);
+		struct loadparm_service *service = lp_servicebynum(s);
 		if (service != NULL) {
 			const char **deny_list = lp_hostsdeny(service);
 			const char **allow_list = lp_hostsallow(service);
@@ -199,7 +199,7 @@
 			getc(stdin);
 		}
 		if (section_name || parameter_name) {
-			struct service *service = NULL;
+			struct loadparm_service *service = NULL;
 			if (!section_name) {
 				section_name = GLOBAL_NAME;
 				service = NULL;
@@ -223,7 +223,7 @@
 	if(cname && caddr){
 		/* this is totally ugly, a real `quick' hack */
 		for (s=0;s<lp_numservices();s++) {
-			struct service *service = lp_servicebynum(s);
+			struct loadparm_service *service = lp_servicebynum(s);
 			if (service != NULL) {
 				if (allow_access(NULL, lp_hostsdeny(NULL), lp_hostsallow(NULL), cname, caddr)
 				    && allow_access(NULL, lp_hostsdeny(service), lp_hostsallow(service), cname, caddr)) {



More information about the samba-cvs mailing list