X-Git-Url: https://git.ozlabs.org/?p=ccan;a=blobdiff_plain;f=ccan%2Ftdb2%2Fio.c;h=f326d98ba6d03e4c49e37409ae61280ae8a894bb;hp=3c24be6774a3f0a4b841809e5a20a9cfe7f417da;hb=2a585ebca2a23c536520d854749fc6a813e9b12a;hpb=587982955ca9c61363d6e3004622ee97eda80e4b diff --git a/ccan/tdb2/io.c b/ccan/tdb2/io.c index 3c24be67..f326d98b 100644 --- a/ccan/tdb2/io.c +++ b/ccan/tdb2/io.c @@ -70,6 +70,7 @@ void tdb_mmap(struct tdb_context *tdb) static int tdb_oob(struct tdb_context *tdb, tdb_off_t len, bool probe) { struct stat st; + enum TDB_ERROR ecode; /* We can't hold pointers during this: we could unmap! */ assert(!tdb->direct_access @@ -89,8 +90,11 @@ static int tdb_oob(struct tdb_context *tdb, tdb_off_t len, bool probe) return -1; } - if (tdb_lock_expand(tdb, F_RDLCK) != 0) + ecode = tdb_lock_expand(tdb, F_RDLCK); + if (ecode != TDB_SUCCESS) { + tdb->ecode = ecode; return -1; + } if (fstat(tdb->fd, &st) != 0) { tdb_logerr(tdb, TDB_ERR_IO, TDB_LOG_ERROR, @@ -400,7 +404,7 @@ static int tdb_expand_file(struct tdb_context *tdb, tdb_len_t addition) file isn't sparse, which would be very bad if we ran out of disk. This must be done with write, not via mmap */ memset(buf, 0x43, sizeof(buf)); - if (0 || fill(tdb, buf, sizeof(buf), tdb->map_size, addition) == -1) + if (fill(tdb, buf, sizeof(buf), tdb->map_size, addition) == -1) return -1; tdb->map_size += addition; tdb_mmap(tdb);