[PATCH] two minor cleanups

Volker Lendecke Volker.Lendecke at SerNet.DE
Thu Nov 13 05:55:45 MST 2014


Hi!

I'd appreciate review&push!

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 3ce7337e9c66ea69e683520dc2d2d1ce7dd7e8c2 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Sun, 9 Nov 2014 12:50:53 +0000
Subject: [PATCH 1/2] registry: Slightly simplify tdb_data_is_cstr

Signed-off-by: Volker Lendecke <vl at samba.org>
---
 source3/registry/reg_backend_db.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/source3/registry/reg_backend_db.c b/source3/registry/reg_backend_db.c
index 67beb6a..44a3d9f 100644
--- a/source3/registry/reg_backend_db.c
+++ b/source3/registry/reg_backend_db.c
@@ -547,7 +547,7 @@ static bool tdb_data_is_cstr(TDB_DATA d) {
 	if (tdb_data_is_empty(d) || (d.dptr[d.dsize-1] != '\0')) {
 		return false;
 	}
-	return strchr((char *)d.dptr, '\0') == (char *)&d.dptr[d.dsize-1];
+	return strlen((char *)d.dptr) == (d.dsize-1);
 }
 
 static bool upgrade_v2_to_v3_check_subkeylist(struct db_context *db,
-- 
1.8.1.2


From 597c5b4bf810985d919f4e09067f279f267f1515 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Sun, 9 Nov 2014 12:48:09 +0000
Subject: [PATCH 2/2] lib: Slightly simplify strupper_m

toupper_ascii_fast_table is only referenced here, make it static.

Signed-off-by: Volker Lendecke <vl at samba.org>
---
 source3/include/smb_macros.h | 8 --------
 source3/lib/util_str.c       | 4 ++--
 2 files changed, 2 insertions(+), 10 deletions(-)

diff --git a/source3/include/smb_macros.h b/source3/include/smb_macros.h
index cd47950..42a9756 100644
--- a/source3/include/smb_macros.h
+++ b/source3/include/smb_macros.h
@@ -292,14 +292,6 @@ do { \
 #define ADD_TO_LARGE_ARRAY(mem_ctx, type, elem, array, num, size) \
 	add_to_large_array((mem_ctx), sizeof(type), &(elem), (void *)(array), (num), (size));
 
-#ifndef toupper_ascii_fast
-/* Warning - this must only be called with 0 <= c < 128. IT WILL
- * GIVE GARBAGE if c > 128 or c < 0. JRA.
- */
-extern const char toupper_ascii_fast_table[];
-#define toupper_ascii_fast(c) toupper_ascii_fast_table[(unsigned int)(c)];
-#endif
-
 #define trans_oob(bufsize, offset, length) \
 	smb_buffer_oob(bufsize, offset, length)
 
diff --git a/source3/lib/util_str.c b/source3/lib/util_str.c
index 2b0830c..3de64c6 100644
--- a/source3/lib/util_str.c
+++ b/source3/lib/util_str.c
@@ -25,7 +25,7 @@
 #include "includes.h"
 #include "lib/param/loadparm.h"
 
-const char toupper_ascii_fast_table[128] = {
+static const char toupper_ascii_fast_table[128] = {
 	0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf,
 	0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
 	0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
@@ -559,7 +559,7 @@ bool strupper_m(char *s)
 	   (ie. they match for the first 128 chars) */
 
 	while (*s && !(((unsigned char)s[0]) & 0x80)) {
-		*s = toupper_ascii_fast((unsigned char)*s);
+		*s = toupper_ascii_fast_table[(unsigned char)s[0]];
 		s++;
 	}
 
-- 
1.8.1.2



More information about the samba-technical mailing list