Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 11 Jul 2017 12:35:44 +0000 (UTC)
From:      Konstantin Belousov <kib@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r320893 - head/sys/sys
Message-ID:  <201707111235.v6BCZiFU073236@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kib
Date: Tue Jul 11 12:35:44 2017
New Revision: 320893
URL: https://svnweb.freebsd.org/changeset/base/320893

Log:
  Fix BIT_FLS().
  
  The iteration index is unsigned, so testing for larger than or equal
  to zero makes little sense.
  
  Submitted by:	Sebastian Huber <sebastian.huber@embedded-brains.de>
  MFC after:	3 days

Modified:
  head/sys/sys/bitset.h

Modified: head/sys/sys/bitset.h
==============================================================================
--- head/sys/sys/bitset.h	Tue Jul 11 12:32:40 2017	(r320892)
+++ head/sys/sys/bitset.h	Tue Jul 11 12:35:44 2017	(r320893)
@@ -218,10 +218,10 @@
 	int __bit;							\
 									\
 	__bit = 0;							\
-	for (__i = __bitset_words((_s)) - 1; __i >= 0; __i--) {		\
-		if ((p)->__bits[__i] != 0) {				\
-			__bit = flsl((p)->__bits[__i]);			\
-			__bit += __i * _BITSET_BITS;			\
+	for (__i = __bitset_words((_s)); __i > 0; __i--) {		\
+		if ((p)->__bits[__i - 1] != 0) {			\
+			__bit = flsl((p)->__bits[__i - 1]);		\
+			__bit += (__i - 1) * _BITSET_BITS;		\
 			break;						\
 		}							\
 	}								\



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201707111235.v6BCZiFU073236>