]> git.ozlabs.org Git - ccan/blobdiff - ccan/tdb2/io.c
tdb2: fix pread/pwrite error handling in fill and tdb_write.
[ccan] / ccan / tdb2 / io.c
index 866ff085bb5e87b6e3463e016aa7202e800c4708..11914b3c76b639f63e89442758e259b21aeeb5fe 100644 (file)
@@ -246,7 +246,7 @@ static enum TDB_ERROR tdb_write(struct tdb_context *tdb, tdb_off_t off,
        } else {
                ssize_t ret;
                ret = pwrite(tdb->fd, buf, len, off);
-               if (ret < len) {
+               if (ret != len) {
                        /* This shouldn't happen: we avoid sparse files. */
                        if (ret >= 0)
                                errno = ENOSPC;
@@ -375,7 +375,7 @@ static enum TDB_ERROR fill(struct tdb_context *tdb,
        while (len) {
                size_t n = len > size ? size : len;
                ssize_t ret = pwrite(tdb->fd, buf, n, off);
-               if (ret < n) {
+               if (ret != n) {
                        if (ret >= 0)
                                errno = ENOSPC;