From eac6599c5ec8374d775f149a90b4718e7f6c082c Mon Sep 17 00:00:00 2001 From: Alasdair Kergon Date: Wed, 15 Jul 2009 14:18:38 +0000 Subject: [PATCH] New LOG_MESG macro to fix file/line number logging for memory leaks after LOG_LINENO macro was added. --- WHATS_NEW_DM | 3 ++- libdm/misc/dm-logging.h | 8 +++++--- libdm/mm/dbg_malloc.c | 2 +- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/WHATS_NEW_DM b/WHATS_NEW_DM index 408f27b8f..df1943737 100644 --- a/WHATS_NEW_DM +++ b/WHATS_NEW_DM @@ -1,6 +1,7 @@ Version 1.02.34 - 15th July 2009 ================================ - Rename plog macro to LOG_LINE and use in dm_dump_memory_debug. + Use _exit() not exit() after forking to avoid flushing libc buffers twice. + Rename plog macro to LOG_LINE & add LOG_MESG variant for dm_dump_memory_debug. Change plog to use dm_log_with_errno unless deprecated dm_log_init was used. Add dm_log_with_errno and dm_log_with_errno_init, deprecating the old fns. Fix whitespace in linear target line to fix identical table line detection. diff --git a/libdm/misc/dm-logging.h b/libdm/misc/dm-logging.h index d2f235917..ee3ed34ef 100644 --- a/libdm/misc/dm-logging.h +++ b/libdm/misc/dm-logging.h @@ -21,14 +21,16 @@ extern dm_log_fn dm_log; extern dm_log_with_errno_fn dm_log_with_errno; -#define LOG_LINE(l, x...) \ +#define LOG_MESG(l, f, ln, x...) \ do { \ if (dm_log_is_non_default()) \ - dm_log(l, __FILE__, __LINE__, ## x); \ + dm_log(l, f, ln, ## x); \ else \ - dm_log_with_errno(l, __FILE__, __LINE__, 0, ## x); \ + dm_log_with_errno(l, f, ln, 0, ## x); \ } while (0) +#define LOG_LINE(l, x...) LOG_MESG(l, __FILE__, __LINE__, ## x) + #include "log.h" #endif diff --git a/libdm/mm/dbg_malloc.c b/libdm/mm/dbg_malloc.c index 24ddc37c9..ea9720889 100644 --- a/libdm/mm/dbg_malloc.c +++ b/libdm/mm/dbg_malloc.c @@ -205,7 +205,7 @@ int dm_dump_memory_debug(void) } str[sizeof(str) - 1] = '\0'; - LOG_LINE(_LOG_INFO, mb->file, mb->line, + LOG_MESG(_LOG_INFO, mb->file, mb->line, "block %d at %p, size %" PRIsize_t "\t [%s]", mb->id, mb->magic, mb->length, str); tot += mb->length; -- 2.43.5