svn commit: samba r6640 - in branches/SAMBA_3_0/source: torture utils

vlendec at samba.org vlendec at samba.org
Sat May 7 06:59:01 GMT 2005


Author: vlendec
Date: 2005-05-07 06:59:00 +0000 (Sat, 07 May 2005)
New Revision: 6640

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

Log:
Attempt to fix 'make everything' with the paranoid malloc checker.

Volker

Modified:
   branches/SAMBA_3_0/source/torture/cmd_vfs.c
   branches/SAMBA_3_0/source/torture/locktest.c
   branches/SAMBA_3_0/source/torture/locktest2.c
   branches/SAMBA_3_0/source/torture/nbio.c
   branches/SAMBA_3_0/source/torture/nsstest.c
   branches/SAMBA_3_0/source/torture/vfstest.c
   branches/SAMBA_3_0/source/utils/log2pcaphex.c


Changeset:
Modified: branches/SAMBA_3_0/source/torture/cmd_vfs.c
===================================================================
--- branches/SAMBA_3_0/source/torture/cmd_vfs.c	2005-05-07 06:46:37 UTC (rev 6639)
+++ branches/SAMBA_3_0/source/torture/cmd_vfs.c	2005-05-07 06:59:00 UTC (rev 6640)
@@ -284,7 +284,7 @@
 		return NT_STATUS_UNSUCCESSFUL;
 	}
 
-	vfs->files[fd] = (struct files_struct *)malloc(sizeof(struct files_struct));
+	vfs->files[fd] = SMB_MALLOC_P(struct files_struct);
 	vfs->files[fd]->fsp_name = SMB_STRDUP(argv[1]);
 	vfs->files[fd]->fd = fd;
 	vfs->files[fd]->conn = vfs->conn;

Modified: branches/SAMBA_3_0/source/torture/locktest.c
===================================================================
--- branches/SAMBA_3_0/source/torture/locktest.c	2005-05-07 06:46:37 UTC (rev 6639)
+++ branches/SAMBA_3_0/source/torture/locktest.c	2005-05-07 06:59:00 UTC (rev 6640)
@@ -423,7 +423,7 @@
 	ZERO_STRUCT(fnum);
 	ZERO_STRUCT(cli);
 
