Re: [PATCHv2] storage: Avoid unnecessary ternary operators and refactor the code

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

 



On 06/05/2013 05:37 PM, Peter Krempa wrote:
> Setting of local variables in virStorageBackendCreateQemuImgCmd was
> unnecessarily cluttered with ternary operators and repeated testing of
> of conditions.
> 
> This patch refactors the function to use if statements and improves
> error reporting in case inputvol is specified but does not contain
> target path. Previously we would complain about "unknown storage vol
> type 0" instead of the actual problem.
> ---
> 
> Notes:
>     Version 2:
>     - retured preallocation check that was removed by mistake
>     - returned backing store check to the correct condition
>     - improve error reporting
> 
>  src/storage/storage_backend.c | 69 ++++++++++++++++++++++---------------------
>  1 file changed, 36 insertions(+), 33 deletions(-)
> 
> diff --git a/src/storage/storage_backend.c b/src/storage/storage_backend.c
> index 5a61381..4d90d52 100644
> --- a/src/storage/storage_backend.c
> +++ b/src/storage/storage_backend.c
> @@ -663,53 +663,58 @@ virStorageBackendCreateQemuImgCmd(virConnectPtr conn,
...
> 
> +    if (inputvol) {
> +        if (!(inputPath = inputvol->target.path)) {
> +            virReportError(VIR_ERR_INVALID_ARG, "%s",
> +                           _("missing target volume path"));

How about "missing input volume target path" instead?

ACK

Jan

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]