summaryrefslogtreecommitdiff
path: root/lib/tdb2/tdb1_check.c
diff options
context:
space:
mode:
authorRusty Russell <rusty@rustcorp.com.au>2011-09-14 08:13:26 +0930
committerRusty Russell <rusty@rustcorp.com.au>2011-09-14 08:13:26 +0930
commitef70f5dd35974115a85850d04b0f4b64e511659f (patch)
tree7904ff676e509cc4feec0887b8034f9c570eaaf1 /lib/tdb2/tdb1_check.c
parent6b11a2630123453a7f40f728641882c440b57010 (diff)
downloadsamba-ef70f5dd35974115a85850d04b0f4b64e511659f.tar.gz
samba-ef70f5dd35974115a85850d04b0f4b64e511659f.tar.bz2
samba-ef70f5dd35974115a85850d04b0f4b64e511659f.zip
tdb2: log allocation failures in tdb1 backend.
The TDB2 tests are stricter about this; they want every error logged. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> (Imported from CCAN commit 670ba98f74b52df541d153eeab9d3310932e75cd)
Diffstat (limited to 'lib/tdb2/tdb1_check.c')
-rw-r--r--lib/tdb2/tdb1_check.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/lib/tdb2/tdb1_check.c b/lib/tdb2/tdb1_check.c
index 4d71712c47..a8e54b2ee0 100644
--- a/lib/tdb2/tdb1_check.c
+++ b/lib/tdb2/tdb1_check.c
@@ -339,6 +339,7 @@ int tdb1_check(struct tdb_context *tdb,
bool found_recovery = false;
tdb1_len_t dead;
bool locked;
+ size_t alloc_len;
/* We may have a write lock already, so don't re-lock. */
if (tdb->file->allrecord_lock.count != 0) {
@@ -364,11 +365,13 @@ int tdb1_check(struct tdb_context *tdb,
}
/* One big malloc: pointers then bit arrays. */
- hashes = (unsigned char **)calloc(
- 1, sizeof(hashes[0]) * (1+tdb->tdb1.header.hash_size)
- + BITMAP_BITS / CHAR_BIT * (1+tdb->tdb1.header.hash_size));
+ alloc_len = sizeof(hashes[0]) * (1+tdb->tdb1.header.hash_size)
+ + BITMAP_BITS / CHAR_BIT * (1+tdb->tdb1.header.hash_size);
+ hashes = (unsigned char **)calloc(1, alloc_len);
if (!hashes) {
- tdb->last_error = TDB_ERR_OOM;
+ tdb->last_error = tdb_logerr(tdb, TDB_ERR_OOM, TDB_LOG_ERROR,
+ "tdb_check: could not allocate %zu",
+ alloc_len);
goto unlock;
}