You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by GitBox <gi...@apache.org> on 2019/05/30 20:49:01 UTC

[GitHub] [mynewt-core] ccollins476ad commented on a change in pull request #1809: Shell newtmgr bridge

ccollins476ad commented on a change in pull request #1809: Shell newtmgr bridge
URL: https://github.com/apache/mynewt-core/pull/1809#discussion_r289166584
 
 

 ##########
 File path: util/streamer/src/streamer_mbuf.c
 ##########
 @@ -0,0 +1,87 @@
+/*
+ * 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.
+ */
+
+#include "streamer/streamer.h"
+
+static int
+streamer_mbuf_write(struct streamer *streamer, const void *src, size_t len)
+{
+    struct streamer_mbuf *sm;
+    int rc;
+
+    if (len > UINT16_MAX) {
+        return SYS_EINVAL;
+    }
+
+    sm = (struct streamer_mbuf *)streamer;
+    rc = os_mbuf_append(sm->om, src, len);
+    if (rc != 0) {
 
 Review comment:
   `os_mbuf_append()` uses a different set of error codes (`OS_E[...]`), so we can't just return that.  I am not strongly opposed to checking if `sm->om` is null here, but I think it would be better to just do this check once when the streamer gets initialized (I see you have made a similar comment below!).
   
   However, I do think we need something that converts from `OS_E` codes to `SYS_E` codes.  Other parts of the code would benefit from such a thing.  So I will add it as a separate commit in this PR.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services