On Wed, Jan 25, 2012 at 11:34:14AM -0700, Eric Blake wrote:
On 01/25/2012 09:38 AM, Daniel P. Berrange wrote:
> From: "Daniel P. Berrange" <berrange(a)redhat.com>
>
> 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/
Hmm, yes good point - will change that.
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;
}
Ok
Daniel
--
|:
http://berrange.com -o-
http://www.flickr.com/photos/dberrange/ :|
|:
http://libvirt.org -o-
http://virt-manager.org :|
|:
http://autobuild.org -o-
http://search.cpan.org/~danberr/ :|
|:
http://entangle-photo.org -o-
http://live.gnome.org/gtk-vnc :|