You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by ma...@apache.org on 2016/06/09 21:38:48 UTC
[3/9] incubator-mynewt-core git commit: Fix reboot_log bug
Fix reboot_log bug
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/89012bd0
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/89012bd0
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/89012bd0
Branch: refs/heads/develop
Commit: 89012bd066bac95caae0506b1807fe154147e407
Parents: a450ef9
Author: Vipul Rahane <vi...@runtime.io>
Authored: Wed May 18 19:10:58 2016 -0700
Committer: Vipul Rahane <vi...@runtime.io>
Committed: Thu Jun 9 12:31:59 2016 -0700
----------------------------------------------------------------------
sys/reboot/src/log_reboot.c | 16 ++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/89012bd0/sys/reboot/src/log_reboot.c
----------------------------------------------------------------------
diff --git a/sys/reboot/src/log_reboot.c b/sys/reboot/src/log_reboot.c
index 6d91378..68054dc 100644
--- a/sys/reboot/src/log_reboot.c
+++ b/sys/reboot/src/log_reboot.c
@@ -92,15 +92,18 @@ log_reboot(int reason)
int rc;
char str[12] = {0};
struct image_version ver;
+ int16_t reboot_tmp_cnt;
rc = 0;
- reboot_cnt++;
+ reboot_tmp_cnt = reboot_cnt;
+
/* If the reboot count is equal to soft_reboot */
- if (soft_reboot == (reboot_cnt - 1)) {
+ if (soft_reboot == reboot_cnt) {
+ reboot_tmp_cnt = reboot_cnt + 1;
/* Save the reboot cnt */
rc = conf_save_one(&reboot_conf_handler, "reboot_cnt",
- conf_str_from_value(CONF_INT16, &reboot_cnt,
+ conf_str_from_value(CONF_INT16, &reboot_tmp_cnt,
str, sizeof(str)));
return (rc);
}
@@ -110,8 +113,9 @@ log_reboot(int reason)
* Save reboot count as soft reboot cnt if the reason is
* a soft reboot
*/
+ reboot_tmp_cnt = reboot_cnt + 1;
rc = conf_save_one(&reboot_conf_handler, "soft_reboot",
- conf_str_from_value(CONF_INT16, &reboot_cnt,
+ conf_str_from_value(CONF_INT16, &reboot_tmp_cnt,
str, sizeof(str)));
if (rc) {
goto err;
@@ -123,7 +127,7 @@ log_reboot(int reason)
/* Save the reboot cnt */
rc = conf_save_one(&reboot_conf_handler, "reboot_cnt",
- conf_str_from_value(CONF_INT16, &reboot_cnt,
+ conf_str_from_value(CONF_INT16, &reboot_tmp_cnt,
str, sizeof(str)));
if (rc) {
goto err;
@@ -131,7 +135,7 @@ log_reboot(int reason)
/* Log a reboot */
LOG_CRITICAL(&reboot_log, LOG_MODULE_REBOOT, "rsn:%s, cnt:%u,"
- " img:%u.%u.%u.%u", REBOOT_REASON_STR(reason), reboot_cnt,
+ " img:%u.%u.%u.%u", REBOOT_REASON_STR(reason), reboot_tmp_cnt,
ver.iv_major, ver.iv_minor, ver.iv_revision,
(unsigned int)ver.iv_build_num);
err: