From d8cfca3a9bd2b6b6c562fd202377d95a98eb5472 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Thu, 5 May 2011 11:25:29 +0200 Subject: s3: only include tdb headers where needed. Guenther --- source3/lib/eventlog/eventlog.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source3/lib/eventlog/eventlog.c') diff --git a/source3/lib/eventlog/eventlog.c b/source3/lib/eventlog/eventlog.c index 4941199c5e..0ff0cb1fa8 100644 --- a/source3/lib/eventlog/eventlog.c +++ b/source3/lib/eventlog/eventlog.c @@ -24,6 +24,7 @@ #include "system/filesys.h" #include "lib/eventlog/eventlog.h" #include "../libcli/security/security.h" +#include "util_tdb.h" /* maintain a list of open eventlog tdbs with reference counts */ -- cgit From ad0a07c531fadd1639c5298951cfaf5cfe0cb10e Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Tue, 7 Jun 2011 11:44:43 +1000 Subject: s3-talloc Change TALLOC_ZERO_P() to talloc_zero() Using the standard macro makes it easier to move code into common, as TALLOC_ZERO_P isn't standard talloc. --- source3/lib/eventlog/eventlog.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/lib/eventlog/eventlog.c') diff --git a/source3/lib/eventlog/eventlog.c b/source3/lib/eventlog/eventlog.c index 0ff0cb1fa8..556938fe1d 100644 --- a/source3/lib/eventlog/eventlog.c +++ b/source3/lib/eventlog/eventlog.c @@ -416,7 +416,7 @@ ELOG_TDB *elog_open_tdb( const char *logname, bool force_clear, bool read_only ) return ptr; } - if ( !(tdb_node = TALLOC_ZERO_P( NULL, ELOG_TDB)) ) { + if ( !(tdb_node = talloc_zero( NULL, ELOG_TDB)) ) { DEBUG(0,("elog_open_tdb: talloc() failure!\n")); tdb_close( tdb ); return NULL; -- cgit From 058c4f84924c07b88ccaf3d617f3abff797a7cc8 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Mon, 20 Jun 2011 18:40:31 +0930 Subject: tdb_fetch_compat: use instead of tdb_fetch. This is a noop for tdb1. Signed-off-by: Rusty Russell --- source3/lib/eventlog/eventlog.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/lib/eventlog/eventlog.c') diff --git a/source3/lib/eventlog/eventlog.c b/source3/lib/eventlog/eventlog.c index 556938fe1d..b719c6f7f8 100644 --- a/source3/lib/eventlog/eventlog.c +++ b/source3/lib/eventlog/eventlog.c @@ -203,7 +203,7 @@ static bool make_way_for_eventlogs( TDB_CONTEXT * the_tdb, int32_t needed, /* read a record, add the amt to nbytes */ key.dsize = sizeof(int32_t); key.dptr = (unsigned char *)&i; - ret = tdb_fetch( the_tdb, key ); + ret = tdb_fetch_compat( the_tdb, key ); if ( ret.dsize == 0 ) { DEBUG( 8, ( "Can't find a record for the key, record [%d]\n", @@ -679,7 +679,7 @@ struct eventlog_Record_tdb *evlog_pull_record_tdb(TALLOC_CTX *mem_ctx, key.dptr = (unsigned char *)&srecno; key.dsize = sizeof(int32_t); - data = tdb_fetch(tdb, key); + data = tdb_fetch_compat(tdb, key); if (data.dsize == 0) { DEBUG(8,("evlog_pull_record_tdb: " "Can't find a record for the key, record %d\n", -- cgit From 6bc59d77b64d1ecbe5c906ed2fa80a7b8ca5d420 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Mon, 20 Jun 2011 18:40:31 +0930 Subject: tdb_store: check returns for 0, not -1. TDB2 returns a negative error number on failure. This is compatible if we always check for != 0 instead of == -1. Signed-off-by: Rusty Russell --- source3/lib/eventlog/eventlog.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/lib/eventlog/eventlog.c') diff --git a/source3/lib/eventlog/eventlog.c b/source3/lib/eventlog/eventlog.c index b719c6f7f8..c29c6f0ed4 100644 --- a/source3/lib/eventlog/eventlog.c +++ b/source3/lib/eventlog/eventlog.c @@ -804,13 +804,13 @@ NTSTATUS evlog_push_record_tdb(TALLOC_CTX *mem_ctx, ebuf.dptr = blob.data; ret = tdb_store(tdb, kbuf, ebuf, 0); - if (ret == -1) { + if (ret != 0) { tdb_unlock_bystring(tdb, EVT_NEXT_RECORD); return NT_STATUS_EVENTLOG_FILE_CORRUPT; } ret = tdb_store_int32(tdb, EVT_NEXT_RECORD, r->record_number + 1); - if (ret == -1) { + if (ret != 0) { tdb_unlock_bystring(tdb, EVT_NEXT_RECORD); return NT_STATUS_EVENTLOG_FILE_CORRUPT; } -- cgit From d925b327f4703cc141c0a7f3eec912dba8440880 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Mon, 20 Jun 2011 18:40:33 +0930 Subject: tdb_compat: Higher level API fixes. My previous patches fixed up all direct TDB callers, but there are a few utility functions and the db_context functions which are still using the old -1 / 0 return codes. It's clearer to fix up all the callers of these too, so everywhere is consistent: non-zero means an error. Signed-off-by: Rusty Russell --- source3/lib/eventlog/eventlog.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/lib/eventlog/eventlog.c') diff --git a/source3/lib/eventlog/eventlog.c b/source3/lib/eventlog/eventlog.c index c29c6f0ed4..67583b8666 100644 --- a/source3/lib/eventlog/eventlog.c +++ b/source3/lib/eventlog/eventlog.c @@ -781,7 +781,7 @@ NTSTATUS evlog_push_record_tdb(TALLOC_CTX *mem_ctx, /* lock */ ret = tdb_lock_bystring_with_timeout(tdb, EVT_NEXT_RECORD, 1); - if (ret == -1) { + if (ret != 0) { return NT_STATUS_LOCK_NOT_GRANTED; } -- cgit