Merge branch 'master' of ozlabs.org:ccan
authorRusty Russell <rusty@rustcorp.com.au>
Wed, 6 Jul 2011 05:21:54 +0000 (14:51 +0930)
committerRusty Russell <rusty@rustcorp.com.au>
Wed, 6 Jul 2011 05:21:54 +0000 (14:51 +0930)
ccan/tally/tally.c
ccan/tap/tap.c

index b1839befe3b4016287ded6203767be305e65b657..396474b250e0c04be0b8a581a2fddc1bb553c7a4 100644 (file)
@@ -27,8 +27,8 @@ struct tally *tally_new(unsigned buckets)
        if (buckets == 0)
                buckets = 1;
 
-       /* Check for overflow. */
-       if (buckets && SIZE_MAX / buckets < sizeof(tally->counts[0]))
+       /* Overly cautious check for overflow. */
+       if (sizeof(*tally) * buckets / sizeof(*tally) != buckets)
                return NULL;
        tally = malloc(sizeof(*tally) + sizeof(tally->counts[0])*(buckets-1));
        if (tally) {
index b7a84ac9900b398a40687e4e2fedd2bef3049518..7c01e140d5c206c475957f439b47eb3462fff994 100644 (file)
@@ -45,8 +45,13 @@ static int test_died = 0;
 static int test_pid;
 
 /* Encapsulate the pthread code in a conditional.  In the absence of
-   libpthread the code does nothing */
-#if HAVE_LIBPTHREAD
+   libpthread the code does nothing.
+
+   If you have multiple threads calling ok() etc. at the same time you would
+   need this, but in that case your test numbers will be random and I'm not
+   sure it makes sense. --RR
+*/
+#ifdef WANT_PTHREAD
 #include <pthread.h>
 static pthread_mutex_t M = PTHREAD_MUTEX_INITIALIZER;
 # define LOCK pthread_mutex_lock(&M)