Source-Changes-HG archive

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

[src/trunk]: src/sys/net bpf_filter: re-use some code. No functional change ...



details:   https://anonhg.NetBSD.org/src/rev/5488309c1dc3
branches:  trunk
changeset: 790398:5488309c1dc3
user:      rmind <rmind%NetBSD.org@localhost>
date:      Sat Oct 05 22:38:52 2013 +0000

description:
bpf_filter: re-use some code.  No functional change intended.

diffstat:

 sys/net/bpf_filter.c |  36 ++++++++++++++----------------------
 1 files changed, 14 insertions(+), 22 deletions(-)

diffs (116 lines):

diff -r 5f618b796033 -r 5488309c1dc3 sys/net/bpf_filter.c
--- a/sys/net/bpf_filter.c      Sat Oct 05 22:01:12 2013 +0000
+++ b/sys/net/bpf_filter.c      Sat Oct 05 22:38:52 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: bpf_filter.c,v 1.59 2013/09/19 00:48:48 rmind Exp $    */
+/*     $NetBSD: bpf_filter.c,v 1.60 2013/10/05 22:38:52 rmind Exp $    */
 
 /*-
  * Copyright (c) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997
@@ -37,7 +37,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: bpf_filter.c,v 1.59 2013/09/19 00:48:48 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bpf_filter.c,v 1.60 2013/10/05 22:38:52 rmind Exp $");
 
 #if 0
 #if !(defined(lint) || defined(KERNEL))
@@ -197,8 +197,9 @@
 {
        uint32_t A, X, k;
        uint32_t mem[BPF_MEMWORDS];
+#ifdef _KERNEL
+       const struct mbuf * const m0 = (const struct mbuf *)p;
 
-#ifdef _KERNEL
        KASSERT(bc != NULL);
 #endif
 
@@ -242,7 +243,7 @@
 
                                if (buflen != 0)
                                        return 0;
-                               A = m_xword((const struct mbuf *)p, k, &merr);
+                               A = m_xword(m0, k, &merr);
                                if (merr != 0)
                                        return 0;
                                continue;
@@ -261,7 +262,7 @@
 
                                if (buflen != 0)
                                        return 0;
-                               A = m_xhalf((const struct mbuf *)p, k, &merr);
+                               A = m_xhalf(m0, k, &merr);
                                if (merr != 0)
                                        return 0;
                                continue;
@@ -276,14 +277,11 @@
                        k = pc->k;
                        if (k >= buflen) {
 #ifdef _KERNEL
-                               const struct mbuf *m;
-                               int len;
+                               int merr;
 
                                if (buflen != 0)
                                        return 0;
-                               m = (const struct mbuf *)p;
-                               MINDEX(len, m, k);
-                               A = mtod(m, u_char *)[k];
+                               A = m_xbyte(m0, k, &merr);
                                continue;
 #else
                                return 0;
@@ -309,7 +307,7 @@
 
                                if (buflen != 0)
                                        return 0;
-                               A = m_xword((const struct mbuf *)p, k, &merr);
+                               A = m_xword(m0, k, &merr);
                                if (merr != 0)
                                        return 0;
                                continue;
@@ -329,7 +327,7 @@
 
                                if (buflen != 0)
                                        return 0;
-                               A = m_xhalf((const struct mbuf *)p, k, &merr);
+                               A = m_xhalf(m0, k, &merr);
                                if (merr != 0)
                                        return 0;
                                continue;
@@ -344,14 +342,11 @@
                        k = X + pc->k;
                        if (pc->k >= buflen || X >= buflen - pc->k) {
 #ifdef _KERNEL
-                               const struct mbuf *m;
-                               int len;
+                               int merr;
 
                                if (buflen != 0)
                                        return 0;
-                               m = (const struct mbuf *)p;
-                               MINDEX(len, m, k);
-                               A = mtod(m, u_char *)[k];
+                               A = m_xbyte(m0, k, &merr);
                                continue;
 #else
                                return 0;
@@ -364,14 +359,11 @@
                        k = pc->k;
                        if (k >= buflen) {
 #ifdef _KERNEL
-                               const struct mbuf *m;
-                               int len;
+                               int merr;
 
                                if (buflen != 0)
                                        return 0;
-                               m = (const struct mbuf *)p;
-                               MINDEX(len, m, k);
-                               X = (mtod(m, char *)[k] & 0xf) << 2;
+                               X = (m_xbyte(m0, k, &merr) & 0xf) << 2;
                                continue;
 #else
                                return 0;



Home | Main Index | Thread Index | Old Index