diff --git a/src/http2.c b/src/http2.c index 7334810..c0b3bd2 100644 --- a/src/http2.c +++ b/src/http2.c @@ -46,7 +46,7 @@ static ssize_t file_read_callback(nghttp2_session* session, int32_t stream_id, int fd = source->fd; ssize_t nread; - while ((nread = read(fd, buf, length)) == -1 && errno == EINTR); + while ((nread = read(fd, buf, length)) == -1 && errno == EINTR) {} if (nread == -1) { diff --git a/src/logging.c b/src/logging.c index 1c6c0f1..de8d16f 100644 --- a/src/logging.c +++ b/src/logging.c @@ -53,7 +53,7 @@ static PerfTracker g_perf_trackers[MAX_PERF_TRACKERS]; static pthread_mutex_t g_perf_mutex = PTHREAD_MUTEX_INITIALIZER; // Get color for log level -static const char* get_level_color(LogLevel level) +static const char* get_level_color(const LogLevel level) { switch (level) { @@ -207,7 +207,7 @@ static void ensure_log_directory(void) } } -void log_init(LogConfig* config) +void log_init(const LogConfig* config) { pthread_mutex_lock(&g_log_mutex); @@ -233,21 +233,21 @@ void log_cleanup(void) pthread_mutex_unlock(&g_log_mutex); } -void log_set_level(LogLevel level) +void log_set_level(const LogLevel level) { pthread_mutex_lock(&g_log_mutex); g_log_config.level = level; pthread_mutex_unlock(&g_log_mutex); } -void log_set_categories(LogCategory categories) +void log_set_categories(const LogCategory categories) { pthread_mutex_lock(&g_log_mutex); g_log_config.categories = categories; pthread_mutex_unlock(&g_log_mutex); } -void log_write(LogLevel level, LogCategory category, const char* file, +void log_write(const LogLevel level, const LogCategory category, const char* file, int line, const char* func, const char* fmt, ...) { // Quick check without lock @@ -376,7 +376,7 @@ void log_event(const char* message) } // Secure logging - sanitizes potentially sensitive data -void log_secure(LogLevel level, LogCategory category, const char* fmt, ...) +void log_secure(const LogLevel level, const LogCategory category, const char* fmt, ...) { char message[4096]; va_list args; @@ -460,7 +460,7 @@ void log_perf_end(const char* operation) if (g_perf_trackers[i].active && strcmp(g_perf_trackers[i].operation, operation) == 0) { - long elapsed_us = (end_time.tv_sec - g_perf_trackers[i].start_time.tv_sec) * 1000000 + + const long elapsed_us = (end_time.tv_sec - g_perf_trackers[i].start_time.tv_sec) * 1000000 + (end_time.tv_usec - g_perf_trackers[i].start_time.tv_usec); g_perf_trackers[i].active = false; diff --git a/src/logging.h b/src/logging.h index e4d3f4f..0910f5f 100644 --- a/src/logging.h +++ b/src/logging.h @@ -55,7 +55,7 @@ typedef struct } LogConfig; // Initialize the logging system -void log_init(LogConfig* config); +void log_init(const LogConfig* config); // Cleanup logging system void log_cleanup(void);