aboutsummaryrefslogtreecommitdiff
path: root/tests/unit
diff options
context:
space:
mode:
authorAlberto Faria <afaria@redhat.com>2022-06-09 16:27:38 +0100
committerHanna Reitz <hreitz@redhat.com>2022-07-12 12:14:55 +0200
commit757dda54b43867936012970a1b457f3d16e7398d (patch)
tree2d0997e452b2c62a2bc42a4ab249642cce5076ce /tests/unit
parent353a5d84b25c335b259f37c4f43dad96e6d60ba8 (diff)
downloadqemu-757dda54b43867936012970a1b457f3d16e7398d.zip
qemu-757dda54b43867936012970a1b457f3d16e7398d.tar.gz
qemu-757dda54b43867936012970a1b457f3d16e7398d.tar.bz2
crypto: Make block callbacks return 0 on success
They currently return the value of their headerlen/buflen parameter on success. Returning 0 instead makes it clear that short reads/writes are not possible. Signed-off-by: Alberto Faria <afaria@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> Message-Id: <20220609152744.3891847-5-afaria@redhat.com> Reviewed-by: Hanna Reitz <hreitz@redhat.com> Signed-off-by: Hanna Reitz <hreitz@redhat.com>
Diffstat (limited to 'tests/unit')
-rw-r--r--tests/unit/test-crypto-block.c38
1 files changed, 19 insertions, 19 deletions
diff --git a/tests/unit/test-crypto-block.c b/tests/unit/test-crypto-block.c
index 3b1f0d5..3417b67 100644
--- a/tests/unit/test-crypto-block.c
+++ b/tests/unit/test-crypto-block.c
@@ -188,12 +188,12 @@ static struct QCryptoBlockTestData {
};
-static ssize_t test_block_read_func(QCryptoBlock *block,
- size_t offset,
- uint8_t *buf,
- size_t buflen,
- void *opaque,
- Error **errp)
+static int test_block_read_func(QCryptoBlock *block,
+ size_t offset,
+ uint8_t *buf,
+ size_t buflen,
+ void *opaque,
+ Error **errp)
{
Buffer *header = opaque;
@@ -201,14 +201,14 @@ static ssize_t test_block_read_func(QCryptoBlock *block,
memcpy(buf, header->buffer + offset, buflen);
- return buflen;
+ return 0;
}
-static ssize_t test_block_init_func(QCryptoBlock *block,
- size_t headerlen,
- void *opaque,
- Error **errp)
+static int test_block_init_func(QCryptoBlock *block,
+ size_t headerlen,
+ void *opaque,
+ Error **errp)
{
Buffer *header = opaque;
@@ -216,16 +216,16 @@ static ssize_t test_block_init_func(QCryptoBlock *block,
buffer_reserve(header, headerlen);
- return headerlen;
+ return 0;
}
-static ssize_t test_block_write_func(QCryptoBlock *block,
- size_t offset,
- const uint8_t *buf,
- size_t buflen,
- void *opaque,
- Error **errp)
+static int test_block_write_func(QCryptoBlock *block,
+ size_t offset,
+ const uint8_t *buf,
+ size_t buflen,
+ void *opaque,
+ Error **errp)
{
Buffer *header = opaque;
@@ -234,7 +234,7 @@ static ssize_t test_block_write_func(QCryptoBlock *block,
memcpy(header->buffer + offset, buf, buflen);
header->offset = offset + buflen;
- return buflen;
+ return 0;
}