[PATCHES] Various cleanups and minor restructuring

Volker Lendecke Volker.Lendecke at SerNet.DE
Fri Sep 19 09:04:13 MDT 2014


On Fri, Sep 19, 2014 at 07:29:59PM +1000, Martin Schwenke wrote:
> Review and push appreciated.  Thanks!

Pushed most of them.

I did not push the move of mkproto. I think we should not
depend on that for common code. I know we're not there, but
putting mkproto into common gives a bad signal.

For the talloc_tos removal I've got a different proposal.
See attached. If you prefer yours, you can for sure push it
with my R-b. It is certainly a correct patch.

Thanks a lot for working on this!

Volker

-- 
SerNet GmbH, Bahnhofsallee 1b, 37081 Göttingen
phone: +49-551-370000-0, fax: +49-551-370000-9
AG Göttingen, HRB 2816, GF: Dr. Johannes Loxen
http://www.sernet.de, mailto:kontakt at sernet.de
-------------- next part --------------
From 977348f760cc4315f6aeda3df2561b9611bd3c3d Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Fri, 19 Sep 2014 16:58:52 +0200
Subject: [PATCH] lib/util: Drop unnecessary use of talloc_tos()

Signed-off-by: Volker Lendecke <vl at samba.org>
---
 lib/util/util.c |   10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/lib/util/util.c b/lib/util/util.c
index ad38bf0..c771c95 100644
--- a/lib/util/util.c
+++ b/lib/util/util.c
@@ -61,7 +61,8 @@ _PUBLIC_ const char *tmpdir(void)
 **/
 int create_unlink_tmp(const char *dir)
 {
-	char *fname;
+	size_t len = strlen(dir);
+	char fname[len+25];
 	int fd;
 	mode_t mask;
 
@@ -69,8 +70,8 @@ int create_unlink_tmp(const char *dir)
 		dir = tmpdir();
 	}
 
-	fname = talloc_asprintf(talloc_tos(), "%s/listenerlock_XXXXXX", dir);
-	if (fname == NULL) {
+	len = snprintf(fname, sizeof(fname), "%s/listenerlock_XXXXXX", dir);
+	if (len >= sizeof(fname)) {
 		errno = ENOMEM;
 		return -1;
 	}
@@ -78,17 +79,14 @@ int create_unlink_tmp(const char *dir)
 	fd = mkstemp(fname);
 	umask(mask);
 	if (fd == -1) {
-		TALLOC_FREE(fname);
 		return -1;
 	}
 	if (unlink(fname) == -1) {
 		int sys_errno = errno;
 		close(fd);
-		TALLOC_FREE(fname);
 		errno = sys_errno;
 		return -1;
 	}
-	TALLOC_FREE(fname);
 	return fd;
 }
 
-- 
1.7.9.5



More information about the samba-technical mailing list