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/05 02:32:48 UTC

incubator-mynewt-larva git commit: Add return code to os_mbuf_copydata().

Repository: incubator-mynewt-larva
Updated Branches:
  refs/heads/master 7c50b189e -> f10a7e7b0


Add return code to os_mbuf_copydata().


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/f10a7e7b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/tree/f10a7e7b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/diff/f10a7e7b

Branch: refs/heads/master
Commit: f10a7e7b03e418c030e0f22cba178f2793160356
Parents: 7c50b18
Author: Christopher Collins <cc...@gmail.com>
Authored: Wed Nov 4 17:32:00 2015 -0800
Committer: Christopher Collins <cc...@gmail.com>
Committed: Wed Nov 4 17:32:00 2015 -0800

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


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/f10a7e7b/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 2ce1dc5..0fc590a 100644
--- a/libs/os/include/os/os_mbuf.h
+++ b/libs/os/include/os/os_mbuf.h
@@ -202,7 +202,7 @@ struct os_mbuf *os_mbuf_get_pkthdr(struct os_mbuf_pool *omp);
 struct os_mbuf *os_mbuf_dup(struct os_mbuf_pool *omp, struct os_mbuf *m);
 
 /* Copy data from an mbuf to a flat buffer. */
-void os_mbuf_copydata(const struct os_mbuf *m, int off, int len, void *dst);
+int os_mbuf_copydata(const struct os_mbuf *m, int off, int len, void *dst);
 
 /* Append data onto a mbuf */
 int os_mbuf_append(struct os_mbuf_pool *omp, struct os_mbuf *m, void *, 

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/f10a7e7b/libs/os/src/os_mbuf.c
----------------------------------------------------------------------
diff --git a/libs/os/src/os_mbuf.c b/libs/os/src/os_mbuf.c
index 0533a1c..5aebd26 100644
--- a/libs/os/src/os_mbuf.c
+++ b/libs/os/src/os_mbuf.c
@@ -325,8 +325,11 @@ err:
 /*
  * Copy data from an mbuf chain starting "off" bytes from the beginning,
  * continuing for "len" bytes, into the indicated buffer.
+ *
+ * @return                      0 on success;
+ *                              -1 if the mbuf does not contain enough data.
  */
-void
+int
 os_mbuf_copydata(const struct os_mbuf *m, int off, int len, void *dst)
 {
     unsigned int count;
@@ -335,6 +338,10 @@ os_mbuf_copydata(const struct os_mbuf *m, int off, int len, void *dst)
     udst = dst;
 
     while (off > 0) {
+        if (!m) {
+            return (-1);
+        }
+
         if (off < m->om_len)
             break;
         off -= m->om_len;
@@ -348,6 +355,8 @@ os_mbuf_copydata(const struct os_mbuf *m, int off, int len, void *dst)
         off = 0;
         m = SLIST_NEXT(m, om_next);
     }
+
+    return (len > 0 ? -1 : 0);
 }
 
 #if 0