This is the mail archive of the glibc-cvs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

GNU C Library master sources branch master updated. glibc-2.16-ports-merge-776-g0817d63


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU C Library master sources".

The branch, master has been updated
       via  0817d63dd1f8e165f8ef6590bf4feddf06705381 (commit)
      from  de2fd463b1c0310d75084b6d774fb974075a4ad9 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://sources.redhat.com/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=0817d63dd1f8e165f8ef6590bf4feddf06705381

commit 0817d63dd1f8e165f8ef6590bf4feddf06705381
Author: Siddhesh Poyarekar <siddhesh@redhat.com>
Date:   Wed Nov 28 06:45:50 2012 +0530

    Fix hashtable size calculation when database has exactly one record
    
    The hash function needs a hashtable of at least size 3 or greater.

diff --git a/ChangeLog b/ChangeLog
index 1a2e4da..7df91e5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2012-11-28  Siddhesh Poyarekar  <siddhesh@redhat.com>
+	    Carlos O'Donell  <carlos_odonell@mentor.com>
+
+	* nss/makedb.c (is_prime): Assert that input is odd and greater
+	than 4.  Note that fact in a comment too.
+	(next_prime): Add 4 to input.
+
 2012-11-27  Siddhesh Poyarekar  <siddhesh@redhat.com>
 
 	[BZ #11741]
diff --git a/nss/makedb.c b/nss/makedb.c
index 8d7d027..e372f5d 100644
--- a/nss/makedb.c
+++ b/nss/makedb.c
@@ -591,13 +591,16 @@ copy_valstr (const void *nodep, const VISIT which, const int depth)
 }
 
 
+/* Determine if the candidate is prime by using a modified trial division
+   algorithm. The candidate must be both odd and greater than 4.  */
 static int
 is_prime (size_t candidate)
 {
-  /* No even number and none less than 10 will be passed here.  */
   size_t divn = 3;
   size_t sq = divn * divn;
 
+  assert (candidate > 4 && candidate % 2 != 0);
+
   while (sq < candidate && candidate % divn != 0)
     {
       ++divn;
@@ -612,8 +615,8 @@ is_prime (size_t candidate)
 static size_t
 next_prime (size_t seed)
 {
-  /* Make it definitely odd.  */
-  seed |= 1;
+  /* Make sure that we're always greater than 4.  */
+  seed = (seed + 4) | 1;
 
   while (!is_prime (seed))
     seed += 2;

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog    |    7 +++++++
 nss/makedb.c |    9 ++++++---
 2 files changed, 13 insertions(+), 3 deletions(-)


hooks/post-receive
-- 
GNU C Library master sources


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]