qemu-block
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-block] [PATCH v2 06/13] qcrypto-block: pass keyslot index rath


From: Daniel P . Berrangé
Subject: Re: [Qemu-block] [PATCH v2 06/13] qcrypto-block: pass keyslot index rather that pointer to the keyslot
Date: Fri, 6 Sep 2019 13:32:58 +0100
User-agent: Mutt/1.12.1 (2019-06-15)

On Mon, Aug 26, 2019 at 04:50:56PM +0300, Maxim Levitsky wrote:
> Another minor refactoring
> 
> Signed-off-by: Maxim Levitsky <address@hidden>
> ---
>  crypto/block-luks.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/crypto/block-luks.c b/crypto/block-luks.c
> index 331377293d..0d81f2ac61 100644
> --- a/crypto/block-luks.c
> +++ b/crypto/block-luks.c
> @@ -410,7 +410,7 @@ qcrypto_block_luks_essiv_cipher(QCryptoCipherAlgorithm 
> cipher,
>   */
>  static int
>  qcrypto_block_luks_load_key(QCryptoBlock *block,
> -                            QCryptoBlockLUKSKeySlot *slot,
> +                            unsigned int slot_idx,

FWIW, I tend to prefer 'size_t' for things which are array
indexes especially....

>                              const char *password,
>                              QCryptoCipherAlgorithm cipheralg,
>                              QCryptoCipherMode ciphermode,
> @@ -424,6 +424,7 @@ qcrypto_block_luks_load_key(QCryptoBlock *block,
>                              Error **errp)
>  {
>      QCryptoBlockLUKS *luks = block->opaque;
> +    const QCryptoBlockLUKSKeySlot *slot = &luks->header.key_slots[slot_idx];
>      g_autofree uint8_t *splitkey = NULL;
>      size_t splitkeylen;
>      g_autofree uint8_t *possiblekey = NULL;
> @@ -580,13 +581,12 @@ qcrypto_block_luks_find_key(QCryptoBlock *block,
>                              void *opaque,
>                              Error **errp)
>  {
> -    QCryptoBlockLUKS *luks = block->opaque;
>      size_t i;
>      int rv;
>  
>      for (i = 0; i < QCRYPTO_BLOCK_LUKS_NUM_KEY_SLOTS; i++) {
>          rv = qcrypto_block_luks_load_key(block,
> -                                         &luks->header.key_slots[i],
> +                                         i,

..given that 'i' is size_t here.

>                                           password,
>                                           cipheralg,
>                                           ciphermode,

With that type changed

Reviewed-by: Daniel P. Berrangé <address@hidden>


Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|



reply via email to

[Prev in Thread] Current Thread [Next in Thread]