Re: [PATCH 00/14] multipath-tools series: some cleanups and fixes checked by codedex tool

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello Lixiaokeng,

On Wed, 2020-09-02 at 14:40 +0800, lixiaokeng wrote:
> Hi:
>     Now, we check multipath-tools codes with codedex tool. Here
> are some some cleanups and fixes.

Thank you. However I'm going to nack all patches that add error
messages after unsuccesful memory allocations. Such messages are
unhelpful most of the time, and increase the code size without a true
benefit. I've actually considered to get rid of all these, and replace
them by a log_oom() macro.

See an untested prototype attached, to better understand what I mean.

Regards
Martin


From fbbca2c5076a489ee4ae643d6d9199ca5085be95 Mon Sep 17 00:00:00 2001
From: Martin Wilck <mwilck@xxxxxxxx>
Date: Thu, 3 Sep 2020 22:03:22 +0200
Subject: [PATCH] libmultipath: prototype implementation of log_oom()

Rationale: with VERBOSE_OOM_LOGGING, we log the part of the code
where OOM occured, with minimal runtime effort (no string formatting).
With lots of log_oom() invocations, our binary will increase by many
static strings. Without VERBOSE_OOM_LOGGING, we just print a minimal
error message, which will be enough most of the time.

Signed-off-by: Martin Wilck <mwilck@xxxxxxxx>
---
 libmultipath/debug.c | 7 +++++++
 libmultipath/debug.h | 8 ++++++++
 2 files changed, 15 insertions(+)

diff --git a/libmultipath/debug.c b/libmultipath/debug.c
index 4128cb9..9062581 100644
--- a/libmultipath/debug.c
+++ b/libmultipath/debug.c
@@ -48,3 +48,10 @@ void dlog (int sink, int prio, const char * fmt, ...)
 	}
 	va_end(ap);
 }
+
+#ifndef VERBOSE_OOM_LOGGING
+void log_oom(void)
+{
+	condlog(0, "Out of memory");
+}
+#endif
diff --git a/libmultipath/debug.h b/libmultipath/debug.h
index c6120c1..f61ecb6 100644
--- a/libmultipath/debug.h
+++ b/libmultipath/debug.h
@@ -11,3 +11,11 @@ extern int logsink;
 
 #define condlog(prio, fmt, args...) \
 	dlog(logsink, prio, fmt "\n", ##args)
+
+#ifdef VERBOSE_OOM_LOGGING
+#define __log_oom(file, line) condlog(0, "Out of memory in " file ":" #line)
+#define _log_oom(file, line) __log_oom(file, line)
+#define log_oom() _log_oom(__FILE__, __LINE__)
+#else
+void log_oom(void);
+#endif
-- 
2.28.0

--
dm-devel mailing list
dm-devel@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/dm-devel

[Index of Archives]     [DM Crypt]     [Fedora Desktop]     [ATA RAID]     [Fedora Marketing]     [Fedora Packaging]     [Fedora SELinux]     [Yosemite Discussion]     [KDE Users]     [Fedora Docs]

  Powered by Linux