[libvirt] [PATCH 11/11] maint: enforce comma style usage
Eric Blake
eblake at redhat.com
Wed Nov 20 16:23:28 UTC 2013
On 11/20/2013 06:26 AM, Osier Yang wrote:
> On 20/11/13 08:30, Eric Blake wrote:
>> Enforce and document the style set up by the previous patches.
>>
>> * build-aux/bracket-spacing.pl: Add comma checks.
>> * docs/hacking.html.in: Document the rules.
>> * HACKING: Regenerate.
>> +When declaring an enum or using a struct initializer that occupies
>> more than
>> +one line, use a trailing comma. That way, future edits to extend the
>> list only
>> +have to add a line, rather than modify an existing line to add the
>> +intermediate comma.
>
> Not sure if we need to explain more about the trailing comma for an enum
> or a struct helps on code auto generation and parsing.
Sure; I'll squash this in.
diff --git i/docs/hacking.html.in w/docs/hacking.html.in
index cc76997..0febee2 100644
--- i/docs/hacking.html.in
+++ w/docs/hacking.html.in
@@ -417,10 +418,15 @@
When declaring an enum or using a struct initializer that
occupies more than one line, use a trailing comma. That way,
future edits to extend the list only have to add a line, rather
- than modify an existing line to add the intermediate comma.
- However, this is harder to enforce, so you will find
- counterexamples in existing code. Additionally, any sentinel
- enumerator value with a name ending in _LAST is exempt.
+ than modify an existing line to add the intermediate comma. Any
+ sentinel enumerator value with a name ending in _LAST is exempt,
+ since you would extend such an enum before the _LAST element.
+ Another reason to favor trailing commas is that it requires less
+ effort to produce via code generators. Note that the syntax
+ checker is unable to enforce a style of trailing commas, so
+ there are counterexamples in existing code which do not use it;
+ also, while C99 allows trailing commas, remember that JSON and
+ XDR do not.
</p>
<pre>
enum {
> ACK either way w.r.t the comment. Thanks for the not interesting work. :-)
Thanks for the quick review. I'll push the series shortly.
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 621 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20131120/bdacff01/attachment-0001.sig>
More information about the libvir-list
mailing list