You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by cc...@apache.org on 2015/11/25 23:11:24 UTC

[2/3] incubator-mynewt-larva git commit: Include size of base pkthdr in om_pkthdr_len field

Include size of base pkthdr in om_pkthdr_len field


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/commit/4e597f54
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/tree/4e597f54
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/diff/4e597f54

Branch: refs/heads/master
Commit: 4e597f5460f7e889dc5242b77f8c7a2e75eed9c3
Parents: fe8e503
Author: Christopher Collins <cc...@gmail.com>
Authored: Wed Nov 25 14:09:41 2015 -0800
Committer: Christopher Collins <cc...@gmail.com>
Committed: Wed Nov 25 14:09:41 2015 -0800

----------------------------------------------------------------------
 libs/os/include/os/os_mbuf.h |  4 ++--
 libs/os/src/os_mbuf.c        | 11 ++++++-----
 2 files changed, 8 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/4e597f54/libs/os/include/os/os_mbuf.h
----------------------------------------------------------------------
diff --git a/libs/os/include/os/os_mbuf.h b/libs/os/include/os/os_mbuf.h
index f0ea5e1..4227e3b 100644
--- a/libs/os/include/os/os_mbuf.h
+++ b/libs/os/include/os/os_mbuf.h
@@ -113,7 +113,7 @@ struct os_mqueue {
  * @param __om The mbuf to check 
  */
 #define OS_MBUF_IS_PKTHDR(__om) \
-    ((__om)->om_pkthdr_len > 0)
+    ((__om)->om_pkthdr_len >= sizeof (struct os_mbuf_pkthdr))
 
 /* Get a packet header pointer given an mbuf pointer */
 #define OS_MBUF_PKTHDR(__om) ((struct os_mbuf_pkthdr *)     \
@@ -144,7 +144,7 @@ _os_mbuf_leadingspace(struct os_mbuf *om)
 
     startoff = 0;
     if (OS_MBUF_IS_PKTHDR(om)) {
-        startoff = sizeof(struct os_mbuf_pkthdr) + om->om_pkthdr_len; 
+        startoff = om->om_pkthdr_len;
     }
 
     leadingspace = (uint16_t) (OS_MBUF_DATA(om, uint8_t *) - 

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/4e597f54/libs/os/src/os_mbuf.c
----------------------------------------------------------------------
diff --git a/libs/os/src/os_mbuf.c b/libs/os/src/os_mbuf.c
index daa4c46..447fb9a 100644
--- a/libs/os/src/os_mbuf.c
+++ b/libs/os/src/os_mbuf.c
@@ -172,15 +172,15 @@ err:
 
 /* Allocate a new packet header mbuf out of the os_mbuf_pool */ 
 struct os_mbuf *
-os_mbuf_get_pkthdr(struct os_mbuf_pool *omp, uint8_t pkthdr_len)
+os_mbuf_get_pkthdr(struct os_mbuf_pool *omp, uint8_t extra_pkthdr_len)
 {
     struct os_mbuf_pkthdr *pkthdr;
     struct os_mbuf *om;
 
     om = os_mbuf_get(omp, 0);
     if (om) {
-        om->om_pkthdr_len = pkthdr_len;
-        om->om_data += pkthdr_len + sizeof(struct os_mbuf_pkthdr);
+        om->om_pkthdr_len = extra_pkthdr_len + sizeof(struct os_mbuf_pkthdr);
+        om->om_data += extra_pkthdr_len + sizeof(struct os_mbuf_pkthdr);
 
         pkthdr = OS_MBUF_PKTHDR(om);
         pkthdr->omp_len = 0;
@@ -255,7 +255,7 @@ static inline void
 _os_mbuf_copypkthdr(struct os_mbuf *new_buf, struct os_mbuf *old_buf)
 {
     memcpy(&new_buf->om_databuf[0], &old_buf->om_databuf[0], 
-            sizeof(struct os_mbuf_pkthdr) + old_buf->om_pkthdr_len);
+           old_buf->om_pkthdr_len);
 }
 
 /** 
@@ -637,7 +637,8 @@ os_mbuf_prepend(struct os_mbuf *om, int len)
 
         /* The current head didn't have enough space; allocate a new head. */
         if (OS_MBUF_IS_PKTHDR(om)) {
-            p = os_mbuf_get_pkthdr(om->om_omp, om->om_pkthdr_len);
+            p = os_mbuf_get_pkthdr(om->om_omp,
+                om->om_pkthdr_len - sizeof (struct os_mbuf_pkthdr));
         } else {
             p = os_mbuf_get(om->om_omp, 0);
         }