diff options
author | Timo Teräs <timo.teras@iki.fi> | 2021-07-17 19:17:46 +0300 |
---|---|---|
committer | Timo Teräs <timo.teras@iki.fi> | 2021-07-22 15:30:08 +0300 |
commit | 395e92b66e35ccbd2f07a4857d6da588ec9f51f2 (patch) | |
tree | 6680aad7ef26e8476a17548ffa05d9ff5c524942 /src/database.c | |
parent | 796d29831360c55d8b8b7d9aa5f33c817094c1bf (diff) | |
download | apk-tools-395e92b66e35ccbd2f07a4857d6da588ec9f51f2.tar.gz apk-tools-395e92b66e35ccbd2f07a4857d6da588ec9f51f2.tar.bz2 apk-tools-395e92b66e35ccbd2f07a4857d6da588ec9f51f2.tar.xz apk-tools-395e92b66e35ccbd2f07a4857d6da588ec9f51f2.zip |
io: formalize apk_ostream_write() always writing full data
Diffstat (limited to 'src/database.c')
-rw-r--r-- | src/database.c | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/src/database.c b/src/database.c index ef05047..b009f74 100644 --- a/src/database.c +++ b/src/database.c @@ -986,15 +986,16 @@ static int apk_db_write_fdb(struct apk_database *db, struct apk_ostream *os) apk_blob_push_blob(&bbuf, APK_BLOB_STR("\n")); } - if (apk_ostream_write(os, buf, bbuf.ptr - buf) != bbuf.ptr - buf) - return -EIO; + r = apk_ostream_write(os, buf, bbuf.ptr - buf); + if (r < 0) return r; bbuf = APK_BLOB_BUF(buf); } - if (apk_ostream_write(os, buf, bbuf.ptr - buf) != bbuf.ptr - buf) - return -EIO; + r = apk_ostream_write(os, buf, bbuf.ptr - buf); + if (r < 0) return r; bbuf = APK_BLOB_BUF(buf); } - apk_ostream_write(os, "\n", 1); + r = apk_ostream_write(os, "\n", 1); + if (r < 0) return r; } return 0; @@ -1194,11 +1195,10 @@ static int write_index_entry(apk_hash_item item, void *ctx) return 0; r = apk_pkg_write_index_entry(pkg, iwctx->os); - if (r < 0) - return r; + if (r < 0) return r; - if (apk_ostream_write(iwctx->os, "\n", 1) != 1) - return apk_ostream_cancel(iwctx->os, -EIO); + r = apk_ostream_write(iwctx->os, "\n", 1); + if (r < 0) return r; iwctx->count++; return 0; |