Patchwork [2/4] multipath-tools: libdmmp: Allow log function as NULL.

login
register
mail settings
Submitter Gris Ge
Date Nov. 21, 2017, 2:09 p.m.
Message ID <20171121140917.18298-3-fge@redhat.com>
Download mbox | patch
Permalink /patch/10068229/
State Not Applicable, archived
Delegated to: christophe varoqui
Headers show

Comments

Gris Ge - Nov. 21, 2017, 2:09 p.m.
* Do nothing when user set log function to NULL.
 * Update document to reflect so.

Signed-off-by: Gris Ge <fge@redhat.com>
---
 libdmmp/libdmmp.c         | 3 +++
 libdmmp/libdmmp/libdmmp.h | 3 ++-
 2 files changed, 5 insertions(+), 1 deletion(-)

Patch

diff --git a/libdmmp/libdmmp.c b/libdmmp/libdmmp.c
index b4e7f08f..74cdb0a6 100644
--- a/libdmmp/libdmmp.c
+++ b/libdmmp/libdmmp.c
@@ -89,6 +89,9 @@  void _dmmp_log(struct dmmp_context *ctx, int priority, const char *file,
 {
 	va_list args;
 
+	if (ctx->log_func == NULL)
+		return;
+
 	va_start(args, format);
 	ctx->log_func(ctx, priority, file, line, func_name, format, args);
 	va_end(args);
diff --git a/libdmmp/libdmmp/libdmmp.h b/libdmmp/libdmmp/libdmmp.h
index 72b79b97..6e233e4f 100644
--- a/libdmmp/libdmmp/libdmmp.h
+++ b/libdmmp/libdmmp/libdmmp.h
@@ -258,7 +258,8 @@  DMMP_DLL_EXPORT int dmmp_context_log_priority_get(struct dmmp_context *ctx);
  *	Pointer of 'struct dmmp_context'.
  *	If this pointer is NULL, your program will be terminated by assert.
  * @log_func:
- *	Pointer of log handler function.
+ *	Pointer of log handler function. If set to NULL, all log will be
+ *	ignored.
  *
  * Return:
  *	void