qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] crypto: move 'opaque' parameter to (nearly) the end of parameter list
@ 2017-04-24 15:36 Daniel P. Berrange
  2017-04-24 15:46 ` Eric Blake
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Daniel P. Berrange @ 2017-04-24 15:36 UTC (permalink / raw)
  To: qemu-devel; +Cc: Fam Zheng, Markus Armbruster, Daniel P. Berrange

Previous commit moved 'opaque' to be the 2nd parameter in the list:

  commit 375092332eeaa6e47561ce47fd36144cdaf964d0
  Author: Fam Zheng <famz@redhat.com>
  Date:   Fri Apr 21 20:27:02 2017 +0800

    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.

this puts it back to the 2nd to last position.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
---
 block/crypto.c            |  6 +++---
 crypto/block-luks.c       | 13 ++++++++-----
 include/crypto/block.h    |  6 +++---
 tests/test-crypto-block.c |  6 +++---
 4 files changed, 17 insertions(+), 14 deletions(-)

diff --git a/block/crypto.c b/block/crypto.c
index 34549b2..2a6a805 100644
--- a/block/crypto.c
+++ b/block/crypto.c
@@ -56,10 +56,10 @@ static int block_crypto_probe_generic(QCryptoBlockFormat format,
 
 
 static ssize_t block_crypto_read_func(QCryptoBlock *block,
-                                      void *opaque,
                                       size_t offset,
                                       uint8_t *buf,
                                       size_t buflen,
+                                      void *opaque,
                                       Error **errp)
 {
     BlockDriverState *bs = opaque;
@@ -83,10 +83,10 @@ struct BlockCryptoCreateData {
 
 
 static ssize_t block_crypto_write_func(QCryptoBlock *block,
-                                       void *opaque,
                                        size_t offset,
                                        const uint8_t *buf,
                                        size_t buflen,
+                                       void *opaque,
                                        Error **errp)
 {
     struct BlockCryptoCreateData *data = opaque;
@@ -102,8 +102,8 @@ static ssize_t block_crypto_write_func(QCryptoBlock *block,
 
 
 static ssize_t block_crypto_init_func(QCryptoBlock *block,
-                                      void *opaque,
                                       size_t headerlen,
+                                      void *opaque,
                                       Error **errp)
 {
     struct BlockCryptoCreateData *data = opaque;
diff --git a/crypto/block-luks.c b/crypto/block-luks.c
index d5a31bb..2b97d89 100644
--- a/crypto/block-luks.c
+++ b/crypto/block-luks.c
@@ -473,9 +473,9 @@ qcrypto_block_luks_load_key(QCryptoBlock *block,
      * then encrypted.
      */
     rv = readfunc(block,
-                  opaque,
                   slot->key_offset * QCRYPTO_BLOCK_LUKS_SECTOR_SIZE,
                   splitkey, splitkeylen,
+                  opaque,
                   errp);
     if (rv < 0) {
         goto cleanup;
@@ -676,9 +676,10 @@ qcrypto_block_luks_open(QCryptoBlock *block,
 
     /* Read the entire LUKS header, minus the key material from
      * the underlying device */
-    rv = readfunc(block, opaque, 0,
+    rv = readfunc(block, 0,
                   (uint8_t *)&luks->header,
                   sizeof(luks->header),
+                  opaque,
                   errp);
     if (rv < 0) {
         ret = rv;
@@ -1245,7 +1246,7 @@ qcrypto_block_luks_create(QCryptoBlock *block,
         QCRYPTO_BLOCK_LUKS_SECTOR_SIZE;
 
     /* Reserve header space to match payload offset */
-    initfunc(block, opaque, block->payload_offset, &local_err);
+    initfunc(block, block->payload_offset, opaque, &local_err);
     if (local_err) {
         error_propagate(errp, local_err);
         goto error;
@@ -1267,9 +1268,10 @@ qcrypto_block_luks_create(QCryptoBlock *block,
 
 
     /* Write out the partition header and key slot headers */
-    writefunc(block, opaque, 0,
+    writefunc(block, 0,
               (const uint8_t *)&luks->header,
               sizeof(luks->header),
+              opaque,
               &local_err);
 
     /* Delay checking local_err until we've byte-swapped */
@@ -1295,10 +1297,11 @@ qcrypto_block_luks_create(QCryptoBlock *block,
 
     /* Write out the master key material, starting at the
      * sector immediately following the partition header. */
-    if (writefunc(block, opaque,
+    if (writefunc(block,
                   luks->header.key_slots[0].key_offset *
                   QCRYPTO_BLOCK_LUKS_SECTOR_SIZE,
                   splitkey, splitkeylen,
+                  opaque,
                   errp) != splitkeylen) {
         goto error;
     }
diff --git a/include/crypto/block.h b/include/crypto/block.h
index 4a053a3..013a435 100644
--- a/include/crypto/block.h
+++ b/include/crypto/block.h
@@ -30,22 +30,22 @@ typedef struct QCryptoBlock QCryptoBlock;
  * and QCryptoBlockOpenOptions in qapi/crypto.json */
 
 typedef ssize_t (*QCryptoBlockReadFunc)(QCryptoBlock *block,
-                                        void *opaque,
                                         size_t offset,
                                         uint8_t *buf,
                                         size_t buflen,
+                                        void *opaque,
                                         Error **errp);
 
 typedef ssize_t (*QCryptoBlockInitFunc)(QCryptoBlock *block,
-                                        void *opaque,
                                         size_t headerlen,
+                                        void *opaque,
                                         Error **errp);
 
 typedef ssize_t (*QCryptoBlockWriteFunc)(QCryptoBlock *block,
-                                         void *opaque,
                                          size_t offset,
                                          const uint8_t *buf,
                                          size_t buflen,
+                                         void *opaque,
                                          Error **errp);
 
 /**
diff --git a/tests/test-crypto-block.c b/tests/test-crypto-block.c
index 85e6603..95c4bd5 100644
--- a/tests/test-crypto-block.c
+++ b/tests/test-crypto-block.c
@@ -187,10 +187,10 @@ static struct QCryptoBlockTestData {
 
 
 static ssize_t test_block_read_func(QCryptoBlock *block,
-                                    void *opaque,
                                     size_t offset,
                                     uint8_t *buf,
                                     size_t buflen,
+                                    void *opaque,
                                     Error **errp)
 {
     Buffer *header = opaque;
@@ -204,8 +204,8 @@ static ssize_t test_block_read_func(QCryptoBlock *block,
 
 
 static ssize_t test_block_init_func(QCryptoBlock *block,
-                                    void *opaque,
                                     size_t headerlen,
+                                    void *opaque,
                                     Error **errp)
 {
     Buffer *header = opaque;
@@ -219,10 +219,10 @@ static ssize_t test_block_init_func(QCryptoBlock *block,
 
 
 static ssize_t test_block_write_func(QCryptoBlock *block,
-                                     void *opaque,
                                      size_t offset,
                                      const uint8_t *buf,
                                      size_t buflen,
+                                     void *opaque,
                                      Error **errp)
 {
     Buffer *header = opaque;
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] [PATCH] crypto: move 'opaque' parameter to (nearly) the end of parameter list
  2017-04-24 15:36 [Qemu-devel] [PATCH] crypto: move 'opaque' parameter to (nearly) the end of parameter list Daniel P. Berrange
@ 2017-04-24 15:46 ` Eric Blake
  2017-04-25  2:00 ` Fam Zheng
  2017-04-25  7:30 ` Markus Armbruster
  2 siblings, 0 replies; 5+ messages in thread
