crypto: Make errp the last parameter of functions
Move opaque to 2nd instead of the 2nd to last, so that compilers help check with the conversion. Signed-off-by: Fam Zheng <famz@redhat.com> Message-Id: <20170421122710.15373-7-famz@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> [Commit message typo corrected] Signed-off-by: Markus Armbruster <armbru@redhat.com>
This commit is contained in:
parent
9217283dc8
commit
375092332e
@ -56,11 +56,11 @@ static int block_crypto_probe_generic(QCryptoBlockFormat format,
|
|||||||
|
|
||||||
|
|
||||||
static ssize_t block_crypto_read_func(QCryptoBlock *block,
|
static ssize_t block_crypto_read_func(QCryptoBlock *block,
|
||||||
|
void *opaque,
|
||||||
size_t offset,
|
size_t offset,
|
||||||
uint8_t *buf,
|
uint8_t *buf,
|
||||||
size_t buflen,
|
size_t buflen,
|
||||||
Error **errp,
|
Error **errp)
|
||||||
void *opaque)
|
|
||||||
{
|
{
|
||||||
BlockDriverState *bs = opaque;
|
BlockDriverState *bs = opaque;
|
||||||
ssize_t ret;
|
ssize_t ret;
|
||||||
@ -83,11 +83,11 @@ struct BlockCryptoCreateData {
|
|||||||
|
|
||||||
|
|
||||||
static ssize_t block_crypto_write_func(QCryptoBlock *block,
|
static ssize_t block_crypto_write_func(QCryptoBlock *block,
|
||||||
|
void *opaque,
|
||||||
size_t offset,
|
size_t offset,
|
||||||
const uint8_t *buf,
|
const uint8_t *buf,
|
||||||
size_t buflen,
|
size_t buflen,
|
||||||
Error **errp,
|
Error **errp)
|
||||||
void *opaque)
|
|
||||||
{
|
{
|
||||||
struct BlockCryptoCreateData *data = opaque;
|
struct BlockCryptoCreateData *data = opaque;
|
||||||
ssize_t ret;
|
ssize_t ret;
|
||||||
@ -102,9 +102,9 @@ static ssize_t block_crypto_write_func(QCryptoBlock *block,
|
|||||||
|
|
||||||
|
|
||||||
static ssize_t block_crypto_init_func(QCryptoBlock *block,
|
static ssize_t block_crypto_init_func(QCryptoBlock *block,
|
||||||
|
void *opaque,
|
||||||
size_t headerlen,
|
size_t headerlen,
|
||||||
Error **errp,
|
Error **errp)
|
||||||
void *opaque)
|
|
||||||
{
|
{
|
||||||
struct BlockCryptoCreateData *data = opaque;
|
struct BlockCryptoCreateData *data = opaque;
|
||||||
int ret;
|
int ret;
|
||||||
|
@ -473,10 +473,10 @@ qcrypto_block_luks_load_key(QCryptoBlock *block,
|
|||||||
* then encrypted.
|
* then encrypted.
|
||||||
*/
|
*/
|
||||||
rv = readfunc(block,
|
rv = readfunc(block,
|
||||||
|
opaque,
|
||||||
slot->key_offset * QCRYPTO_BLOCK_LUKS_SECTOR_SIZE,
|
slot->key_offset * QCRYPTO_BLOCK_LUKS_SECTOR_SIZE,
|
||||||
splitkey, splitkeylen,
|
splitkey, splitkeylen,
|
||||||
errp,
|
errp);
|
||||||
opaque);
|
|
||||||
if (rv < 0) {
|
if (rv < 0) {
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
@ -676,11 +676,10 @@ qcrypto_block_luks_open(QCryptoBlock *block,
|
|||||||
|
|
||||||
/* Read the entire LUKS header, minus the key material from
|
/* Read the entire LUKS header, minus the key material from
|
||||||
* the underlying device */
|
* the underlying device */
|
||||||
rv = readfunc(block, 0,
|
rv = readfunc(block, opaque, 0,
|
||||||
(uint8_t *)&luks->header,
|
(uint8_t *)&luks->header,
|
||||||
sizeof(luks->header),
|
sizeof(luks->header),
|
||||||
errp,
|
errp);
|
||||||
opaque);
|
|
||||||
if (rv < 0) {
|
if (rv < 0) {
|
||||||
ret = rv;
|
ret = rv;
|
||||||
goto fail;
|
goto fail;
|
||||||
@ -1246,7 +1245,7 @@ qcrypto_block_luks_create(QCryptoBlock *block,
|
|||||||
QCRYPTO_BLOCK_LUKS_SECTOR_SIZE;
|
QCRYPTO_BLOCK_LUKS_SECTOR_SIZE;
|
||||||
|
|
||||||
/* Reserve header space to match payload offset */
|
/* Reserve header space to match payload offset */
|
||||||
initfunc(block, block->payload_offset, &local_err, opaque);
|
initfunc(block, opaque, block->payload_offset, &local_err);
|
||||||
if (local_err) {
|
if (local_err) {
|
||||||
error_propagate(errp, local_err);
|
error_propagate(errp, local_err);
|
||||||
goto error;
|
goto error;
|
||||||
@ -1268,11 +1267,10 @@ qcrypto_block_luks_create(QCryptoBlock *block,
|
|||||||
|
|
||||||
|
|
||||||
/* Write out the partition header and key slot headers */
|
/* Write out the partition header and key slot headers */
|
||||||
writefunc(block, 0,
|
writefunc(block, opaque, 0,
|
||||||
(const uint8_t *)&luks->header,
|
(const uint8_t *)&luks->header,
|
||||||
sizeof(luks->header),
|
sizeof(luks->header),
|
||||||
&local_err,
|
&local_err);
|
||||||
opaque);
|
|
||||||
|
|
||||||
/* Delay checking local_err until we've byte-swapped */
|
/* Delay checking local_err until we've byte-swapped */
|
||||||
|
|
||||||
@ -1297,12 +1295,11 @@ qcrypto_block_luks_create(QCryptoBlock *block,
|
|||||||
|
|
||||||
/* Write out the master key material, starting at the
|
/* Write out the master key material, starting at the
|
||||||
* sector immediately following the partition header. */
|
* sector immediately following the partition header. */
|
||||||
if (writefunc(block,
|
if (writefunc(block, opaque,
|
||||||
luks->header.key_slots[0].key_offset *
|
luks->header.key_slots[0].key_offset *
|
||||||
QCRYPTO_BLOCK_LUKS_SECTOR_SIZE,
|
QCRYPTO_BLOCK_LUKS_SECTOR_SIZE,
|
||||||
splitkey, splitkeylen,
|
splitkey, splitkeylen,
|
||||||
errp,
|
errp) != splitkeylen) {
|
||||||
opaque) != splitkeylen) {
|
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,23 +30,23 @@ typedef struct QCryptoBlock QCryptoBlock;
|
|||||||
* and QCryptoBlockOpenOptions in qapi/crypto.json */
|
* and QCryptoBlockOpenOptions in qapi/crypto.json */
|
||||||
|
|
||||||
typedef ssize_t (*QCryptoBlockReadFunc)(QCryptoBlock *block,
|
typedef ssize_t (*QCryptoBlockReadFunc)(QCryptoBlock *block,
|
||||||
|
void *opaque,
|
||||||
size_t offset,
|
size_t offset,
|
||||||
uint8_t *buf,
|
uint8_t *buf,
|
||||||
size_t buflen,
|
size_t buflen,
|
||||||
Error **errp,
|
Error **errp);
|
||||||
void *opaque);
|
|
||||||
|
|
||||||
typedef ssize_t (*QCryptoBlockInitFunc)(QCryptoBlock *block,
|
typedef ssize_t (*QCryptoBlockInitFunc)(QCryptoBlock *block,
|
||||||
|
void *opaque,
|
||||||
size_t headerlen,
|
size_t headerlen,
|
||||||
Error **errp,
|
Error **errp);
|
||||||
void *opaque);
|
|
||||||
|
|
||||||
typedef ssize_t (*QCryptoBlockWriteFunc)(QCryptoBlock *block,
|
typedef ssize_t (*QCryptoBlockWriteFunc)(QCryptoBlock *block,
|
||||||
|
void *opaque,
|
||||||
size_t offset,
|
size_t offset,
|
||||||
const uint8_t *buf,
|
const uint8_t *buf,
|
||||||
size_t buflen,
|
size_t buflen,
|
||||||
Error **errp,
|
Error **errp);
|
||||||
void *opaque);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* qcrypto_block_has_format:
|
* qcrypto_block_has_format:
|
||||||
|
@ -187,11 +187,11 @@ static struct QCryptoBlockTestData {
|
|||||||
|
|
||||||
|
|
||||||
static ssize_t test_block_read_func(QCryptoBlock *block,
|
static ssize_t test_block_read_func(QCryptoBlock *block,
|
||||||
|
void *opaque,
|
||||||
size_t offset,
|
size_t offset,
|
||||||
uint8_t *buf,
|
uint8_t *buf,
|
||||||
size_t buflen,
|
size_t buflen,
|
||||||
Error **errp,
|
Error **errp)
|
||||||
void *opaque)
|
|
||||||
{
|
{
|
||||||
Buffer *header = opaque;
|
Buffer *header = opaque;
|
||||||
|
|
||||||
@ -204,9 +204,9 @@ static ssize_t test_block_read_func(QCryptoBlock *block,
|
|||||||
|
|
||||||
|
|
||||||
static ssize_t test_block_init_func(QCryptoBlock *block,
|
static ssize_t test_block_init_func(QCryptoBlock *block,
|
||||||
|
void *opaque,
|
||||||
size_t headerlen,
|
size_t headerlen,
|
||||||
Error **errp,
|
Error **errp)
|
||||||
void *opaque)
|
|
||||||
{
|
{
|
||||||
Buffer *header = opaque;
|
Buffer *header = opaque;
|
||||||
|
|
||||||
@ -219,11 +219,11 @@ static ssize_t test_block_init_func(QCryptoBlock *block,
|
|||||||
|
|
||||||
|
|
||||||
static ssize_t test_block_write_func(QCryptoBlock *block,
|
static ssize_t test_block_write_func(QCryptoBlock *block,
|
||||||
|
void *opaque,
|
||||||
size_t offset,
|
size_t offset,
|
||||||
const uint8_t *buf,
|
const uint8_t *buf,
|
||||||
size_t buflen,
|
size_t buflen,
|
||||||
Error **errp,
|
Error **errp)
|
||||||
void *opaque)
|
|
||||||
{
|
{
|
||||||
Buffer *header = opaque;
|
Buffer *header = opaque;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user