Fix power-of-2 check for the TCB hash size.

Submitted by:	Brian Feldman <green@unixhelp.org>
This commit is contained in:
Mike Smith 1999-02-04 03:02:56 +00:00
parent 5549c02763
commit 609b6256fd
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=43575
2 changed files with 4 additions and 4 deletions

View File

@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)tcp_subr.c 8.2 (Berkeley) 5/24/95
* $Id: tcp_subr.c,v 1.49 1998/12/07 21:58:42 archie Exp $
* $Id: tcp_subr.c,v 1.50 1999/02/03 08:59:30 msmith Exp $
*/
#include "opt_compat.h"
@ -136,7 +136,7 @@ tcp_init()
tcbinfo.listhead = &tcb;
if (!(getenv_int("net.inet.tcp.tcbhashsize", &hashsize)))
hashsize = TCBHASHSIZE;
if ((1 << ffs(hashsize)) != hashsize) {
if ((1 << (ffs(hashsize) - 1)) != hashsize) {
printf("WARNING: TCB hash size not a power of 2\n");
hashsize = 512; /* safe default */
}

View File

@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)tcp_subr.c 8.2 (Berkeley) 5/24/95
* $Id: tcp_subr.c,v 1.49 1998/12/07 21:58:42 archie Exp $
* $Id: tcp_subr.c,v 1.50 1999/02/03 08:59:30 msmith Exp $
*/
#include "opt_compat.h"
@ -136,7 +136,7 @@ tcp_init()
tcbinfo.listhead = &tcb;
if (!(getenv_int("net.inet.tcp.tcbhashsize", &hashsize)))
hashsize = TCBHASHSIZE;
if ((1 << ffs(hashsize)) != hashsize) {
if ((1 << (ffs(hashsize) - 1)) != hashsize) {
printf("WARNING: TCB hash size not a power of 2\n");
hashsize = 512; /* safe default */
}