[libvirt] [PATCH v3] Document preferred naming conventions

Michal Privoznik mprivozn at redhat.com
Fri Mar 10 14:31:29 UTC 2017


On 03/06/2017 12:09 PM, Daniel P. Berrange wrote:
> This documents the preferred conventions for naming files,
> structs, enums, typedefs and functions.
> 
> Signed-off-by: Daniel P. Berrange <berrange at redhat.com>
> ---
> 
> Changed in v3:
>  - Clarify function naming wrt verb & subject
>  - Simplify macro naming, since in practice libvirt code doesn't follow any
>    rules consistently aside from having a VIR_ prefix.
> 
>  HACKING              | 80 ++++++++++++++++++++++++++++++++++++++++++++
>  docs/hacking.html.in | 93 ++++++++++++++++++++++++++++++++++++++++++++++++++++
>  docs/hacking2.xsl    |  4 +++
>  3 files changed, 177 insertions(+)
> 


> +*Function names*
> +
> +All functions should have a 'vir' prefix in their name, followed by one or
> +more words with first letter of each word capitalized. Underscores should not
> +be used in function names. If the function is operating on an object, then the
> +function name prefix should match the object typedef name, otherwise it should
> +match the filename. Following this comes the verb / action name, and finally
> +an optional subject name. For example, given an object 'virHashTable', all
> +functions should have a name 'virHashTable$VERB' or
> +'virHashTable$VERB$SUBJECT". e.g. 'virHashTableLookup' or
> +'virHashTableGetValue'.
> +

This will create some functions with ridiculously long names.
qemuDomainSnapshotPrepareDiskExternalOverlayInactive() for instance.
Should we lift our "80 chars per line" rule? Say to 100? Even more so
since we all are working on wide screen monitors (RIP 4:3).

Michal




More information about the libvir-list mailing list