From: Rusty Russell Date: Wed, 6 Jul 2011 05:21:54 +0000 (+0930) Subject: Merge branch 'master' of ozlabs.org:ccan X-Git-Url: https://git.ozlabs.org/?p=ccan;a=commitdiff_plain;h=da8558a174da778aeb9dd95e62e023d39349b948;hp=993b67a5cce1414578d5fac3c10e89e2236613f8 Merge branch 'master' of ozlabs.org:ccan --- diff --git a/ccan/tally/tally.c b/ccan/tally/tally.c index b1839bef..396474b2 100644 --- a/ccan/tally/tally.c +++ b/ccan/tally/tally.c @@ -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) { diff --git a/ccan/tap/tap.c b/ccan/tap/tap.c index b7a84ac9..7c01e140 100644 --- a/ccan/tap/tap.c +++ b/ccan/tap/tap.c @@ -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 static pthread_mutex_t M = PTHREAD_MUTEX_INITIALIZER; # define LOCK pthread_mutex_lock(&M)