From 391d103bfd69d27a574249d876281a9ed6cafc88 Mon Sep 17 00:00:00 2001 From: David Sidrane Date: Thu, 5 Oct 2017 12:48:13 -1000 Subject: [PATCH] hardfault_log:Not having a ulog file to append to is not an error The hardfault keeps track of the number of reboot without a commit to disk. A commit to disk is the act of writing the fault data from the bbsram to the hardfault file, not the ulog file. The sucessful commit rearms the hardfault system. When ulog appending was added it treated the lack of a ulog file as an error. This prevented the hardfault_log reset from being called because the hardfault_log commit returned an error. if hardfault_log check then if hardfault_log commit then hardfault_log reset fi fi This change treats the lack a a ulog as a non error. --- src/systemcmds/hardfault_log/hardfault_log.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/systemcmds/hardfault_log/hardfault_log.c b/src/systemcmds/hardfault_log/hardfault_log.c index 4fd1def5aa..aefe55d8a5 100644 --- a/src/systemcmds/hardfault_log/hardfault_log.c +++ b/src/systemcmds/hardfault_log/hardfault_log.c @@ -617,6 +617,10 @@ static int hardfault_append_to_ulog(const char *caller, int fdin) close(fd); ulog_file_name[HARDFAULT_MAX_ULOG_FILE_LEN - 1] = 0; //ensure null-termination + if (strlen(ulog_file_name) == 0) { + return -ENOENT; + } + identify(caller); syslog(LOG_INFO, "Appending to ULog %s\n", ulog_file_name); @@ -823,14 +827,21 @@ static int hardfault_commit(char *caller) // .txt file around, since that is a bit less prone to FS errors than the ULog if (ret == OK) { ret = hardfault_append_to_ulog(caller, fdout); + identify(caller); - if (ret == OK) { - identify(caller); + switch (ret) { + case OK: syslog(LOG_INFO, "Successfully appended to ULog\n"); + break; + + case -ENOENT: + syslog(LOG_INFO, "No ULog to append to\n"); + ret = OK; + break; - } else { - identify(caller); + default: syslog(LOG_INFO, "Failed to append to ULog (%i)\n", ret); + break; } }