From: Eric Blake @ 2017-04-24 15:46 UTC (permalink / raw)
  To: Daniel P. Berrange, qemu-devel; +Cc: Fam Zheng, Markus Armbruster

[-- Attachment #1: Type: text/plain, Size: 743 bytes --]

On 04/24/2017 10:36 AM, Daniel P. Berrange wrote:
> Previous commit moved 'opaque' to be the 2nd parameter in the list:
> 
>   commit 375092332eeaa6e47561ce47fd36144cdaf964d0
>   Author: Fam Zheng <famz@redhat.com>
>   Date:   Fri Apr 21 20:27:02 2017 +0800
> 
>     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.
> 
> this puts it back to the 2nd to last position.
> 
> Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
> ---

Reviewed-by: Eric Blake <eblake@redhat.com>

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] [PATCH] crypto: move 'opaque' parameter to (nearly) the end of parameter list
  2017-04-24 15:36 [Qemu-devel] [PATCH] crypto: move 'opaque' parameter to (nearly) the end of parameter list Daniel P. Berrange
  2017-04-24 15:46 ` Eric Blake
@ 2017-04-25  2:00 ` Fam Zheng
  2017-04-25  7:30 ` Markus Armbruster
  2 siblings, 0 replies; 5+ messages in thread
From: Fam Zheng @ 2017-04-25  2:00 UTC (permalink / raw)
  To: Daniel P. Berrange; +Cc: qemu-devel, Markus Armbruster

On Mon, 04/24 16:36, Daniel P. Berrange wrote:
> Previous commit moved 'opaque' to be the 2nd parameter in the list:
> 
>   commit 375092332eeaa6e47561ce47fd36144cdaf964d0
>   Author: Fam Zheng <famz@redhat.com>
>   Date:   Fri Apr 21 20:27:02 2017 +0800
> 
>     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.
> 
> this puts it back to the 2nd to last position.
> 
> Signed-off-by: Daniel P. Berrange <berrange@redhat.com>

Reviewed-by: Fam Zheng <famz@redhat.com>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] [PATCH] crypto: move 'opaque' parameter to (nearly) the end of parameter list
  2017-04-24 15:36 [Qemu-devel] [PATCH] crypto: move 'opaque' parameter to (nearly) the end of parameter list Daniel P. Berrange
  2017-04-24 15:46 ` Eric Blake
  2017-04-25  2:00 ` Fam Zheng
@ 2017-04-25  7:30 ` Markus Armbruster
  2017-04-25  9:06   ` Daniel P. Berrange
  2 siblings, 1 reply; 5+ messages in thread
From: Markus Armbruster @ 2017-04-25  7:30 UTC (permalink / raw)
  To: Daniel P. Berrange; +Cc: qemu-devel, Fam Zheng

"Daniel P. Berrange" <berrange@redhat.com> writes:

> Previous commit moved 'opaque' to be the 2nd parameter in the list:
>
>   commit 375092332eeaa6e47561ce47fd36144cdaf964d0
>   Author: Fam Zheng <famz@redhat.com>
>   Date:   Fri Apr 21 20:27:02 2017 +0800
>
>     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.
>
> this puts it back to the 2nd to last position.
>
> Signed-off-by: Daniel P. Berrange <berrange@redhat.com>

I could take this through my tree, but I suggest you stick it into your
next crypto pull request.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] [PATCH] crypto: move 'opaque' parameter to (nearly) the end of parameter list
  2017-04-25  7:30 ` Markus Armbruster
