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 2019/04/06 01:36:17 UTC

[mynewt-core] branch master updated: mgmt/oicmgr: omgr_oic_put()-like with return code

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-core.git


The following commit(s) were added to refs/heads/master by this push:
     new df93ea9  mgmt/oicmgr: omgr_oic_put()-like with return code
df93ea9 is described below

commit df93ea935d02ef602f9753e59a54261628700835
Author: Christopher Collins <cc...@apache.org>
AuthorDate: Fri Apr 5 09:47:25 2019 -0700

    mgmt/oicmgr: omgr_oic_put()-like with return code
    
    `omgr_oic_put()` include status in the CoAP response that it sends,
    but it does not indicate status to the caller.  This is necessary
    because the iotivity library only accepts pointers to a functions
    returning void.
    
    It may be helpful to return a status code here in case the caller wants
    to perform additional work after successfully processing an oicmgr
    request.  This commit adds a new function (`omgr_oic_process_put()`)
    which does the same thing as the original, but returns a status.
---
 mgmt/oicmgr/include/oicmgr/oicmgr.h |  5 ++++-
 mgmt/oicmgr/src/oicmgr.c            | 12 ++++++++++--
 2 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/mgmt/oicmgr/include/oicmgr/oicmgr.h b/mgmt/oicmgr/include/oicmgr/oicmgr.h
index 0b13d80..38a44c2 100644
--- a/mgmt/oicmgr/include/oicmgr/oicmgr.h
+++ b/mgmt/oicmgr/include/oicmgr/oicmgr.h
@@ -30,8 +30,11 @@
  * @param req                   The oicmgr request to process.
  * @param mask                  The oicmgr mask supported by the CoAP request
  *                                  handler.
+ *
+ * @return                      0 on success;
+ *                              nonzero on failure (not consistent code sets).
  */
-void omgr_oic_put(oc_request_t *req, oc_interface_mask_t mask);
+int omgr_oic_process_put(oc_request_t *req, oc_interface_mask_t mask);
 
 /**
  * Parses an oicmgr request and copies out the NMP header.
diff --git a/mgmt/oicmgr/src/oicmgr.c b/mgmt/oicmgr/src/oicmgr.c
index aa23af9..c50f430 100644
--- a/mgmt/oicmgr/src/oicmgr.c
+++ b/mgmt/oicmgr/src/oicmgr.c
@@ -154,8 +154,8 @@ omgr_extract_req_hdr(oc_request_t *req, struct nmgr_hdr *out_hdr)
     return 0;
 }
 
-void
-omgr_oic_put(oc_request_t *req, oc_interface_mask_t mask)
+int
+omgr_oic_process_put(oc_request_t *req, oc_interface_mask_t mask)
 {
     struct omgr_state *o = &omgr_state;
     const struct mgmt_handler *handler;
@@ -272,6 +272,14 @@ done:
 
     cbor_encoder_close_container(&g_encoder, &o->os_cbuf.ob_mj.encoder);
     oc_send_response(req, rc);
+
+    return rc;
+}
+
+static void
+omgr_oic_put(oc_request_t *req, oc_interface_mask_t mask)
+{
+    omgr_oic_process_put(req, mask);
 }
 
 int