[PATCH] hash: minor touchups

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

 



On RHEL5, I got:
util/virrandom.c:66: warning: nested extern declaration of '_gl_verify_function66' [-Wnested-externs]

The fix is to hoist the verify earlier.  Also some other hodge-podge
fixes I noticed while reviewing Dan's recent series.

* .gitignore: Ignore new test.
* src/util/cgroup.c: Bump copyright year.
* src/util/virhash.c: Fix typo in description.
* src/util/virrandom.c (virRandomBits): Mark doc comment, and
hoist assert to silence older gcc.
---

Pushing under the build-breaker rule.

We didn't notice it earlier because newer gcc introduced
_Static_assert (per C11), so that verify() doesn't have to
rely on extern declarations in that case.

 .gitignore           |    1 +
 src/util/cgroup.c    |    2 +-
 src/util/virhash.c   |    2 +-
 src/util/virrandom.c |   10 +++++-----
 4 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/.gitignore b/.gitignore
index 61a9a38..2533fce 100644
--- a/.gitignore
+++ b/.gitignore
@@ -78,6 +78,7 @@
 /tests/openvzutilstest
 /tests/qemuxmlnstest
 /tests/shunloadtest
+/tests/virhashtest
 /update.log
 Makefile
 Makefile.in
diff --git a/src/util/cgroup.c b/src/util/cgroup.c
index 3f092ab..15b870d 100644
--- a/src/util/cgroup.c
+++ b/src/util/cgroup.c
@@ -1,7 +1,7 @@
 /*
  * cgroup.c: Tools for managing cgroups
  *
- * Copyright (C) 2010-2011 Red Hat, Inc.
+ * Copyright (C) 2010-2012 Red Hat, Inc.
  * Copyright IBM Corp. 2008
  *
  * See COPYING.LIB for the License of this software
diff --git a/src/util/virhash.c b/src/util/virhash.c
index efaa286..6dec684 100644
--- a/src/util/virhash.c
+++ b/src/util/virhash.c
@@ -1,5 +1,5 @@
 /*
- * virhash.c: chained hash tables for domain and domain/connection deallocatiosn
+ * virhash.c: chained hash tables
  *
  * Reference: Your favorite introductory book on algorithms
  *
diff --git a/src/util/virrandom.c b/src/util/virrandom.c
index 0af94d5..ec0cf03 100644
--- a/src/util/virrandom.c
+++ b/src/util/virrandom.c
@@ -46,7 +46,11 @@ int virRandomInitialize(uint32_t seed)
     return 0;
 }

-/*
+/* The algorithm of virRandomBits requires that RAND_MAX == 2^n-1 for
+ * some n; gnulib's random_r meets this property. */
+verify(((RAND_MAX + 1U) & RAND_MAX) == 0);
+
+/**
  * virRandomBits:
  * @nbits: Number of bits of randommess required
  *
@@ -61,10 +65,6 @@ uint64_t virRandomBits(int nbits)
     uint64_t ret = 0;
     int32_t bits;

-    /* This algorithm requires that RAND_MAX == 2^n-1 for some n;
-       gnulib's random_r meets this property. */
-    verify(((RAND_MAX + 1U) & RAND_MAX) == 0);
-
     virMutexLock(&randomLock);

     while (nbits > bits_per_iter) {
-- 
1.7.7.6

--
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]