[PATCH] pdb_tdb: Use fstr_sprintf

Volker Lendecke Volker.Lendecke at SerNet.DE
Tue Jul 21 08:38:00 UTC 2015


Hi!

Review&push appreciated!

Thanks,

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 8e7a848fe554e6e616433d229c530c3c25650d06 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Tue, 21 Jul 2015 10:36:09 +0200
Subject: [PATCH] pdb_tdb: Use fstr_sprintf

Saves 160 bytes of .text

Signed-off-by: Volker Lendecke <vl at samba.org>
---
 source3/passdb/pdb_tdb.c |   17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/source3/passdb/pdb_tdb.c b/source3/passdb/pdb_tdb.c
index 2e97ba4..74a2792 100644
--- a/source3/passdb/pdb_tdb.c
+++ b/source3/passdb/pdb_tdb.c
@@ -584,7 +584,7 @@ static NTSTATUS tdbsam_getsampwnam (struct pdb_methods *my_methods,
 	}
 
 	/* set search key */
-	slprintf(keystr, sizeof(keystr)-1, "%s%s", USERPREFIX, name);
+	fstr_sprintf(keystr, "%s%s", USERPREFIX, name);
 
 	/* open the database */
 
@@ -642,7 +642,7 @@ static NTSTATUS tdbsam_getsampwrid (struct pdb_methods *my_methods,
 
 	/* set search key */
 
-	slprintf(keystr, sizeof(keystr)-1, "%s%.8x", RIDPREFIX, rid);
+	fstr_sprintf(keystr, "%s%.8x", RIDPREFIX, rid);
 
 	/* open the database */
 
@@ -689,7 +689,7 @@ static bool tdb_delete_samacct_only( struct samu *sam_pass )
 
   	/* set the search key */
 
-	slprintf(keystr, sizeof(keystr)-1, "%s%s", USERPREFIX, name);
+	fstr_sprintf(keystr, "%s%s", USERPREFIX, name);
 
 	/* it's outaa here!  8^) */
 	if ( !tdbsam_open( tdbsam_filename ) ) {
@@ -735,7 +735,7 @@ static NTSTATUS tdbsam_delete_sam_account(struct pdb_methods *my_methods,
 
   	/* set the search key */
 
-	slprintf(keystr, sizeof(keystr)-1, "%s%s", USERPREFIX, name);
+	fstr_sprintf(keystr, "%s%s", USERPREFIX, name);
 
 	rid = pdb_get_user_rid(sam_pass);
 
@@ -755,7 +755,7 @@ static NTSTATUS tdbsam_delete_sam_account(struct pdb_methods *my_methods,
 
   	/* set the search key */
 
-	slprintf(keystr, sizeof(keystr)-1, "%s%.8x", RIDPREFIX, rid);
+	fstr_sprintf(keystr, "%s%.8x", RIDPREFIX, rid);
 
 	/* it's outaa here!  8^) */
 
@@ -813,7 +813,7 @@ static bool tdb_update_samacct_only( struct samu* newpwd, int flag )
 		  pdb_get_user_rid(newpwd)));
 
   	/* setup the USER index key */
-	slprintf(keystr, sizeof(keystr)-1, "%s%s", USERPREFIX, name);
+	fstr_sprintf(keystr, "%s%s", USERPREFIX, name);
 
 	/* add the account */
 
@@ -852,8 +852,7 @@ static bool tdb_update_ridrec_only( struct samu* newpwd, int flag )
 	data = string_term_tdb_data(name);
 
 	/* setup the RID index key */
-	slprintf(keystr, sizeof(keystr)-1, "%s%.8x", RIDPREFIX,
-		 pdb_get_user_rid(newpwd));
+	fstr_sprintf(keystr, "%s%.8x", RIDPREFIX, pdb_get_user_rid(newpwd));
 
 	/* add the reference */
 	status = dbwrap_store_bystring(db_sam, keystr, data, flag);
@@ -933,7 +932,7 @@ static bool tdb_update_sam(struct pdb_methods *my_methods, struct samu* newpwd,
 
 		/* Delete old RID key */
 		DEBUG(10, ("tdb_update_sam: Deleting key for RID %u\n", oldrid));
-		slprintf(keystr, sizeof(keystr) - 1, "%s%.8x", RIDPREFIX, oldrid);
+		fstr_sprintf(keystr, "%s%.8x", RIDPREFIX, oldrid);
 		if (!NT_STATUS_IS_OK(dbwrap_delete_bystring(db_sam, keystr))) {
 			DEBUG(0, ("tdb_update_sam: Can't delete %s\n", keystr));
 			goto cancel;
-- 
1.7.9.5



More information about the samba-technical mailing list