Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/netbt factor out common subexpressions.



details:   https://anonhg.NetBSD.org/src/rev/d2e7deaa2aa4
branches:  trunk
changeset: 821205:d2e7deaa2aa4
user:      christos <christos%NetBSD.org@localhost>
date:      Sat Jan 28 19:07:16 2017 +0000

description:
factor out common subexpressions.

diffstat:

 sys/netbt/hci.h |  28 ++++++++++++++--------------
 1 files changed, 14 insertions(+), 14 deletions(-)

diffs (59 lines):

diff -r dc45e8ea3284 -r d2e7deaa2aa4 sys/netbt/hci.h
--- a/sys/netbt/hci.h   Sat Jan 28 17:14:21 2017 +0000
+++ b/sys/netbt/hci.h   Sat Jan 28 19:07:16 2017 +0000
@@ -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;
-
-       off >>= 5;
-       filter->mask[off] |= (1 << ((bit - 1) & 0x1f));
+       uint8_t off = (uint8_t)((bit - 1) >> 5);
+       uint8_t sh = (uint8_t)((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;
-
-       off >>= 5;
-       filter->mask[off] &= ~(1 << ((bit - 1) & 0x1f));
+       uint8_t off = (uint8_t)((bit - 1) >> 5);
+       uint8_t sh = (uint8_t)((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;
-
-       off >>= 5;
-       return (filter->mask[off] & (1 << ((bit - 1) & 0x1f)));
+       uint8_t off = (uint8_t)((bit - 1) >> 5);
+       uint8_t sh = (uint8_t)((bit - 1) & 0x1f);
+
+       return filter->mask[off] & (1 << sh);
 }
 
 /*



Home | Main Index | Thread Index | Old Index