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

Re: [libvirt] [PATCH 01/24] maint: consistent formatting in libvirt.c



On 01/02/2014 08:29 AM, John Ferlan wrote:
> 
> 
> On 12/28/2013 11:11 AM, Eric Blake wrote:
>> Preliminary cleanups to make search-and-replace easier in later
>> patches.
>>
>> * src/libvirt.c: Uniform two spaces between functions, return
>> type and open brace on separate line, and label in column 1.
>>
>> Signed-off-by: Eric Blake <eblake redhat com>
>> ---
>>  src/libvirt.c | 718 +++++++++++++++++++++++++++++++++++++++++++---------------
>>  1 file changed, 536 insertions(+), 182 deletions(-)
>>
> 
> Well -someone- was busy during the holidays :-)

I was _trying_ to implement qemu monitor events as a pet project on my
own time, but kept running into pre-existing issue after issue with
existing event and documentation stuff (and this entire libvirt.c
cleanup series was prompted by the fact that I copied-and-pasted from
libvirt.c to libvirt-qemu.c, but compilation failed because of
inconsistencies between the two).  :)

> 
> Figured this was as good as place as any to start...  I did peek at the
> "final product", but since this first patch was about consistency of
> function decls, parameters, etc. I figured I'd do a summary here rather
> than trying to find each in the lines below.
> 
> In general it's very mechanical, but there were a few misses:

Thanks for spotting those; I'll incorporate fixes.

> 
> 1. The following didn't follow the rules exactly:
> 
> $ grep "^char \*" libvirt.c | grep -v "^char \*$"
> char *virConnectDomainXMLFromNative(virConnectPtr conn,

> 
> I did the same for 'unsigned char *', 'int', 'unsigned int', 'unsigned
> long', and various 'vir*Ptr' return types (Domain, Connect, Network,
> Interface, StoragePool, StorageVol, NodeDevice, Secret, Stream,
> NWFilter, and DomainSnapshot). I think I covered all the various return
> types I saw, but I supposed I could have missed a few...

I think you found them all - the only time we return pointers is either
via typedef ending in Ptr (which my greps covered) or via variants of
'char *' (which you found) - all other pointers are passed as parameters
rather than return type.

> 
> 4. And the copyright will I know be fixed the next time you touch the
> file...

yep, that already happened in commit c8f95ff :)

> 
> ACK with the changes
> 

Here's what I squashed in, before pushing:

diff --git i/src/libvirt.c w/src/libvirt.c
index eba3448..69ee4ac 100644
--- i/src/libvirt.c
+++ w/src/libvirt.c
@@ -3009,7 +3009,7 @@ error:
  */
 int
 virDomainRestoreFlags(virConnectPtr conn, const char *from, const char
*dxml,
-    unsigned int flags)
+                      unsigned int flags)
 {
     VIR_DEBUG("conn=%p, from=%s, dxml=%s, flags=%x",
               conn, from, NULLSTR(dxml), flags);
@@ -4382,8 +4382,8 @@ error:
  */
 int
 virDomainSetBlkioParameters(virDomainPtr domain,
-                             virTypedParameterPtr params,
-                             int nparams, unsigned int flags)
+                            virTypedParameterPtr params,
+                            int nparams, unsigned int flags)
 {
     virConnectPtr conn;

@@ -4454,8 +4454,8 @@ error:
  */
 int
 virDomainGetBlkioParameters(virDomainPtr domain,
-                             virTypedParameterPtr params,
-                             int *nparams, unsigned int flags)
+                            virTypedParameterPtr params,
+                            int *nparams, unsigned int flags)
 {
     virConnectPtr conn;

@@ -4720,10 +4720,11 @@ error:
  * Returns a 0 terminated UTF-8 encoded XML instance, or NULL in case
of error.
  *         the caller must free() the returned value.
  */
-char *virConnectDomainXMLFromNative(virConnectPtr conn,
-                                    const char *nativeFormat,
-                                    const char *nativeConfig,
-                                    unsigned int flags)
+char *
+virConnectDomainXMLFromNative(virConnectPtr conn,
+                              const char *nativeFormat,
+                              const char *nativeConfig,
+                              unsigned int flags)
 {
     VIR_DEBUG("conn=%p, format=%s, config=%s, flags=%x",
               conn, nativeFormat, nativeConfig, flags);
@@ -4776,10 +4777,11 @@ error:
  * Returns a 0 terminated UTF-8 encoded native config datafile, or NULL
in case of error.
  *         the caller must free() the returned value.
  */
-char *virConnectDomainXMLToNative(virConnectPtr conn,
-                                  const char *nativeFormat,
-                                  const char *domainXml,
-                                  unsigned int flags)
+char *
+virConnectDomainXMLToNative(virConnectPtr conn,
+                            const char *nativeFormat,
+                            const char *domainXml,
+                            unsigned int flags)
 {
     VIR_DEBUG("conn=%p, format=%s, xml=%s, flags=%x",
               conn, nativeFormat, domainXml, flags);
@@ -7104,7 +7106,6 @@ virDomainMigratePrepareTunnel3(virConnectPtr conn,
                                const char *dname,
                                unsigned long bandwidth,
                                const char *dom_xml)
-
 {
     VIR_DEBUG("conn=%p, stream=%p, cookiein=%p, cookieinlen=%d,
cookieout=%p, "
               "cookieoutlen=%p, flags=%lx, dname=%s, bandwidth=%lu, "
@@ -7433,7 +7434,6 @@ virDomainMigratePrepareTunnel3Params(virConnectPtr
conn,
                                      char **cookieout,
                                      int *cookieoutlen,
                                      unsigned int flags)
-
 {
     VIR_DEBUG("conn=%p, stream=%p, params=%p, nparams=%d, cookiein=%p, "
               "cookieinlen=%d, cookieout=%p, cookieoutlen=%p, flags=%x",
@@ -7969,7 +7969,6 @@ virNodeSuspendForDuration(virConnectPtr conn,
                           unsigned long long duration,
                           unsigned int flags)
 {
-
     VIR_DEBUG("conn=%p, target=%d, duration=%lld, flags=%x",
               conn, target, duration, flags);

@@ -15803,7 +15802,8 @@ error:
  *
  * Returns the XML document, or NULL on error
  */
-char *virNodeDeviceGetXMLDesc(virNodeDevicePtr dev, unsigned int flags)
+char *
+virNodeDeviceGetXMLDesc(virNodeDevicePtr dev, unsigned int flags)
 {
     VIR_DEBUG("dev=%p, conn=%p, flags=%x", dev, dev ? dev->conn : NULL,
flags);

@@ -15839,7 +15839,8 @@ error:
  *
  * Returns the device name or NULL in case of error
  */
-const char *virNodeDeviceGetName(virNodeDevicePtr dev)
+const char *
+virNodeDeviceGetName(virNodeDevicePtr dev)
 {
     VIR_DEBUG("dev=%p, conn=%p", dev, dev ? dev->conn : NULL);

@@ -15862,7 +15863,8 @@ const char
*virNodeDeviceGetName(virNodeDevicePtr dev)
  * Returns the name of the device's parent, or NULL if the
  * device has no parent.
  */
-const char *virNodeDeviceGetParent(virNodeDevicePtr dev)
+const char *
+virNodeDeviceGetParent(virNodeDevicePtr dev)
 {
     VIR_DEBUG("dev=%p, conn=%p", dev, dev ? dev->conn : NULL);



-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


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