Sat Jan 28 19:07:16 2017 UTC ()
factor out common subexpressions.


(christos)
diff -r1.41 -r1.42 src/sys/netbt/hci.h

cvs diff -r1.41 -r1.42 src/sys/netbt/hci.h (expand / switch to context diff)
--- src/sys/netbt/hci.h 2015/11/28 09:04:34 1.41
+++ src/sys/netbt/hci.h 2017/01/28 19:07:16 1.42
@@ -1,4 +1,4 @@
-/*	$NetBSD: hci.h,v 1.41 2015/11/28 09:04:34 plunky Exp $	*/
+/*	$NetBSD: hci.h,v 1.42 2017/01/28 19:07:16 christos Exp $	*/
 
 /*-
  * Copyright (c) 2005 Iain Hibbert.
@@ -54,7 +54,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $Id: hci.h,v 1.41 2015/11/28 09:04:34 plunky Exp $
+ * $Id: hci.h,v 1.42 2017/01/28 19:07:16 christos Exp $
  * $FreeBSD: src/sys/netgraph/bluetooth/include/ng_hci.h,v 1.6 2005/01/07 01:45:43 imp Exp $
  */
 
@@ -2278,28 +2278,28 @@
 static __inline void
 hci_filter_set(uint8_t bit, struct hci_filter *filter)
 {
-	uint8_t off = bit - 1;
+	uint8_t off = (uint8_t)((bit - 1) >> 5);
+	uint8_t sh = (uint8_t)((bit - 1) & 0x1f);
 
-	off >>= 5;
-	filter->mask[off] |= (1 << ((bit - 1) & 0x1f));
+	filter->mask[off] |= 1 << sh;
 }
 
 static __inline void
 hci_filter_clr(uint8_t bit, struct hci_filter *filter)
 {
-	uint8_t off = bit - 1;
+	uint8_t off = (uint8_t)((bit - 1) >> 5);
+	uint8_t sh = (uint8_t)((bit - 1) & 0x1f);
 
-	off >>= 5;
-	filter->mask[off] &= ~(1 << ((bit - 1) & 0x1f));
+	filter->mask[off] &= ~(1 << sh);
 }
 
 static __inline int
 hci_filter_test(uint8_t bit, const struct hci_filter *filter)
 {
-	uint8_t off = bit - 1;
+	uint8_t off = (uint8_t)((bit - 1) >> 5);
+	uint8_t sh = (uint8_t)((bit - 1) & 0x1f);
 
-	off >>= 5;
-	return (filter->mask[off] & (1 << ((bit - 1) & 0x1f)));
+	return filter->mask[off] & (1 << sh);
 }
 
 /*