[libvirt PATCH 4/4] docs: coding-style: One variable declaration per line

Ján Tomko jtomko at redhat.com
Fri Jan 14 15:56:06 UTC 2022


On a Friday in 2022, Tim Wiederhake wrote:
>This was not mentioned before.
>
>Signed-off-by: Tim Wiederhake <twiederh at redhat.com>
>---
> docs/coding-style.rst | 13 +++++++++++++
> 1 file changed, 13 insertions(+)
>
>diff --git a/docs/coding-style.rst b/docs/coding-style.rst
>index 14c5136398..e1ed34f764 100644
>--- a/docs/coding-style.rst
>+++ b/docs/coding-style.rst
>@@ -600,6 +600,19 @@ calling another function.
>         ...
>     }
>
>+Define variables on separate lines. This allows for smaller, easier to
>+understand diffs when changing them. Define variables in the smallest
>+possible scope.
>+
>+::
>+
>+  GOOD:
>+    int x;
>+    int y;
>+
>+  BAD:
>+    int x, y;
>+

Please use longer variable names and initialize some too, to illustrate
it better, e.g.:

     int count = 0, nnodes;

Personally I don't mind:

   size_t i, j;

that much - even though removing one does cause churn, they are simple
to read.

Reviewed-by: Ján Tomko <jtomko at redhat.com>

Jano
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20220114/746e40d0/attachment-0001.sig>


More information about the libvir-list mailing list