You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by ja...@apache.org on 2026/10/12 16:26:24 UTC
(mynewt-core) 15/24: mgmt/mcumgr: Remove remaining non-Mynewt code
This is an automated email from the ASF dual-hosted git repository.
sjanc pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git
commit 6e2eb8cdfd2c5f44aefbbb1614519fd916da7c10
Author: Szymon Janc <sz...@codecoup.pl>
AuthorDate: Tue Oct 6 19:15:54 2026 +0200
mgmt/mcumgr: Remove remaining non-Mynewt code
Remove code that was only used when building mcumgr for Zephyr or
other OSes:
- __ZEPHYR__ conditional code in cborattr and log_mgmt
- MYNEWT conditionals in cborattr (always defined by newt)
- multi-image support in image state read (Mynewt supports single
updatable image only)
No functional changes.
Assisted-by: Claude:claude-opus-5-5
---
encoding/cborattr/include/cborattr/cborattr.h | 6 ------
encoding/cborattr/src/cborattr.c | 18 ------------------
mgmt/mcumgr/cmd/img_mgmt/src/img_mgmt_state.c | 4 ----
mgmt/mcumgr/cmd/log_mgmt/src/log_mgmt.c | 4 ----
4 files changed, 32 deletions(-)
diff --git a/encoding/cborattr/include/cborattr/cborattr.h b/encoding/cborattr/include/cborattr/cborattr.h
index 6c800e0bb..083fea8f9 100644
--- a/encoding/cborattr/include/cborattr/cborattr.h
+++ b/encoding/cborattr/include/cborattr/cborattr.h
@@ -27,9 +27,7 @@
#include <sys/types.h>
#include "tinycbor/cbor.h"
-#ifdef MYNEWT
#include <os/os_mbuf.h>
-#endif
#ifdef __cplusplus
extern "C" {
@@ -126,7 +124,6 @@ struct cbor_attr_t {
bool nodefault;
};
-#ifndef __ZEPHYR__
/** An array value to be encoded as CBOR. */
struct cbor_out_arr_val_t {
struct cbor_out_val_t *elems;
@@ -162,7 +159,6 @@ struct cbor_out_attr_t {
struct cbor_out_val_t val; /** The attribute value. */
bool omit; /** Attribute ignored if true. */
};
-#endif
/*
* Use the following macros to declare template initializers for
@@ -189,7 +185,6 @@ int cbor_read_object(struct CborValue *, const struct cbor_attr_t *);
int cbor_read_array(struct CborValue *, const struct cbor_array_t *);
int cbor_read_flat_attrs(const uint8_t *data, int len, const struct cbor_attr_t *attrs);
-#ifdef MYNEWT
int cbor_read_mbuf_attrs(struct os_mbuf *m, uint16_t off, uint16_t len,
const struct cbor_attr_t *attrs);
@@ -214,7 +209,6 @@ int cbor_write_object(struct CborEncoder *enc, const struct cbor_out_attr_t *att
*/
int cbor_write_object_msys(const struct cbor_out_attr_t *attrs,
struct os_mbuf **out_om);
-#endif
#ifdef __cplusplus
}
#endif
diff --git a/encoding/cborattr/src/cborattr.c b/encoding/cborattr/src/cborattr.c
index 8266e50d8..4f980ae4f 100644
--- a/encoding/cborattr/src/cborattr.c
+++ b/encoding/cborattr/src/cborattr.c
@@ -20,28 +20,12 @@
#include "cborattr/cborattr.h"
#include "tinycbor/cbor.h"
#include "tinycbor/cbor_buf_reader.h"
-
-#ifdef __ZEPHYR__
-#include <zephyr/kernel.h>
-#ifdef CONFIG_MGMT_CBORATTR_MAX_SIZE
-#define CBORATTR_MAX_SIZE CONFIG_MGMT_CBORATTR_MAX_SIZE
-#else
-#define CBORATTR_MAX_SIZE 512
-#endif
-#endif
-
-#ifdef MYNEWT
#include "syscfg/syscfg.h"
#include "tinycbor/cbor_mbuf_reader.h"
#include "tinycbor/cbor_mbuf_writer.h"
#include "os/os_mbuf.h"
#define CBORATTR_MAX_SIZE MYNEWT_VAL(CBORATTR_MAX_SIZE)
#define CBORATTR_MAX_NESTING MYNEWT_VAL(CBORATTR_MAX_NESTING)
-#endif
-
-#ifndef CBORATTR_MAX_NESTING
-#define CBORATTR_MAX_NESTING 16
-#endif
/* this maps a CborType to a matching CborAtter Type. The mapping is not
* one-to-one because of signedness of integers
@@ -525,7 +509,6 @@ cbor_read_flat_attrs(const uint8_t *data, int len, const struct cbor_attr_t *att
return cbor_read_object(&value, attrs);
}
-#ifdef MYNEWT
static int cbor_write_val(struct CborEncoder *enc, const struct cbor_out_val_t *val);
/*
@@ -737,4 +720,3 @@ cbor_write_object_msys(const struct cbor_out_attr_t *attrs, struct os_mbuf **out
return 0;
}
-#endif
diff --git a/mgmt/mcumgr/cmd/img_mgmt/src/img_mgmt_state.c b/mgmt/mcumgr/cmd/img_mgmt/src/img_mgmt_state.c
index 18b6cb4f0..7d8d5e9f0 100644
--- a/mgmt/mcumgr/cmd/img_mgmt/src/img_mgmt_state.c
+++ b/mgmt/mcumgr/cmd/img_mgmt/src/img_mgmt_state.c
@@ -212,10 +212,6 @@ img_mgmt_state_read(struct mgmt_ctxt *ctxt)
err |= cbor_encoder_create_map(&images, &image, CborIndefiniteLength);
-#if IMG_MGMT_UPDATABLE_IMAGE_NUMBER > 1
- err |= cbor_encode_text_stringz(&image, "image");
- err |= cbor_encode_int(&image, i >> 1);
-#endif
err |= cbor_encode_text_stringz(&image, "slot");
err |= cbor_encode_int(&image, i % 2);
diff --git a/mgmt/mcumgr/cmd/log_mgmt/src/log_mgmt.c b/mgmt/mcumgr/cmd/log_mgmt/src/log_mgmt.c
index 1850d3858..3f6bd46a6 100644
--- a/mgmt/mcumgr/cmd/log_mgmt/src/log_mgmt.c
+++ b/mgmt/mcumgr/cmd/log_mgmt/src/log_mgmt.c
@@ -461,11 +461,7 @@ log_mgmt_cb_encode(struct log_mgmt_entry *entry, void *arg)
*/
cbor_cnt_writer_init(&cnt_writer);
-#ifdef __ZEPHYR__
- cbor_encoder_cust_writer_init(&cnt_encoder, &cnt_writer.enc, 0);
-#else
cbor_encoder_init(&cnt_encoder, &cnt_writer.enc, 0);
-#endif
rc = log_mgmt_encode_entry(&cnt_encoder, entry, &entry_len, lmec);
if (rc != 0) {
return rc;