Better patch included

Honza

Steven Dake napsal(a):
On 06/02/2011 12:19 AM, Jan Friesse wrote:
Steven Dake wrote:
On 06/01/2011 09:14 AM, Jan Friesse wrote:
Signed-off-by: Jan Friesse <jfrie...@redhat.com>
---
 exec/mainconfig.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/exec/mainconfig.c b/exec/mainconfig.c
index 44bd47a..c7df8c6 100644
--- a/exec/mainconfig.c
+++ b/exec/mainconfig.c
@@ -614,7 +614,9 @@ static void 
main_objdb_reload_notify(objdb_reload_notify_type_t type, int flush,
                /*
                 * Reload the logsys configuration
                 */
-               logsys_format_set(NULL);
+               if (logsys_format_set(NULL) < 0) {
+                       fprintf (stderr, "Unable to setup logging format.\n");
+               }
                corosync_main_config_read_logging(global_objdb,
                                                  &error_string);
        }

please check for == -1 rather then < 0.

Regards
-steve
Take a look to:
include/corosync/engine/logsys.h:319.
I was trying to be consistent, so I would prefer ether both checked for
-1 or both < 0. I don't have strong opinion which option is better.


Somewhat arbitrary what the code does today, but if the error code is
always -1, we should always check for -1 to prevent a situation where
other results may trigger unintended consequences.


>From aac4a543b548bad7d63c2cb7e68c399bb2920e43 Mon Sep 17 00:00:00 2001
From: Jan Friesse <jfrie...@redhat.com>
Date: Mon, 30 May 2011 13:02:36 +0200
Subject: [PATCH] mainconfig: Check retval of logsys_format_set

Signed-off-by: Jan Friesse <jfrie...@redhat.com>
---
 exec/mainconfig.c                |    4 +++-
 include/corosync/engine/logsys.h |    2 +-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/exec/mainconfig.c b/exec/mainconfig.c
index 44bd47a..70984f9 100644
--- a/exec/mainconfig.c
+++ b/exec/mainconfig.c
@@ -614,7 +614,9 @@ static void main_objdb_reload_notify(objdb_reload_notify_type_t type, int flush,
 		/*
 		 * Reload the logsys configuration
 		 */
-		logsys_format_set(NULL);
+		if (logsys_format_set(NULL) == -1) {
+			fprintf (stderr, "Unable to setup logging format.\n");
+		}
 		corosync_main_config_read_logging(global_objdb,
 						  &error_string);
 	}
diff --git a/include/corosync/engine/logsys.h b/include/corosync/engine/logsys.h
index 010684c..e789b65 100644
--- a/include/corosync/engine/logsys.h
+++ b/include/corosync/engine/logsys.h
@@ -316,7 +316,7 @@ static void logsys_system_init (void)					\
 		exit (-1);						\
 	}								\
 									\
-	if (logsys_format_set (format) < 0) {				\
+	if (logsys_format_set (format) == -1) {				\
 		fprintf (stderr,					\
 			"Unable to setup logging format.\n");		\
 		exit (-1);						\
-- 
1.7.3

_______________________________________________
Openais mailing list
Openais@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/openais

Reply via email to