Re: [PATCH 2/4] Convert various virHash functions to use size_t / uint32

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

 



On 01/25/2012 09:38 AM, Daniel P. Berrange wrote:
> From: "Daniel P. Berrange" <berrange@xxxxxxxxxx>
> 
> In preparation for conversion over to use the Murmurhash3
> algorithm, convert various virHash APIs to use size_t or
> uint32 for their return values/parameters, instead of the
> variable size 'unsigned long' or 'int' types
> ---
>  src/util/cgroup.c |    4 +-
>  src/util/hash.c   |   56 +++++++++++++++++++++++++++-------------------------
>  src/util/hash.h   |   14 ++++++------
>  3 files changed, 38 insertions(+), 36 deletions(-)
> 

> diff --git a/src/util/cgroup.c b/src/util/cgroup.c
> index 25f2691..a270965 100644
> --- a/src/util/cgroup.c
> +++ b/src/util/cgroup.c
> @@ -1636,9 +1636,9 @@ cleanup:
>  }
>  
>  
> -static unsigned long virCgroupPidCode(const void *name)
> +static uint32_t virCgroupPidCode(const void *name)
>  {
> -    return (unsigned long)name;
> +    return (uint32_t)(int64_t)name;

I know why you did the double cast - to shut up the compiler warnings
about converting a pointer to a different size int.  But you still get
that warning on 32-bit machines, unless you use:

s/int64_t/intptr_t/

Meanwhile, your argument about this hash code only being used on Linux
with cgroups, and where pid is not a pid_t but a parsed long int from
procfs, convinced me - the naming is a bit unfortunate, but there is no
bug that will impact mingw64 pid_t cleanups.

Again, you forgot 'make check'.  ACK if you fix the above cast, and
squash this in:

diff --git i/tests/hashtest.c w/tests/hashtest.c
index 441672c..e4b2bc1 100644
--- i/tests/hashtest.c
+++ w/tests/hashtest.c
@@ -40,7 +40,7 @@ testHashInit(int size)
         }

         if (virHashTableSize(hash) != oldsize && virTestGetDebug()) {
-            fprintf(stderr, "\nhash grown from %d to %d",
+            fprintf(stderr, "\nhash grown from %d to %zd",
                     oldsize, virHashTableSize(hash));
         }
     }
@@ -75,7 +75,7 @@ testHashCheckCount(virHashTablePtr hash, int count)
     int iter_count = 0;

     if (virHashSize(hash) != count) {
-        testError("\nhash contains %d instead of %d elements\n",
+        testError("\nhash contains %zd instead of %d elements\n",
                   virHashSize(hash), count);
         return -1;
     }

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

Attachment: signature.asc
Description: OpenPGP digital signature

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]