vrahane commented on a change in pull request #27: Update mynewt port of mcumgr 
and various fixes
URL: https://github.com/apache/mynewt-mcumgr/pull/27#discussion_r330781454
 
 

 ##########
 File path: cmd/log_mgmt/port/mynewt/src/mynewt_log_mgmt.c
 ##########
 @@ -127,32 +124,54 @@ mynewt_log_mgmt_walk_cb(struct log *log, struct 
log_offset *log_offset,
      * Else: encode entries whose timestamp >= specified timestamp and whose
      *      index >= specified index
      */
-
     if (log_offset->lo_ts == 0) {
-        if (log_offset->lo_index > ueh.ue_index) {
+        if (log_offset->lo_index > leh->ue_index) {
             return 0;
         }
-    } else if (ueh.ue_ts < log_offset->lo_ts   ||
-               (ueh.ue_ts == log_offset->lo_ts &&
-                ueh.ue_index < log_offset->lo_index)) {
+    } else if (leh->ue_ts < log_offset->lo_ts   ||
+               (leh->ue_ts == log_offset->lo_ts &&
+                leh->ue_index < log_offset->lo_index)) {
         return 0;
     }
 
-    read_len = min(len - sizeof ueh, LOG_MGMT_BODY_LEN - sizeof ueh);
-    rc = log_read(log, desciptor, mynewt_log_mgmt_walk_arg->body, sizeof ueh,
-                  read_len);
-    if (rc < 0) {
-        return MGMT_ERR_EUNKNOWN;
+    entry.ts = leh->ue_ts;
+    entry.index = leh->ue_index;
+    entry.module = leh->ue_module;
+    entry.level = leh->ue_level;
+
+#if MYNEWT_VAL(LOG_VERSION) < 3
+    entry.type = LOG_ETYPE_STRING;
+    entry.flags = 0;
+#else
+    entry.type = leh->ue_etype;
+    entry.flags = leh->ue_flags;
+    entry.imghash = (leh->ue_flags & LOG_FLAGS_IMG_HASH) ?
+        leh->ue_imghash : NULL;
+#endif
+
+    for (offset = 0; offset < len; offset += LOG_MGMT_CHUNK_LEN) {
+        if (len - offset < LOG_MGMT_CHUNK_LEN) {
+            read_len = len - offset;
+        } else {
+            read_len = LOG_MGMT_CHUNK_LEN;
+        }
+
+        rc = log_read_body(log, dptr, mynewt_log_mgmt_walk_arg->chunk, offset,
+                           read_len);
+        if (rc < 0) {
+            return MGMT_ERR_EUNKNOWN;
+        }
+        entrylen += rc;
     }
 
-    entry.ts = ueh.ue_ts;
-    entry.index = ueh.ue_index;
-    entry.module = ueh.ue_module;
-    entry.level = ueh.ue_level;
-    entry.len = rc;
-    entry.data = mynewt_log_mgmt_walk_arg->body;
+    entry.len = entrylen;
+    entry.data = mynewt_log_mgmt_walk_arg->chunk;
+    rc = mynewt_log_mgmt_walk_arg->cb(&entry, mynewt_log_mgmt_walk_arg->arg);
+    if (rc) {
 
 Review comment:
   done

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

Reply via email to