Commit 9faf1743 authored by Rusty Russell's avatar Rusty Russell

tdb2: fix valgrind warnings.

The unreserved headers were a real bug; the others could cause a false error too.
parent 6c69b9ba
...@@ -255,13 +255,18 @@ static int tdb_nest_lock(struct tdb_context *tdb, tdb_off_t offset, int ltype, ...@@ -255,13 +255,18 @@ static int tdb_nest_lock(struct tdb_context *tdb, tdb_off_t offset, int ltype,
{ {
struct tdb_lock_type *new_lck; struct tdb_lock_type *new_lck;
if (offset >= TDB_HASH_LOCK_START + (1ULL << tdb->header.v.hash_bits) /* Header is not valid for open lock; valgrind complains. */
+ (tdb->header.v.num_zones * (tdb->header.v.free_buckets+1))) { if (offset >= TDB_HASH_LOCK_START) {
tdb->ecode = TDB_ERR_LOCK; if (offset > TDB_HASH_LOCK_START
tdb->log(tdb, TDB_DEBUG_FATAL, tdb->log_priv, + (1ULL << tdb->header.v.hash_bits)
"tdb_lock: invalid offset %llu for ltype=%d\n", + (tdb->header.v.num_zones
(long long)offset, ltype); * (tdb->header.v.free_buckets+1))) {
return -1; tdb->ecode = TDB_ERR_LOCK;
tdb->log(tdb, TDB_DEBUG_FATAL, tdb->log_priv,
"tdb_lock: invalid offset %llu ltype=%d\n",
(long long)offset, ltype);
return -1;
}
} }
if (tdb->flags & TDB_NOLOCK) if (tdb->flags & TDB_NOLOCK)
return 0; return 0;
......
...@@ -147,7 +147,7 @@ static int tdb_new_database(struct tdb_context *tdb) ...@@ -147,7 +147,7 @@ static int tdb_new_database(struct tdb_context *tdb)
sizeof(newdb.hdr.hash_test), sizeof(newdb.hdr.hash_test),
newdb.hdr.hash_seed, newdb.hdr.hash_seed,
tdb->hash_priv); tdb->hash_priv);
memset(newdb.hdr.reserved, 0, sizeof(newdb.hdr.reserved));
newdb.hdr.v.generation = 0; newdb.hdr.v.generation = 0;
/* The initial zone must cover the initial database size! */ /* The initial zone must cover the initial database size! */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment