Module Name:    src
Committed By:   christos
Date:           Sat Jan 28 19:07:16 UTC 2017

Modified Files:
        src/sys/netbt: hci.h

Log Message:
factor out common subexpressions.


To generate a diff of this commit:
cvs rdiff -u -r1.41 -r1.42 src/sys/netbt/hci.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/netbt/hci.h
diff -u src/sys/netbt/hci.h:1.41 src/sys/netbt/hci.h:1.42
--- src/sys/netbt/hci.h:1.41	Sat Nov 28 04:04:34 2015
+++ src/sys/netbt/hci.h	Sat Jan 28 14:07:16 2017
@@ -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 @@ struct hci_filter {
 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);
 }
 
 /*

Reply via email to