diff --git a/cmd/log_mgmt/src/log_mgmt.c b/cmd/log_mgmt/src/log_mgmt.c index 4f92390a..58ecddb7 100644 --- a/cmd/log_mgmt/src/log_mgmt.c +++ b/cmd/log_mgmt/src/log_mgmt.c @@ -317,6 +317,7 @@ log_mgmt_show(struct mgmt_ctxt *ctxt) /* Log list fully iterated. */ if (name_len != 0) { /* Client specified log name, but the log wasn't found. */ + cbor_encoder_close_container(&ctxt->encoder, &logs); return MGMT_ERR_ENOENT; } else { break; diff --git a/omp/port/mynewt/src/mynewt_omp.c b/omp/port/mynewt/src/mynewt_omp.c index 2cda55e1..38b1ef4c 100644 --- a/omp/port/mynewt/src/mynewt_omp.c +++ b/omp/port/mynewt/src/mynewt_omp.c @@ -78,9 +78,6 @@ omp_impl_process_request_packet(struct omp_state *omgr_st, void *req_buf) } rc = omp_process_mgmt_hdr(&req_hdr, &rsp_hdr, &ctxt); - /* if (err != 0) { */ - /* rc = MGMT_ERR_EINVAL; */ - /* } */ cbor_encoder_close_container(streamer->rsp_encoder, &ctxt.encoder); if (rc != 0) { diff --git a/omp/src/omp.c b/omp/src/omp.c index 615c7984..fb1cc1e9 100644 --- a/omp/src/omp.c +++ b/omp/src/omp.c @@ -110,8 +110,8 @@ omp_process_mgmt_hdr(struct mgmt_hdr *req_hdr, struct mgmt_ctxt *ctxt) { int rc = 0; - bool rsp_hdr_filled = true; const struct mgmt_handler *handler; + mgmt_handler_fn *handler_fn = NULL; handler = mgmt_find_handler(req_hdr->nh_group, req_hdr->nh_id); if (handler == NULL) { @@ -121,34 +121,29 @@ omp_process_mgmt_hdr(struct mgmt_hdr *req_hdr, switch (req_hdr->nh_op) { case MGMT_OP_READ: - if (handler->mh_read == NULL) { - rc = MGMT_ERR_ENOENT; - } else { - rsp_hdr->nh_op = MGMT_OP_READ_RSP; - rc = handler->mh_read(ctxt); - } + rsp_hdr->nh_op = MGMT_OP_READ_RSP; + handler_fn = handler->mh_read; break; case MGMT_OP_WRITE: - if (handler->mh_write == NULL) { - rc = MGMT_ERR_ENOENT; - } else { - rsp_hdr->nh_op = MGMT_OP_WRITE_RSP; - rc = handler->mh_write(ctxt); - } + rsp_hdr->nh_op = MGMT_OP_WRITE_RSP; + handler_fn = handler->mh_write; break; default: rc = MGMT_ERR_EINVAL; - rsp_hdr_filled = false; - goto done; - break; + } + + if (handler_fn) { + rc = handler_fn(ctxt); + } else { + rc = MGMT_ERR_ENOTSUP; } /* Encode the MGMT header in the response. */ -done: + if (rc != 0) { - if (rsp_hdr_filled) { + if (handler_fn) { rc = omp_send_err_rsp(&ctxt->encoder, rsp_hdr, rc); } } else { @@ -158,5 +153,5 @@ omp_process_mgmt_hdr(struct mgmt_hdr *req_hdr, } } - return rc; + return mgmt_err_from_cbor(rc); } diff --git a/omp/syscfg.yml b/omp/syscfg.yml deleted file mode 100644 index 0efa3205..00000000 --- a/omp/syscfg.yml +++ /dev/null @@ -1,24 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -syscfg.defs: - OMP_OIC_RESOURCE_NAME: - description: > - The OMP OIC Resource name. - value: '"x.mynewt.nmgr"'