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 2016/10/07 20:40:36 UTC

incubator-mynewt-core git commit: MYNEWT-426 - Don't register reboot log again.

Repository: incubator-mynewt-core
Updated Branches:
  refs/heads/develop 8cf9cf31c -> ad17b3a7f


MYNEWT-426 - Don't register reboot log again.


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/ad17b3a7
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/ad17b3a7
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/ad17b3a7

Branch: refs/heads/develop
Commit: ad17b3a7f314b93957b9a8a0d25fea72238d6cc0
Parents: 8cf9cf3
Author: Christopher Collins <cc...@apache.org>
Authored: Fri Oct 7 13:34:59 2016 -0700
Committer: Christopher Collins <cc...@apache.org>
Committed: Fri Oct 7 13:40:28 2016 -0700

----------------------------------------------------------------------
 sys/log/src/log.c     | 18 ++++++++++++++++++
 sys/log/src/log_fcb.c | 12 ++----------
 2 files changed, 20 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/ad17b3a7/sys/log/src/log.c
----------------------------------------------------------------------
diff --git a/sys/log/src/log.c b/sys/log/src/log.c
index 23714f6..26d4454 100644
--- a/sys/log/src/log.c
+++ b/sys/log/src/log.c
@@ -87,6 +87,23 @@ log_list_get_next(struct log *log)
     return (next);
 }
 
+/**
+ * Indicates whether the specified log has been regiestered.
+ */
+static int
+log_registered(struct log *log)
+{
+    struct log *cur;
+
+    STAILQ_FOREACH(cur, &g_log_list, l_next) {
+        if (cur == log) {
+            return 1;
+        }
+    }
+
+    return 0;
+}
+
 /*
  * Associate an instantiation of a log with the logging infrastructure
  */
@@ -98,6 +115,7 @@ log_register(char *name, struct log *log, const struct log_handler *lh,
     log->l_log = (struct log_handler *)lh;
     log->l_arg = arg;
 
+    assert(!log_registered(log));
     STAILQ_INSERT_TAIL(&g_log_list, log, l_next);
 
     return (0);

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/ad17b3a7/sys/log/src/log_fcb.c
----------------------------------------------------------------------
diff --git a/sys/log/src/log_fcb.c b/sys/log/src/log_fcb.c
index 2e6efca..252c3d1 100644
--- a/sys/log/src/log_fcb.c
+++ b/sys/log/src/log_fcb.c
@@ -156,17 +156,9 @@ log_fcb_copy_entry(struct log *log, struct fcb_entry *entry,
     /* Changing the fcb to be logged to be dst fcb */
     fcb_tmp = &((struct fcb_log *)log->l_arg)->fl_fcb;
 
-    rc = log_register(log->l_name, log, &log_fcb_handler, dst_fcb);
-    if (rc) {
-        goto err;
-    }
-
+    log->l_arg = dst_fcb;
     rc = log_fcb_append(log, data, dlen);
-    if (rc) {
-        goto err;
-    }
-
-    rc = log_register(log->l_name, log, &log_fcb_handler, fcb_tmp);
+    log->l_arg = fcb_tmp;
     if (rc) {
         goto err;
     }