[Qemu-devel] [PATCH 0/2] Refine some vdi code

yuchenlin--- via Qemu-devel posted 2 patches 7 years, 3 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20180730024701.7613-1-yuchenlin@synology.com
Test checkpatch passed
Test docker-mingw@fedora passed
Test docker-clang@ubuntu passed
Test docker-quick@centos7 passed
block/vdi.c | 32 ++++++++++++++++++--------------
1 file changed, 18 insertions(+), 14 deletions(-)
[Qemu-devel] [PATCH 0/2] Refine some vdi code
Posted by yuchenlin--- via Qemu-devel 7 years, 3 months ago
From: yuchenlin <yuchenlin@synology.com>

This series refine some code in vdi.c, includes:

* Remvoe CONFIG_VDI_WRITE because there is no reason to leave an always on
  and cannot configure option in the code-side.
* decouple if else if chain to get more readability.

Thanks,
yuchenlin

yuchenlin (2):
  vdi: remove CONFIG_VDI_WRITE
  vdi: refine code for vdi_open

 block/vdi.c | 32 ++++++++++++++++++--------------
 1 file changed, 18 insertions(+), 14 deletions(-)

-- 
2.17.0


Re: [Qemu-devel] [PATCH 0/2] Refine some vdi code
Posted by Stefan Weil 7 years, 3 months ago
Am 30.07.2018 um 04:46 schrieb yuchenlin@synology.com:
> From: yuchenlin <yuchenlin@synology.com>
> 
> This series refine some code in vdi.c, includes:
> 
> * Remvoe CONFIG_VDI_WRITE because there is no reason to leave an always on
>   and cannot configure option in the code-side.
> * decouple if else if chain to get more readability.
> 
> Thanks,
> yuchenlin
> 
> yuchenlin (2):
>   vdi: remove CONFIG_VDI_WRITE
>   vdi: refine code for vdi_open
> 
>  block/vdi.c | 32 ++++++++++++++++++--------------
>  1 file changed, 18 insertions(+), 14 deletions(-)


Technically these changes are fine, but personally I prefer my old code.
If else is rendundant here, but redundancy helps humans to understand
the code. CONFIG_VDI_WRITE still has a similar function as it documents
which code parts are relevant for write support.

Stefan

Re: [Qemu-devel] [PATCH 0/2] Refine some vdi code
Posted by yuchenlin via Qemu-devel 7 years, 3 months ago
Hi, Stefan

I agree that redundancy of If else may helps people to understand the code.

However, CONFIG_VDI_WRITE only contributes:

#if defined(CONFIG_VDI_WRITE)
.bdrv_co_pwritev = vdi_co_pwritev,
#endif

I think we don't need CONFIG_VDI_WRITE to document the code.
As its name implies, vdi_co_pwritev shows the code parts for vdi write support.


I appreciated your time and effort for reviews.

Regards,
yuchenlin


Stefan Weil <sw@weilnetz.de> 於 2018-07-30 15:13 寫道:
> Am 30.07.2018 um 04:46 schrieb yuchenlin@synology.com: > From: yuchenlin <yuchenlin@synology.com> > > This series refine some code in vdi.c, includes: > > * Remvoe CONFIG_VDI_WRITE because there is no reason to leave an always on > and cannot configure option in the code-side. > * decouple if else if chain to get more readability. > > Thanks, > yuchenlin > > yuchenlin (2): > vdi: remove CONFIG_VDI_WRITE > vdi: refine code for vdi_open > > block/vdi.c | 32 ++++++++++++++++++-------------- > 1 file changed, 18 insertions(+), 14 deletions(-) Technically these changes are fine, but personally I prefer my old code. If else is rendundant here, but redundancy helps humans to understand the code. CONFIG_VDI_WRITE still has a similar function as it documents which code parts are relevant for write support. Stefan