]> xenbits.xensource.com Git - libvirt.git/commitdiff
virnetserverservice: Resolve Coverity ARRAY_VS_SINGLETON
authorJohn Ferlan <jferlan@redhat.com>
Thu, 28 Aug 2014 13:03:47 +0000 (09:03 -0400)
committerJohn Ferlan <jferlan@redhat.com>
Thu, 28 Aug 2014 23:18:37 +0000 (19:18 -0400)
Coverity complained about the following:

(3) Event ptr_arith:
   Performing pointer arithmetic on "cur_fd" in expression "cur_fd++".
130             return virNetServerServiceNewFD(*cur_fd++,

The complaint is that pointer arithmetic taking place instead of the
expected auto increment of the variable...  Adding some well placed
parentheses ensures our order of operation.

src/rpc/virnetserverservice.c

index fea05c3e4ec3186f93bb67747bcb3551af098fc4..647007b91112f13481e6c2f8082c3a6cb157dd27 100644 (file)
@@ -125,9 +125,11 @@ virNetServerServiceNewFDOrUNIX(const char *path,
     } else {
         /*
          * There's still enough file descriptors.  In this case we'll
-         * use the current one and increment it afterwards.
+         * use the current one and increment it afterwards. Take care
+         * with order of operation for pointer arithmetic and auto
+         * increment on cur_fd - the parentheses are necessary.
          */
-        return virNetServerServiceNewFD(*cur_fd++,
+        return virNetServerServiceNewFD((*cur_fd)++,
                                         auth,
 #if WITH_GNUTLS
                                         tls,