From 30139366edcb1f00c9ff14bdeed82d3fced1a879 Mon Sep 17 00:00:00 2001 From: Jeremy Fitzhardinge Date: Fri, 31 Aug 2012 13:10:29 -0700 Subject: [PATCH] blackbox: fix 64-bit big-endian issues Two issues: 1. when writing out the function name length, don't just write the 4 MSB of the size 2. when reading the time, don't just use the 4 MSB of the time as the timestamp; the log contains a full time_t, so we may as well use it. --- lib/log_blackbox.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/log_blackbox.c b/lib/log_blackbox.c index fd10ac3..06b60d2 100644 --- a/lib/log_blackbox.c +++ b/lib/log_blackbox.c @@ -51,7 +51,7 @@ _blackbox_vlogger(int32_t target, { size_t max_size; size_t actual_size; - size_t fn_size; + uint32_t fn_size; char *chunk; char *msg_len_pt; uint32_t msg_len; @@ -200,7 +200,6 @@ qb_log_blackbox_print_from_file(const char *bb_filename) time_t timestamp; uint32_t msg_len; char message[QB_LOG_MAX_LEN]; - uint32_t u32; bytes_read = qb_rb_chunk_read(instance, chunk, max_size, 0); ptr = chunk; @@ -226,8 +225,7 @@ qb_log_blackbox_print_from_file(const char *bb_filename) ptr += fn_size; /* timestamp size & content */ - memcpy(&u32, ptr, sizeof(uint32_t)); - timestamp = u32; + memcpy(×tamp, ptr, sizeof(time_t)); ptr += sizeof(time_t); tm = localtime(×tamp); if (tm) {