diff mbox series

[01/13] block-crypto: misc refactoring

Message ID 20190814202219.1870-2-mlevitsk@redhat.com
State New
Headers show
Series RFC: luks/encrypted qcow2 key management | expand

Commit Message

Maxim Levitsky Aug. 14, 2019, 8:22 p.m. UTC
* rename the write_func to create_write_func,
  and init_func to create_init_func
  this is  preparation for other write_func that will
  be used to update the encryption keys.

No functional changes

Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com>
---
 block/crypto.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

Comments

Max Reitz Aug. 20, 2019, 4:38 p.m. UTC | #1
On 14.08.19 22:22, Maxim Levitsky wrote:
> * rename the write_func to create_write_func,
>   and init_func to create_init_func
>   this is  preparation for other write_func that will
>   be used to update the encryption keys.
> 
> No functional changes
> 
> Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com>
> ---
>  block/crypto.c | 15 ++++++++-------
>  1 file changed, 8 insertions(+), 7 deletions(-)
> 

I’m not quite sure why you remove or add blank lines seemingly at random...

> diff --git a/block/crypto.c b/block/crypto.c
> index 8237424ae6..42a3f0898b 100644
> --- a/block/crypto.c
> +++ b/block/crypto.c

[...]

> @@ -77,7 +76,7 @@ struct BlockCryptoCreateData {
>  };
>  
>  
> -static ssize_t block_crypto_write_func(QCryptoBlock *block,
> +static ssize_t block_crypto_create_write_func(QCryptoBlock *block,
>                                         size_t offset,
>                                         const uint8_t *buf,
>                                         size_t buflen,

Alignment should be kept at the opening parentheses.

But other than those two things, why not.

Max
Daniel P. Berrangé Aug. 21, 2019, 3:39 p.m. UTC | #2
On Wed, Aug 14, 2019 at 11:22:07PM +0300, Maxim Levitsky wrote:
> * rename the write_func to create_write_func,
>   and init_func to create_init_func
>   this is  preparation for other write_func that will
>   be used to update the encryption keys.
> 
> No functional changes
> 
> Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com>
> ---
>  block/crypto.c | 15 ++++++++-------
>  1 file changed, 8 insertions(+), 7 deletions(-)
> 
> diff --git a/block/crypto.c b/block/crypto.c
> index 8237424ae6..42a3f0898b 100644
> --- a/block/crypto.c
> +++ b/block/crypto.c
> @@ -51,7 +51,6 @@ static int block_crypto_probe_generic(QCryptoBlockFormat format,
>      }
>  }
>  
> -

Unrelated whitespace change

>  static ssize_t block_crypto_read_func(QCryptoBlock *block,
>                                        size_t offset,
>                                        uint8_t *buf,
> @@ -77,7 +76,7 @@ struct BlockCryptoCreateData {
>  };
>  
>  
> -static ssize_t block_crypto_write_func(QCryptoBlock *block,
> +static ssize_t block_crypto_create_write_func(QCryptoBlock *block,
>                                         size_t offset,
>                                         const uint8_t *buf,
>                                         size_t buflen,

Re-indent.

> @@ -95,8 +94,7 @@ static ssize_t block_crypto_write_func(QCryptoBlock *block,
>      return ret;
>  }
>  
> -

Unrelated whitespace

> -static ssize_t block_crypto_init_func(QCryptoBlock *block,
> +static ssize_t block_crypto_create_init_func(QCryptoBlock *block,
>                                        size_t headerlen,
>                                        void *opaque,
>                                        Error **errp)

Re-indent.

> @@ -108,7 +106,8 @@ static ssize_t block_crypto_init_func(QCryptoBlock *block,
>          return -EFBIG;
>      }
>  
> -    /* User provided size should reflect amount of space made
> +    /*
> +     * User provided size should reflect amount of space made

Unrelated whitespace

>       * available to the guest, so we must take account of that
>       * which will be used by the crypto header
>       */
> @@ -117,6 +116,8 @@ static ssize_t block_crypto_init_func(QCryptoBlock *block,
>  }
>  
>  
> +
> +

Unrelated whitespace

>  static QemuOptsList block_crypto_runtime_opts_luks = {
>      .name = "crypto",
>      .head = QTAILQ_HEAD_INITIALIZER(block_crypto_runtime_opts_luks.head),
> @@ -272,8 +273,8 @@ static int block_crypto_co_create_generic(BlockDriverState *bs,
>      };
>  
>      crypto = qcrypto_block_create(opts, NULL,
> -                                  block_crypto_init_func,
> -                                  block_crypto_write_func,
> +                                  block_crypto_create_init_func,
> +                                  block_crypto_create_write_func,
>                                    &data,
>                                    errp);

With the whitespace changes removed & indent fixed

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>


Regards,
Daniel
Maxim Levitsky Aug. 22, 2019, 12:05 a.m. UTC | #3
On Tue, 2019-08-20 at 18:38 +0200, Max Reitz wrote:
> On 14.08.19 22:22, Maxim Levitsky wrote:
> > * rename the write_func to create_write_func,
> >   and init_func to create_init_func
> >   this is  preparation for other write_func that will
> >   be used to update the encryption keys.
> > 
> > No functional changes
> > 
> > Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com>
> > ---
> >  block/crypto.c | 15 ++++++++-------
> >  1 file changed, 8 insertions(+), 7 deletions(-)
> > 
> 
> I’m not quite sure why you remove or add blank lines seemingly at random...

Basically to have consistent two space separation between all functions.
A bit of OCD I confess :-)

> 
> > diff --git a/block/crypto.c b/block/crypto.c
> > index 8237424ae6..42a3f0898b 100644
> > --- a/block/crypto.c
> > +++ b/block/crypto.c
> 
> [...]
> 
> > @@ -77,7 +76,7 @@ struct BlockCryptoCreateData {
> >  };
> >  
> >  
> > -static ssize_t block_crypto_write_func(QCryptoBlock *block,
> > +static ssize_t block_crypto_create_write_func(QCryptoBlock *block,
> >                                         size_t offset,
> >                                         const uint8_t *buf,
> >                                         size_t buflen,
> 
> Alignment should be kept at the opening parentheses.
Opps. I am still trying to learn that rule. Fixed.

> 
> But other than those two things, why not.
> 
> Max
> 

Best regards,
	Thanks for the review
		Maxim Levitsky
Maxim Levitsky Aug. 22, 2019, 12:08 a.m. UTC | #4
On Wed, 2019-08-21 at 16:39 +0100, Daniel P. Berrangé wrote:
> On Wed, Aug 14, 2019 at 11:22:07PM +0300, Maxim Levitsky wrote:
> > * rename the write_func to create_write_func,
> >   and init_func to create_init_func
> >   this is  preparation for other write_func that will
> >   be used to update the encryption keys.
> > 
> > No functional changes
> > 
> > Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com>
> > ---
> >  block/crypto.c | 15 ++++++++-------
> >  1 file changed, 8 insertions(+), 7 deletions(-)
> > 
> > diff --git a/block/crypto.c b/block/crypto.c
> > index 8237424ae6..42a3f0898b 100644
> > --- a/block/crypto.c
> > +++ b/block/crypto.c
> > @@ -51,7 +51,6 @@ static int block_crypto_probe_generic(QCryptoBlockFormat format,
> >      }
> >  }
> >  
> > -
> 
> Unrelated whitespace change
> 
> >  static ssize_t block_crypto_read_func(QCryptoBlock *block,
> >                                        size_t offset,
> >                                        uint8_t *buf,
> > @@ -77,7 +76,7 @@ struct BlockCryptoCreateData {
> >  };
> >  
> >  
> > -static ssize_t block_crypto_write_func(QCryptoBlock *block,
> > +static ssize_t block_crypto_create_write_func(QCryptoBlock *block,
> >                                         size_t offset,
> >                                         const uint8_t *buf,
> >                                         size_t buflen,
> 
> Re-indent.
> 
> > @@ -95,8 +94,7 @@ static ssize_t block_crypto_write_func(QCryptoBlock *block,
> >      return ret;
> >  }
> >  
> > -
> 
> Unrelated whitespace
> 
> > -static ssize_t block_crypto_init_func(QCryptoBlock *block,
> > +static ssize_t block_crypto_create_init_func(QCryptoBlock *block,
> >                                        size_t headerlen,
> >                                        void *opaque,
> >                                        Error **errp)
> 
> Re-indent.
> 
> > @@ -108,7 +106,8 @@ static ssize_t block_crypto_init_func(QCryptoBlock *block,
> >          return -EFBIG;
> >      }
> >  
> > -    /* User provided size should reflect amount of space made
> > +    /*
> > +     * User provided size should reflect amount of space made
> 
> Unrelated whitespace
> 
> >       * available to the guest, so we must take account of that
> >       * which will be used by the crypto header
> >       */
> > @@ -117,6 +116,8 @@ static ssize_t block_crypto_init_func(QCryptoBlock *block,
> >  }
> >  
> >  
> > +
> > +
> 
> Unrelated whitespace
> 
> >  static QemuOptsList block_crypto_runtime_opts_luks = {
> >      .name = "crypto",
> >      .head = QTAILQ_HEAD_INITIALIZER(block_crypto_runtime_opts_luks.head),
> > @@ -272,8 +273,8 @@ static int block_crypto_co_create_generic(BlockDriverState *bs,
> >      };
> >  
> >      crypto = qcrypto_block_create(opts, NULL,
> > -                                  block_crypto_init_func,
> > -                                  block_crypto_write_func,
> > +                                  block_crypto_create_init_func,
> > +                                  block_crypto_create_write_func,
> >                                    &data,
> >                                    errp);
> 
> With the whitespace changes removed & indent fixed
> 
> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
> 
> 
> Regards,
> Daniel

Thanks you!

Best regards,
	Maxim Levitsky
Max Reitz Aug. 22, 2019, 2:34 p.m. UTC | #5
On 22.08.19 02:05, Maxim Levitsky wrote:
> On Tue, 2019-08-20 at 18:38 +0200, Max Reitz wrote:
>> On 14.08.19 22:22, Maxim Levitsky wrote:
>>> * rename the write_func to create_write_func,
>>>   and init_func to create_init_func
>>>   this is  preparation for other write_func that will
>>>   be used to update the encryption keys.
>>>
>>> No functional changes
>>>
>>> Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com>
>>> ---
>>>  block/crypto.c | 15 ++++++++-------
>>>  1 file changed, 8 insertions(+), 7 deletions(-)
>>>
>>
>> I’m not quite sure why you remove or add blank lines seemingly at random...
> 
> Basically to have consistent two space separation between all functions.
> A bit of OCD I confess :-)

Well, it didn’t work because in one place you added two empty lines
where we already had two, so there are four now.

Max
Maxim Levitsky Aug. 22, 2019, 3:04 p.m. UTC | #6
On Thu, 2019-08-22 at 16:34 +0200, Max Reitz wrote:
> On 22.08.19 02:05, Maxim Levitsky wrote:
> > On Tue, 2019-08-20 at 18:38 +0200, Max Reitz wrote:
> > > On 14.08.19 22:22, Maxim Levitsky wrote:
> > > > * rename the write_func to create_write_func,
> > > >   and init_func to create_init_func
> > > >   this is  preparation for other write_func that will
> > > >   be used to update the encryption keys.
> > > > 
> > > > No functional changes
> > > > 
> > > > Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com>
> > > > ---
> > > >  block/crypto.c | 15 ++++++++-------
> > > >  1 file changed, 8 insertions(+), 7 deletions(-)
> > > > 
> > > 
> > > I’m not quite sure why you remove or add blank lines seemingly at random...
> > 
> > Basically to have consistent two space separation between all functions.
> > A bit of OCD I confess :-)
> 
> Well, it didn’t work because in one place you added two empty lines
> where we already had two, so there are four now.
Exactly :-) 

While the reason I sometimes add/remove black lines between functions
is this, this time this was just a leftover from some stuff I removed and forget
to remove the black lines. Usually prior to sending the patches I 'polish' very
carefully such stuff, but this time since I send up the RFC, I didn't do that 
that well thus various issues like that poped up.


Best regards,
	Maxim Levitsky
diff mbox series

Patch

diff --git a/block/crypto.c b/block/crypto.c
index 8237424ae6..42a3f0898b 100644
--- a/block/crypto.c
+++ b/block/crypto.c
@@ -51,7 +51,6 @@  static int block_crypto_probe_generic(QCryptoBlockFormat format,
     }
 }
 
-
 static ssize_t block_crypto_read_func(QCryptoBlock *block,
                                       size_t offset,
                                       uint8_t *buf,
@@ -77,7 +76,7 @@  struct BlockCryptoCreateData {
 };
 
 
-static ssize_t block_crypto_write_func(QCryptoBlock *block,
+static ssize_t block_crypto_create_write_func(QCryptoBlock *block,
                                        size_t offset,
                                        const uint8_t *buf,
                                        size_t buflen,
@@ -95,8 +94,7 @@  static ssize_t block_crypto_write_func(QCryptoBlock *block,
     return ret;
 }
 
-
-static ssize_t block_crypto_init_func(QCryptoBlock *block,
+static ssize_t block_crypto_create_init_func(QCryptoBlock *block,
                                       size_t headerlen,
                                       void *opaque,
                                       Error **errp)
@@ -108,7 +106,8 @@  static ssize_t block_crypto_init_func(QCryptoBlock *block,
         return -EFBIG;
     }
 
-    /* User provided size should reflect amount of space made
+    /*
+     * User provided size should reflect amount of space made
      * available to the guest, so we must take account of that
      * which will be used by the crypto header
      */
@@ -117,6 +116,8 @@  static ssize_t block_crypto_init_func(QCryptoBlock *block,
 }
 
 
+
+
 static QemuOptsList block_crypto_runtime_opts_luks = {
     .name = "crypto",
     .head = QTAILQ_HEAD_INITIALIZER(block_crypto_runtime_opts_luks.head),
@@ -272,8 +273,8 @@  static int block_crypto_co_create_generic(BlockDriverState *bs,
     };
 
     crypto = qcrypto_block_create(opts, NULL,
-                                  block_crypto_init_func,
-                                  block_crypto_write_func,
+                                  block_crypto_create_init_func,
+                                  block_crypto_create_write_func,
                                   &data,
                                   errp);