[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] hw: virtio-gpu: remove duplicated 'virtqueue_pop'
From: |
Gerd Hoffmann |
Subject: |
Re: [PATCH] hw: virtio-gpu: remove duplicated 'virtqueue_pop' |
Date: |
Mon, 17 Aug 2020 09:01:16 +0200 |
Hi,
> - If the get_next() invocation is simple, then style (1) is perfectly fine.
Fully agree. Duplicating a single line is perfectly fine if it is
simple enough that you can hardly get it wrong.
> - Style (2) is the worst of all.
Yes, especially because the break is three lines not two due to qemu
code style.
> - If style (1) is not appropriate for whatever reason, then style (3) is
> frequently a good replacement. Style (3) is sometimes rejected by coding
> style documents though. Style (3) is not usable if is_valid() is a
> function-like macro that does not evaluate its argument exactly once.
> Frequently, is_valid() is simply open-coded with C operators (using extra
> parens), for example:
> or more verbosely
>
> while ((cmd = virtqueue_pop(vq, sizeof(struct virtio_gpu_ctrl_command)))
> !=
> NULL) {
Style 3 tends to generate long lines, which in turn need line breaks
like this. Also many parens don't help making code more readable.
So I'd prefer to just leave things as-is.
take care,
Gerd