This is an automated email from the ASF dual-hosted git repository.

ccollins pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-mcumgr.git

commit 46ad88ab79f90a9a5674a22e641172770e7af3c9
Author: Christopher Collins <ccoll...@apache.org>
AuthorDate: Wed Jan 3 17:24:38 2018 -0800

    Use latest tinycbor.
---
 mgmt/include/mgmt/endian.h | 31 +++++++++++++++++++++++++++++++
 mgmt/src/mgmt.c            |  7 ++++---
 smp/src/smp.c              | 34 ++++------------------------------
 3 files changed, 39 insertions(+), 33 deletions(-)

diff --git a/mgmt/include/mgmt/endian.h b/mgmt/include/mgmt/endian.h
new file mode 100644
index 0000000..704213e
--- /dev/null
+++ b/mgmt/include/mgmt/endian.h
@@ -0,0 +1,31 @@
+#ifndef H_MGMT_ENDIAN_
+#define H_MGMT_ENDIAN_
+
+#include <inttypes.h>
+
+#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
+
+#ifndef ntohs
+#define ntohs(x) (x)
+#endif
+
+#ifndef htons
+#define htons(x) (x)
+#endif
+
+#else
+/* Little endian. */
+
+#ifndef ntohs
+#define ntohs(x)   ((uint16_t)  \
+    ((((x) & 0xff00) >> 8) |    \
+     (((x) & 0x00ff) << 8)))
+#endif
+
+#ifndef htons
+#define htons(x) (ntohs(x))
+#endif
+
+#endif
+
+#endif
diff --git a/mgmt/src/mgmt.c b/mgmt/src/mgmt.c
index f12fc98..f906e5d 100644
--- a/mgmt/src/mgmt.c
+++ b/mgmt/src/mgmt.c
@@ -18,7 +18,8 @@
  */
 
 #include <string.h>
-#include "tinycbor/cbor.h"
+#include "cbor.h"
+#include "mgmt/endian.h"
 #include "mgmt/mgmt.h"
 
 static struct mgmt_group *mgmt_group_list;
@@ -145,12 +146,12 @@ mgmt_cbuf_init(struct mgmt_cbuf *cbuf, struct 
mgmt_streamer *streamer)
 {
     int rc;
 
-    rc = cbor_parser_init(streamer->reader, 0, &cbuf->parser, &cbuf->it);
+    rc = cbor_parser_cust_reader_init(streamer->reader, 0, &cbuf->parser, 
&cbuf->it);
     if (rc != CborNoError) {
         return mgmt_err_from_cbor(rc);
     }
 
-    cbor_encoder_init(&cbuf->encoder, streamer->writer, 0);
+    cbor_encoder_cust_writer_init(&cbuf->encoder, streamer->writer, 0);
 
     return 0;
 }
diff --git a/smp/src/smp.c b/smp/src/smp.c
index 6caf653..f88e17f 100644
--- a/smp/src/smp.c
+++ b/smp/src/smp.c
@@ -22,36 +22,10 @@
 #include <assert.h>
 #include <string.h>
 
+#include "mgmt/endian.h"
 #include "mgmt/mgmt.h"
 #include "smp/smp.h"
-#include "tinycbor/cbor.h"
-#include "tinycbor/cbor_mbuf_writer.h"
-#include "tinycbor/cbor_mbuf_reader.h"
-
-#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
-
-#ifndef ntohs
-#define ntohs(x) (x)
-#endif
-
-#ifndef htons
-#define htons(x) (x)
-#endif
-
-#else
-/* Little endian. */
-
-#ifndef ntohs
-#define ntohs(x)   ((uint16_t)  \
-    ((((x) & 0xff00) >> 8) |    \
-     (((x) & 0x00ff) << 8)))
-#endif
-
-#ifndef htons
-#define htons(x) (ntohs(x))
-#endif
-
-#endif
+#include "cbor.h"
 
 static int
 smp_align4(int x)
@@ -96,11 +70,11 @@ smp_read_hdr(struct smp_streamer *streamer, struct mgmt_hdr 
*dst_hdr)
 
     reader = streamer->ss_base.reader;
 
-    if (reader->message_size < sizeof *hdr) {
+    if (reader->message_size < sizeof *dst_hdr) {
         return MGMT_ERR_EINVAL;
     }
 
-    reader->cpy(reader, (char *)hdr, 0, sizeof *hdr);
+    reader->cpy(reader, (char *)dst_hdr, 0, sizeof *dst_hdr);
     return 0;
 }
 

-- 
To stop receiving notification emails like this one, please contact
"commits@mynewt.apache.org" <commits@mynewt.apache.org>.

Reply via email to