-	recorded = (struct record *)malloc(sizeof(*recorded) * numops);
+	recorded = SMB_MALLOC_ARRAY(struct record, numops);
 
 	for (n=0; n<numops; n++) {
 #if PRESETS

Modified: branches/SAMBA_3_0/source/torture/locktest2.c
===================================================================
--- branches/SAMBA_3_0/source/torture/locktest2.c	2005-05-07 06:46:37 UTC (rev 6639)
+++ branches/SAMBA_3_0/source/torture/locktest2.c	2005-05-07 06:59:00 UTC (rev 6640)
@@ -373,7 +373,7 @@
 	ZERO_STRUCT(fnum);
 	ZERO_STRUCT(cli);
 
-	recorded = (struct record *)malloc(sizeof(*recorded) * numops);
+	recorded = SMB_MALLOC_ARRAY(struct record, numops);
 
 	for (n=0; n<numops; n++) {
 		recorded[n].conn = random() % NCONNECTIONS;

Modified: branches/SAMBA_3_0/source/torture/nbio.c
===================================================================
--- branches/SAMBA_3_0/source/torture/nbio.c	2005-05-07 06:46:37 UTC (rev 6639)
+++ branches/SAMBA_3_0/source/torture/nbio.c	2005-05-07 06:59:00 UTC (rev 6640)
@@ -281,7 +281,7 @@
 	char *s, *n;
 	if (finfo->name[0] == '.') return;
 
-	n = strdup(name);
+	n = SMB_STRDUP(name);
 	n[strlen(n)-1] = 0;
 	asprintf(&s, "%s%s", n, finfo->name);
 	if (finfo->mode & aDIR) {

Modified: branches/SAMBA_3_0/source/torture/nsstest.c
===================================================================
--- branches/SAMBA_3_0/source/torture/nsstest.c	2005-05-07 06:46:37 UTC (rev 6639)
+++ branches/SAMBA_3_0/source/torture/nsstest.c	2005-05-07 06:59:00 UTC (rev 6640)
@@ -167,13 +167,13 @@
 		return NULL;
 
 	if (!buf) 
-		buf = malloc(buflen);
+		buf = SMB_MALLOC(buflen);
 
 again:	
 	status = _nss_getgrent_r(&grp, buf, buflen, &nss_errno);
 	if (status == NSS_STATUS_TRYAGAIN) {
 		buflen *= 2;
-		buf = realloc(buf, buflen);
+		buf = SMB_REALLOC(buf, buflen);
 		goto again;
 	}
 	if (status == NSS_STATUS_NOTFOUND) {
@@ -199,12 +199,12 @@
 		return NULL;
 
 	if (!buf) 
-		buf = malloc(buflen);
+		buf = SMB_MALLOC(buflen);
 again:	
 	status = _nss_getgrnam_r(name, &grp, buf, buflen, &nss_errno);
 	if (status == NSS_STATUS_TRYAGAIN) {
 		buflen *= 2;
-		buf = realloc(buf, buflen);
+		buf = SMB_REALLOC(buf, buflen);
 		goto again;
 	}
 	if (status == NSS_STATUS_NOTFOUND) {
@@ -230,13 +230,13 @@
 		return NULL;
 
 	if (!buf) 
-		buf = malloc(buflen);
+		buf = SMB_MALLOC(buflen);
 
 again:	
 	status = _nss_getgrgid_r(gid, &grp, buf, buflen, &nss_errno);
 	if (status == NSS_STATUS_TRYAGAIN) {
 		buflen *= 2;
-		buf = realloc(buf, buflen);
+		buf = SMB_REALLOC(buf, buflen);
 		goto again;
 	}
 	if (status == NSS_STATUS_NOTFOUND) {
@@ -333,7 +333,7 @@
 	int i;
 	NSS_STATUS status;
 
-	groups = (gid_t *)malloc(size * sizeof(gid_t));
+	groups = SMB_MALLOC_ARRAY(gid_t, size);
 	groups[0] = gid;
 
 	status = nss_initgroups(name, gid, &groups, &start, &size);

Modified: branches/SAMBA_3_0/source/torture/vfstest.c
===================================================================
--- branches/SAMBA_3_0/source/torture/vfstest.c	2005-05-07 06:46:37 UTC (rev 6639)
+++ branches/SAMBA_3_0/source/torture/vfstest.c	2005-05-07 06:59:00 UTC (rev 6640)
@@ -52,10 +52,10 @@
 	if (!commands) 
 		return NULL;
 
-	matches = (char **)malloc(sizeof(matches[0])*MAX_COMPLETIONS);
+	matches = SMB_MALLOC_ARRAY(char *, MAX_COMPLETIONS);
 	if (!matches) return NULL;
 
-	matches[count++] = strdup(text);
+	matches[count++] = SMB_STRDUP(text);
 	if (!matches[0]) return NULL;
 
 	while (commands && count < MAX_COMPLETIONS-1) 
@@ -68,7 +68,7 @@
 			if ((strncmp(text, commands->cmd_set[i].name, strlen(text)) == 0) &&
 				commands->cmd_set[i].fn) 
 			{
-				matches[count] = strdup(commands->cmd_set[i].name);
+				matches[count] = SMB_STRDUP(commands->cmd_set[i].name);
 				if (!matches[count]) 
 					return NULL;
 				count++;
@@ -81,7 +81,7 @@
 
 	if (count == 2) {
 		SAFE_FREE(matches[0]);
-		matches[0] = strdup(matches[1]);
+		matches[0] = SMB_STRDUP(matches[1]);
 	}
 	matches[count] = NULL;
 	return matches;
@@ -248,7 +248,7 @@
 {
 	struct cmd_list *entry;
 
-	if (!(entry = (struct cmd_list *)malloc(sizeof(struct cmd_list)))) {
+	if (!(entry = SMB_MALLOC_P(struct cmd_list))) {
 		DEBUG(0, ("out of memory\n"));
 		return;
 	}
@@ -274,7 +274,7 @@
  again:
 	while(next_token(&p, buf, " ", sizeof(buf))) {
 		if (argv) {
-			argv[argc] = strdup(buf);
+			argv[argc] = SMB_STRDUP(buf);
 		}
 		
 		argc++;
@@ -284,7 +284,7 @@
 
 		/* Create argument list */
 
-		argv = (char **)malloc(sizeof(char *) * argc);
+		argv = SMB_MALLOC_ARRAY(char *, argc);
 		memset(argv, 0, sizeof(char *) * argc);
 
 		if (!argv) {

Modified: branches/SAMBA_3_0/source/utils/log2pcaphex.c
===================================================================
--- branches/SAMBA_3_0/source/utils/log2pcaphex.c	2005-05-07 06:46:37 UTC (rev 6639)
+++ branches/SAMBA_3_0/source/utils/log2pcaphex.c	2005-05-07 06:59:00 UTC (rev 6640)
@@ -29,6 +29,11 @@
 */
 
 #include "includes.h"
+
+/* We don't care about the paranoid malloc checker in this standalone
+   program */
+#undef malloc
+
 #include <assert.h>
 
 int quiet = 0;



More information about the samba-cvs mailing list