diff mbox

[2/3] util: fix some coding style issue

Message ID 1469691571-10819-3-git-send-email-caoj.fnst@cn.fujitsu.com
State New
Headers show

Commit Message

Cao jin July 28, 2016, 7:39 a.m. UTC
Fix some coding style issues found in removing NonBlockingConnectHandler.

Cc: Daniel P. Berrange <berrange@redhat.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Cao jin <caoj.fnst@cn.fujitsu.com>
---
 util/qemu-sockets.c | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

Comments

Daniel P. Berrangé July 28, 2016, 8:08 a.m. UTC | #1
On Thu, Jul 28, 2016 at 03:39:30PM +0800, Cao jin wrote:
> Fix some coding style issues found in removing NonBlockingConnectHandler.
> 
> Cc: Daniel P. Berrange <berrange@redhat.com>
> Cc: Gerd Hoffmann <kraxel@redhat.com>
> Cc: Paolo Bonzini <pbonzini@redhat.com>
> Signed-off-by: Cao jin <caoj.fnst@cn.fujitsu.com>
> ---
>  util/qemu-sockets.c | 16 +++++++++++-----
>  1 file changed, 11 insertions(+), 5 deletions(-)

Reviwed-by: Daniel P. Berrange <berrange@redhat.com>


> @@ -443,12 +443,16 @@ static int inet_dgram_saddr(InetSocketAddress *sraddr,
>      return sock;
>  
>  err:
> -    if (-1 != sock)
> +    if (-1 != sock) {

I'd probably fix the yoda-conditional here too. ie sock != -1 instead.

>          closesocket(sock);
> -    if (local)
> +    }
> +    if (local) {
>          freeaddrinfo(local);
> -    if (peer)
> +    }
> +    if (peer) {
>          freeaddrinfo(peer);
> +    }
> +
>      return -1;
>  }

Regards,
Daniel
Cao jin July 28, 2016, 8:44 a.m. UTC | #2
On 07/28/2016 04:08 PM, Daniel P. Berrange wrote:
> On Thu, Jul 28, 2016 at 03:39:30PM +0800, Cao jin wrote:
>> Fix some coding style issues found in removing NonBlockingConnectHandler.
>>
>> Cc: Daniel P. Berrange <berrange@redhat.com>
>> Cc: Gerd Hoffmann <kraxel@redhat.com>
>> Cc: Paolo Bonzini <pbonzini@redhat.com>
>> Signed-off-by: Cao jin <caoj.fnst@cn.fujitsu.com>
>> ---
>>   util/qemu-sockets.c | 16 +++++++++++-----
>>   1 file changed, 11 insertions(+), 5 deletions(-)
>
> Reviwed-by: Daniel P. Berrange <berrange@redhat.com>
>
>
>> @@ -443,12 +443,16 @@ static int inet_dgram_saddr(InetSocketAddress *sraddr,
>>       return sock;
>>
>>   err:
>> -    if (-1 != sock)
>> +    if (-1 != sock) {
>
> I'd probably fix the yoda-conditional here too. ie sock != -1 instead.
>
Just find this file mixes yoda-condition and non-yoda-condition.
ok, I can do it, v2 on the way.
diff mbox

Patch

diff --git a/util/qemu-sockets.c b/util/qemu-sockets.c
index cd4ed55..b2ef066 100644
--- a/util/qemu-sockets.c
+++ b/util/qemu-sockets.c
@@ -389,7 +389,7 @@  static int inet_dgram_saddr(InetSocketAddress *sraddr,
     if (0 != (rc = getaddrinfo(addr, port, &ai, &peer))) {
         error_setg(errp, "address resolution failed for %s:%s: %s", addr, port,
                    gai_strerror(rc));
-	goto err;
+        goto err;
     }
 
     /* lookup local addr */
@@ -443,12 +443,16 @@  static int inet_dgram_saddr(InetSocketAddress *sraddr,
     return sock;
 
 err:
-    if (-1 != sock)
+    if (-1 != sock) {
         closesocket(sock);
-    if (local)
+    }
+    if (local) {
         freeaddrinfo(local);
-    if (peer)
+    }
+    if (peer) {
         freeaddrinfo(peer);
+    }
+
     return -1;
 }
 
@@ -690,8 +694,10 @@  int unix_listen(const char *str, char *ostr, int olen, Error **errp)
 
     sock = unix_listen_saddr(saddr, true, errp);
 
-    if (sock != -1 && ostr)
+    if (sock != -1 && ostr) {
         snprintf(ostr, olen, "%s%s", saddr->path, optstr ? optstr : "");
+    }
+
     qapi_free_UnixSocketAddress(saddr);
     return sock;
 }