qemu-block
[Top][All Lists]
Advanced

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

Re: [PATCH v6 04/14] block/amend: separate amend and create options for


From: Eric Blake
Subject: Re: [PATCH v6 04/14] block/amend: separate amend and create options for qemu-img
Date: Fri, 15 May 2020 12:24:14 -0500
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0

On 5/15/20 1:22 AM, Max Reitz wrote:


+        QCOW_COMMON_OPTIONS,
+        { /* end of list */ }

...the intended usage is to use the macro name followed by a comma, so
including a trailing comma in the macro itself would lead to a syntax
error.

But why is that the indended usage?  Is there something in our coding
style that forbids macros that don’t allow a separator to be placed
after them?

If we have more than one such macro, it is easier to write and indent (especially when using your editor's ability to decipher enough syntax to suggest how to indent):

myarray = {
  COMMON_ELEMENTS,
  MORE_ELEMENTS,
  { /* end of list */ }
};

than it is:

myarray = {
  COMMON_ELEMENTS
  MORE_ELEMENTS
  { /* end of list */ }
};

which in turn implies that it is better to NOT stick a trailing comma in the macro itself. Similarly, for macros intended to replace statements, we tend to avoid the trailing ; in the macro itself, because it is easier to read:

{
  code;
  MACRO();
  more code;
}

than it is:

{
  code;
  MACRO()
  more code;
}

--
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org




reply via email to

[Prev in Thread] Current Thread [Next in Thread]