diff mbox series

[v7,2/9] qcow2: Cosmetic changes

Message ID 20180810062647.23211-3-lbloch@janustech.com
State New
Headers show
Series Take the image size into account when allocating the L2 cache | expand

Commit Message

Leonid Bloch Aug. 10, 2018, 6:26 a.m. UTC
Some refactoring for better readability is done here.

Signed-off-by: Leonid Bloch <lbloch@janustech.com>
---
 block/qcow2.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

Comments

Alberto Garcia Aug. 10, 2018, 12:54 p.m. UTC | #1
On Fri 10 Aug 2018 08:26:40 AM CEST, Leonid Bloch wrote:
> Some refactoring for better readability is done here.
>
> Signed-off-by: Leonid Bloch <lbloch@janustech.com>

> -    *l2_cache_entry_size = qemu_opt_get_size(
> -        opts, QCOW2_OPT_L2_CACHE_ENTRY_SIZE, s->cluster_size);
> +    *l2_cache_entry_size = qemu_opt_get_size(opts,
> +                                             QCOW2_OPT_L2_CACHE_ENTRY_SIZE,
> +                                             s->cluster_size);

> -                *refcount_cache_size =
> -                    MIN(combined_cache_size, min_refcount_cache);
> +                *refcount_cache_size = MIN(combined_cache_size,
> +                                           min_refcount_cache);

I won't oppose these changes if more people think that they improve
readability, but it seems to me that this is just a matter of taste and
there's no big difference either way.

I'm personally fine with the way the code is now, and this coding style
is used in many other parts of QEMU:

$ git grep -A 1 '.* = .*($'
$ git grep -A 1 '.* =$'

Berto
diff mbox series

Patch

diff --git a/block/qcow2.c b/block/qcow2.c
index ec9e6238a0..3f4abc394e 100644
--- a/block/qcow2.c
+++ b/block/qcow2.c
@@ -790,8 +790,9 @@  static void read_cache_sizes(BlockDriverState *bs, QemuOpts *opts,
     *refcount_cache_size = qemu_opt_get_size(opts,
                                              QCOW2_OPT_REFCOUNT_CACHE_SIZE, 0);
 
-    *l2_cache_entry_size = qemu_opt_get_size(
-        opts, QCOW2_OPT_L2_CACHE_ENTRY_SIZE, s->cluster_size);
+    *l2_cache_entry_size = qemu_opt_get_size(opts,
+                                             QCOW2_OPT_L2_CACHE_ENTRY_SIZE,
+                                             s->cluster_size);
 
     if (combined_cache_size_set) {
         if (l2_cache_size_set && refcount_cache_size_set) {
@@ -823,8 +824,8 @@  static void read_cache_sizes(BlockDriverState *bs, QemuOpts *opts,
                 *l2_cache_size = max_l2_cache;
                 *refcount_cache_size = combined_cache_size - *l2_cache_size;
             } else {
-                *refcount_cache_size =
-                    MIN(combined_cache_size, min_refcount_cache);
+                *refcount_cache_size = MIN(combined_cache_size,
+                                           min_refcount_cache);
                 *l2_cache_size = combined_cache_size - *refcount_cache_size;
             }
         }