From f1ad24b7cc0eca5efdf71788e21f6e976651d61b Mon Sep 17 00:00:00 2001 From: XorTroll Date: Thu, 7 May 2020 17:24:21 +0200 Subject: [PATCH] More small changes --- nx/include/switch/runtime/diag.h | 10 +++---- nx/source/runtime/diag.c | 48 ++++++++++++++++---------------- 2 files changed, 29 insertions(+), 29 deletions(-) diff --git a/nx/include/switch/runtime/diag.h b/nx/include/switch/runtime/diag.h index 0c47852f..af7c0280 100644 --- a/nx/include/switch/runtime/diag.h +++ b/nx/include/switch/runtime/diag.h @@ -11,10 +11,10 @@ /// DiagLogSeverity typedef enum { DiagLogSeverity_Trace = 0, - DiagLogSeverity_Info = 1, - DiagLogSeverity_Warn = 2, + DiagLogSeverity_Info = 1, + DiagLogSeverity_Warn = 2, DiagLogSeverity_Error = 3, - DiagLogSeverity_Fatal = 4 + DiagLogSeverity_Fatal = 4, } DiagLogSeverity; /// DiagSourceInfo @@ -57,13 +57,13 @@ void diagLogImpl(const DiagLogMetadata *metadata); #define DIAG_DETAILED_LOGF(log_severity, log_verbosity, fmt, ...) ({ \ char msg[0x400] = {}; \ - snprintf(msg, 0x400, fmt, ##__VA_ARGS__); \ + snprintf(msg, sizeof(msg), fmt, ##__VA_ARGS__); \ DIAG_DETAILED_LOG(log_severity, log_verbosity, msg); \ }) #define DIAG_DETAILED_VLOG(log_severity, log_verbosity, fmt, args) ({ \ char msg[0x400] = {}; \ - vsnprintf(msg, 0x400, fmt, args); \ + vsnprintf(msg, sizeof(msg), fmt, args); \ DIAG_DETAILED_LOG(log_severity, log_verbosity, msg); \ }) diff --git a/nx/source/runtime/diag.c b/nx/source/runtime/diag.c index 99228cbf..12dd069c 100644 --- a/nx/source/runtime/diag.c +++ b/nx/source/runtime/diag.c @@ -8,40 +8,40 @@ static Mutex g_logMutex; /// DiagLogPacketFlags typedef enum { - DiagLogPacketFlags_Head = BIT(0), ///< First packet. - DiagLogPacketFlags_Tail = BIT(1) ///< Last packet. + DiagLogPacketFlags_Head = BIT(0), ///< First packet. + DiagLogPacketFlags_Tail = BIT(1), ///< Last packet. } DiagLogPacketFlags; /// DiagLogPacketHeader typedef struct { - u64 process_id; ///< Process ID. - u64 thread_id; ///< Thread ID. - u8 flags; ///< \ref DiagLogPacketFlags - u8 pad; ///< Padding - u8 severity; ///< \ref DiagLogSeverity - u8 verbosity; ///< Verbosity. - u32 payload_size; ///< Total packet size after this header. + u64 process_id; ///< Process ID. + u64 thread_id; ///< Thread ID. + u8 flags; ///< \ref DiagLogPacketFlags + u8 pad; ///< Padding + u8 severity; ///< \ref DiagLogSeverity + u8 verbosity; ///< Verbosity. + u32 payload_size; ///< Total packet size after this header. } DiagLogPacketHeader; /// DiagLogDataChunkKey typedef enum { - DiagLogDataChunkKey_LogSessionBegin = 0, ///< Log session begin (unknown) - DiagLogDataChunkKey_LogSessionEnd = 1, ///< Log session end (unknown) - DiagLogDataChunkKey_TextLog = 2, ///< Text to be logged. - DiagLogDataChunkKey_LineNumber = 3, ///< Source line number. - DiagLogDataChunkKey_FileName = 4, ///< Source file name. - DiagLogDataChunkKey_FunctionName = 5, ///< Source function name. - DiagLogDataChunkKey_ModuleName = 6, ///< Process module name. - DiagLogDataChunkKey_ThreadName = 7, ///< Process thread name. - DiagLogDataChunkKey_LogPacketDropCount = 8, ///< Log packet drop count (unknown) - DiagLogDataChunkKey_UserSystemClock = 9, ///< User system clock (unknown) - DiagLogDataChunkKey_ProcessName = 10 ///< Process name. + DiagLogDataChunkKey_LogSessionBegin = 0, ///< Log session begin (unknown) + DiagLogDataChunkKey_LogSessionEnd = 1, ///< Log session end (unknown) + DiagLogDataChunkKey_TextLog = 2, ///< Text to be logged. + DiagLogDataChunkKey_LineNumber = 3, ///< Source line number. + DiagLogDataChunkKey_FileName = 4, ///< Source file name. + DiagLogDataChunkKey_FunctionName = 5, ///< Source function name. + DiagLogDataChunkKey_ModuleName = 6, ///< Process module name. + DiagLogDataChunkKey_ThreadName = 7, ///< Process thread name. + DiagLogDataChunkKey_LogPacketDropCount = 8, ///< Log packet drop count (unknown) + DiagLogDataChunkKey_UserSystemClock = 9, ///< User system clock (unknown) + DiagLogDataChunkKey_ProcessName = 10, ///< Process name. } DiagLogDataChunkKey; /// DiagLogDataChunkTypeHeader (see specific types below) typedef struct { - u8 chunk_key; ///< \ref DiagLogDataChunkKey - u8 chunk_len; ///< Value length. + u8 chunk_key; ///< \ref DiagLogDataChunkKey + u8 chunk_len; ///< Value length. } DiagLogDataChunkTypeHeader; // Specific chunk types. @@ -277,8 +277,8 @@ void diagLogImpl(const DiagLogMetadata *metadata) { remaining_len -= cur_len; } - size_t i = 0; - for(; i < packet_count; i++) { + size_t i; + for(i = 0; i < packet_count; i++) { DiagLogPacket *cur_packet = &packets[i]; cur_packet->header.severity = (u8)metadata->severity; cur_packet->header.verbosity = (u8)metadata->verbosity;