summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/util/util_tdb.c4
-rw-r--r--lib/util/util_tdb.h1
-rw-r--r--source3/registry/reg_backend_db.c4
-rw-r--r--source3/utils/net_idmap_check.c17
-rw-r--r--source3/utils/net_registry_check.c4
5 files changed, 12 insertions, 18 deletions
diff --git a/lib/util/util_tdb.c b/lib/util/util_tdb.c
index 02c7095f66..0c30d7774d 100644
--- a/lib/util/util_tdb.c
+++ b/lib/util/util_tdb.c
@@ -46,6 +46,10 @@ bool tdb_data_equal(TDB_DATA t1, TDB_DATA t2)
return (memcmp(t1.dptr, t2.dptr, t1.dsize) == 0);
}
+bool tdb_data_is_empty(TDB_DATA d) {
+ return (d.dsize == 0) || (d.dptr == NULL);
+}
+
TDB_DATA string_tdb_data(const char *string)
{
return make_tdb_data((const uint8_t *)string, string ? strlen(string) : 0 );
diff --git a/lib/util/util_tdb.h b/lib/util/util_tdb.h
index 2d805d7d20..3d03b990c2 100644
--- a/lib/util/util_tdb.h
+++ b/lib/util/util_tdb.h
@@ -27,6 +27,7 @@
****************************************************************/
TDB_DATA make_tdb_data(const uint8_t *dptr, size_t dsize);
bool tdb_data_equal(TDB_DATA t1, TDB_DATA t2);
+bool tdb_data_is_empty(TDB_DATA d);
TDB_DATA string_tdb_data(const char *string);
TDB_DATA string_term_tdb_data(const char *string);
diff --git a/source3/registry/reg_backend_db.c b/source3/registry/reg_backend_db.c
index 06251e01f9..965d121649 100644
--- a/source3/registry/reg_backend_db.c
+++ b/source3/registry/reg_backend_db.c
@@ -541,10 +541,6 @@ static bool tdb_data_read_cstr(TDB_DATA *buf, char **result)
return false;
}
-static bool tdb_data_is_empty(TDB_DATA d) {
- return (d.dptr == NULL) || (d.dsize == 0);
-}
-
static bool tdb_data_is_cstr(TDB_DATA d) {
if (tdb_data_is_empty(d) || (d.dptr[d.dsize-1] != '\0')) {
return false;
diff --git a/source3/utils/net_idmap_check.c b/source3/utils/net_idmap_check.c
index b662a85792..3f9f3f53d9 100644
--- a/source3/utils/net_idmap_check.c
+++ b/source3/utils/net_idmap_check.c
@@ -43,9 +43,6 @@ static int traverse_check(struct db_record *rec, void* data);
static char* print_data(TALLOC_CTX* mem_ctx, TDB_DATA d);
static TDB_DATA parse_data(TALLOC_CTX* mem_ctx, const char** ptr);
static TDB_DATA talloc_copy(TALLOC_CTX* mem_ctx, TDB_DATA data);
-static bool is_empty(TDB_DATA data) {
- return (data.dsize == 0) || (data.dptr == NULL);
-}
/* record *********************************************************************/
@@ -275,10 +272,10 @@ static TDB_DATA_diff unpack_diff(TDB_DATA data) {
#define DEBUG_DIFF(LEV,MEM,MSG,KEY,OLD,NEW) \
DEBUG(LEV, ("%s: %s\n", MSG, print_data(MEM, KEY))); \
- if (!is_empty(OLD)) { \
+ if (!tdb_data_is_empty(OLD)) { \
DEBUGADD(LEV, ("-%s\n", print_data(MEM, OLD))); \
} \
- if (!is_empty(NEW)) { \
+ if (!tdb_data_is_empty(NEW)) { \
DEBUGADD(LEV, ("+%s\n", print_data(MEM, NEW))); \
}
@@ -501,7 +498,7 @@ int traverse_check(struct db_record *rec, void* data) {
}
if (!tdb_data_equal(key, r->key)) {
TDB_DATA oval = fetch_record(ctx, mem, r->key);
- if (!is_empty(oval) &&
+ if (!tdb_data_is_empty(oval) &&
!tdb_data_equal(oval, r->val))
{
action = get_action(&act->record_exists,
@@ -513,7 +510,7 @@ int traverse_check(struct db_record *rec, void* data) {
}
if (is_map(r)) {
TDB_DATA okey = fetch_record(ctx, mem, r->val);
- if (!is_empty(okey) &&
+ if (!tdb_data_is_empty(okey) &&
!tdb_data_equal(okey, r->key))
{
action = get_action(&act->record_exists,
@@ -566,7 +563,7 @@ TDB_DATA talloc_copy(TALLOC_CTX* mem_ctx, TDB_DATA data) {
}
static bool is_cstr(TDB_DATA str) {
- return !is_empty(str) && str.dptr[str.dsize-1] == '\0';
+ return !tdb_data_is_empty(str) && str.dptr[str.dsize-1] == '\0';
}
static bool parse_sid (TDB_DATA str, enum DT* type, struct dom_sid* sid) {
@@ -666,7 +663,7 @@ struct record* reverse_record(struct record* in)
char* print_data(TALLOC_CTX* mem_ctx, TDB_DATA d)
{
- if (!is_empty(d)) {
+ if (!tdb_data_is_empty(d)) {
char* ret = NULL;
cbuf* ost = cbuf_new(mem_ctx);
int len = cbuf_print_quoted(ost, (const char*)d.dptr, d.dsize);
@@ -753,7 +750,7 @@ static int traverse_commit(struct db_record *diff_rec, void* data) {
DEBUG_DIFF(0, mem, "Commit", key, diff.oval, diff.nval);
- if (is_empty(diff.nval)) {
+ if (tdb_data_is_empty(diff.nval)) {
status = dbwrap_record_delete(rec);
} else {
status = dbwrap_record_store(rec, diff.nval, 0);
diff --git a/source3/utils/net_registry_check.c b/source3/utils/net_registry_check.c
index ce7032ab64..9dca2192b6 100644
--- a/source3/utils/net_registry_check.c
+++ b/source3/utils/net_registry_check.c
@@ -207,10 +207,6 @@ static bool tdb_data_read_regval(TDB_DATA *buf, struct regval *result)
return true;
}
-static bool tdb_data_is_empty(TDB_DATA d) {
- return (d.dptr == NULL) || (d.dsize == 0);
-}
-
static bool tdb_data_is_cstr(TDB_DATA d) {
if (tdb_data_is_empty(d)) {
return false;