@ 2017-04-25  9:06   ` Daniel P. Berrange
  0 siblings, 0 replies; 5+ messages in thread
From: Daniel P. Berrange @ 2017-04-25  9:06 UTC (permalink / raw)
  To: Markus Armbruster; +Cc: qemu-devel, Fam Zheng

On Tue, Apr 25, 2017 at 09:30:13AM +0200, Markus Armbruster wrote:
> "Daniel P. Berrange" <berrange@redhat.com> writes:
> 
> > Previous commit moved 'opaque' to be the 2nd parameter in the list:
> >
> >   commit 375092332eeaa6e47561ce47fd36144cdaf964d0
> >   Author: Fam Zheng <famz@redhat.com>
> >   Date:   Fri Apr 21 20:27:02 2017 +0800
> >
> >     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.
> >
> > this puts it back to the 2nd to last position.
> >
> > Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
> 
> I could take this through my tree, but I suggest you stick it into your
> next crypto pull request.

Yes, I'll submit it myself as I have a bunch of other stuff pending.


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 :|

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2017-04-25  9:06 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-04-24 15:36 [Qemu-devel] [PATCH] crypto: move 'opaque' parameter to (nearly) the end of parameter list Daniel P. Berrange
2017-04-24 15:46 ` Eric Blake
2017-04-25  2:00 ` Fam Zheng
2017-04-25  7:30 ` Markus Armbruster
2017-04-25  9:06   ` Daniel P. Berrange

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).