This is an automated email from the ASF dual-hosted git repository.

xiaoxiang781216 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git

commit 4b7b915933ca2a582692f6942f3a94b32fbd8a4d
Author: xuxingliang <[email protected]>
AuthorDate: Tue Dec 9 18:04:25 2025 +0800

    drivers/ramlog: use header size as magic value
    
    The magic number at the start of the ramlog buffer now carries the
    size of struct ramlog_header_s in its low bits, so another CPU that
    reads the buffer, e.g. a different image after a reset, can tell from
    the header where the log data starts.  A buffer with the old magic
    number is reinitialized once.
    
    Signed-off-by: xuxingliang <[email protected]>
---
 drivers/syslog/ramlog.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/syslog/ramlog.c b/drivers/syslog/ramlog.c
index 22ecdc01ec0..33f0b8c694b 100644
--- a/drivers/syslog/ramlog.c
+++ b/drivers/syslog/ramlog.c
@@ -60,7 +60,8 @@
  * Pre-processor Definitions
  ****************************************************************************/
 
-#define RAMLOG_MAGIC_NUMBER 0x12345678
+#define RAMLOG_MAGIC_INIT  0x12340000
+#define RAMLOG_MAGIC_READY (0x56780000 | sizeof(struct ramlog_header_s))
 
 /****************************************************************************
  * Private Types
@@ -399,10 +400,10 @@ static ssize_t ramlog_addbuf(FAR struct ramlog_dev_s 
*priv,
     }
 
 #ifdef CONFIG_RAMLOG_SYSLOG
-  if (header->rl_magic != RAMLOG_MAGIC_NUMBER && priv == &g_sysdev)
+  if (header->rl_magic != RAMLOG_MAGIC_READY && priv == &g_sysdev)
     {
       memset(header, 0, sizeof(g_sysbuffer));
-      header->rl_magic = RAMLOG_MAGIC_NUMBER;
+      header->rl_magic = RAMLOG_MAGIC_READY;
     }
 #endif
 

Reply via email to