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

[Linux-cluster] [PATCH 1/4] fence - Use bools instead of crude defines



This patch uses C99 bools instead of crude defines.

Bastian

-- 
Virtue is a relative term.
		-- Spock, "Friday's Child", stardate 3499.1
diff -urN -x CVS cvs/fenced/fd.h cvs-patch01-bool/fenced/fd.h
--- cvs/fenced/fd.h	2005-02-15 04:58:00.000000000 +0100
+++ cvs-patch01-bool/fenced/fd.h	2005-02-17 18:43:21.000000000 +0100
@@ -14,12 +14,8 @@
 #ifndef __FD_DOT_H__
 #define __FD_DOT_H__
 
-#ifndef TRUE
-#define TRUE 1
-#define FALSE 0
-#endif
-
 #include <pthread.h>
+#include <stdbool.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <stddef.h>
@@ -44,7 +40,7 @@
 
 
 extern char *             prog_name;
-extern int                fenced_debug;
+extern bool               fenced_debug;
 extern int                debug_sock;
 extern char               debug_buf[256];
 extern struct sockaddr_un debug_addr;
@@ -129,10 +125,10 @@
 	int debug;
 	int post_join_delay;
 	int post_fail_delay;
-	int8_t clean_start;
-	int8_t post_join_delay_opt;
-	int8_t post_fail_delay_opt;
-	int8_t clean_start_opt;
+	int clean_start;
+	bool post_join_delay_opt;
+	bool post_fail_delay_opt;
+	bool clean_start_opt;
 };
 
 #define FDFL_RUN        (0)
@@ -150,7 +146,7 @@
 	int 			last_start;
 	int 			last_finish;
 
-	int			first_recovery;
+	bool			first_recovery;
 	int 			prev_count;
 	struct list_head 	prev;
 	struct list_head 	victims;
diff -urN -x CVS cvs/fenced/main.c cvs-patch01-bool/fenced/main.c
--- cvs/fenced/main.c	2005-02-15 04:56:15.000000000 +0100
+++ cvs-patch01-bool/fenced/main.c	2005-02-17 18:13:07.000000000 +0100
@@ -391,7 +391,7 @@
 
 	/* If an option was set on the command line, don't set it from ccs. */
 
-	if (fd->comline->clean_start_opt == FALSE) {
+	if (fd->comline->clean_start_opt == false) {
 		str = NULL;
 	        memset(path, 0, 256);
 	        sprintf(path, "/cluster/fence_daemon/@clean_start");
@@ -405,7 +405,7 @@
 			free(str);
 	}
 
-	if (fd->comline->post_join_delay_opt == FALSE) {
+	if (fd->comline->post_join_delay_opt == false) {
 		str = NULL;
 	        memset(path, 0, 256);
 	        sprintf(path, "/cluster/fence_daemon/@post_join_delay");
@@ -419,7 +419,7 @@
 			free(str);
 	}
 
-	if (fd->comline->post_fail_delay_opt == FALSE) {
+	if (fd->comline->post_fail_delay_opt == false) {
 		str = NULL;
 	        memset(path, 0, 256);
 	        sprintf(path, "/cluster/fence_daemon/@post_fail_delay");
@@ -508,7 +508,7 @@
 	fd->namelen = namelen;
 
 	fd->comline = comline;
-	fd->first_recovery = FALSE;
+	fd->first_recovery = false;
 	fd->last_stop = 0;
 	fd->last_start = 0;
 	fd->last_finish = 0;
@@ -523,12 +523,12 @@
 
 static void decode_arguments(int argc, char **argv, commandline_t *comline)
 {
-	int cont = TRUE;
+	bool cont = true;
 	int optchar;
 
-	comline->post_join_delay_opt = FALSE;
-	comline->post_fail_delay_opt = FALSE;
-	comline->clean_start_opt = FALSE;
+	comline->post_join_delay_opt = false;
+	comline->post_fail_delay_opt = false;
+	comline->clean_start_opt = false;
 
 	while (cont) {
 		optchar = getopt(argc, argv, OPTION_STRING);
@@ -537,22 +537,22 @@
 
 		case 'c':
 			comline->clean_start = 1;
-			comline->clean_start_opt = TRUE;
+			comline->clean_start_opt = true;
 			break;
 
 		case 'j':
 			comline->post_join_delay = atoi(optarg);
-			comline->post_join_delay_opt = TRUE;
+			comline->post_join_delay_opt = true;
 			break;
 
 		case 'f':
 			comline->post_fail_delay = atoi(optarg);
-			comline->post_fail_delay_opt = TRUE;
+			comline->post_fail_delay_opt = true;
 			break;
 
 		case 'D':
-			comline->debug = TRUE;
-			fenced_debug = TRUE;
+			comline->debug = true;
+			fenced_debug = true;
 			break;
 
 		case 'n':
@@ -584,7 +584,7 @@
 			break;
 
 		case EOF:
-			cont = FALSE;
+			cont = false;
 			break;
 
 		default:
@@ -658,7 +658,7 @@
 }
 
 char *prog_name;
-int fenced_debug;
+bool fenced_debug = false;
 int debug_sock;
 char debug_buf[256];
 struct sockaddr_un debug_addr;
diff -urN -x CVS cvs/fenced/recover.c cvs-patch01-bool/fenced/recover.c
--- cvs/fenced/recover.c	2005-02-10 06:33:29.000000000 +0100
+++ cvs-patch01-bool/fenced/recover.c	2005-02-17 18:15:56.000000000 +0100
@@ -69,14 +69,14 @@
 	return node;
 }
 
-static int name_equal(fd_node_t *node1, struct cl_cluster_node *node2)
+static bool name_equal(fd_node_t *node1, struct cl_cluster_node *node2)
 {
 	char name1[64], name2[64];
 	int i, len1, len2;
 
 	if ((node1->namelen == strlen(node2->name) &&
 	     !strncmp(node1->name, node2->name, node1->namelen)))
-		return TRUE;
+		return true;
 
 	memset(name1, 0, 64);
 	memset(name2, 0, 64);
@@ -98,9 +98,9 @@
 	}
 
 	if (!strncmp(name1, name2, strlen(name1)))
-		return TRUE;
+		return true;
 
-	return FALSE;
+	return false;
 }
 
 static uint32_t next_complete_nodeid(fd_t *fd, uint32_t gt)
@@ -155,7 +155,7 @@
 	return low;
 }
 
-static int can_avert_fence(fd_t *fd, fd_node_t *victim)
+static bool can_avert_fence(fd_t *fd, fd_node_t *victim)
 {
 	struct cl_cluster_node cl_node;
 	int error;
@@ -166,15 +166,15 @@
 
 	error = ioctl(fd->cl_sock, SIOCCLUSTER_GETNODE, &cl_node);
 	if (error < 0)
-		return FALSE;
+		return false;
 
 	log_debug("state of node %s is %d", victim->name, cl_node.state);
 
 	if (cl_node.state == NODESTATE_MEMBER ||
 	    cl_node.state == NODESTATE_JOINING)
-		return TRUE;
+		return true;
 
-        return FALSE;
+        return false;
 }
 
 static void free_node_list(struct list_head *head)
@@ -230,7 +230,7 @@
 	fd->prev_count = ev->node_count;
 }
 
-static int in_cl_nodes(struct cl_cluster_node *cl_nodes, fd_node_t *node,
+static bool in_cl_nodes(struct cl_cluster_node *cl_nodes, fd_node_t *node,
 		       int num_nodes)
 {
 	struct cl_cluster_node *cl_node = cl_nodes;
@@ -238,10 +238,10 @@
 
 	for (i = 0; i < num_nodes; i++) {
 		if (name_equal(node, cl_node))
-			return TRUE;
+			return true;
 		cl_node++;
 	}
-	return FALSE;
+	return false;
 }
 
 static int get_members(fd_t *fd, struct cl_cluster_node **cl_nodes)
@@ -308,7 +308,7 @@
 	free(cl_nodes);
 }
 
-static int id_in_cl_nodes(struct cl_cluster_node *cl_nodes, uint32_t nodeid,
+static bool id_in_cl_nodes(struct cl_cluster_node *cl_nodes, uint32_t nodeid,
 			  int num_nodes)
 {
 	struct cl_cluster_node *cl_node = cl_nodes;
@@ -316,10 +316,10 @@
 
 	for (i = 0; i < num_nodes; i++) {
 		if (nodeid == cl_node->node_id)
-			return TRUE;
+			return true;
 		cl_node++;
 	}
-	return FALSE;
+	return false;
 }
 
 static int list_count(struct list_head *head)
@@ -522,7 +522,7 @@
 	if (!fd->last_finish && fd->last_stop) {
 		log_debug("revert aborted first start");
 		fd->last_stop = 0;
-		fd->first_recovery = FALSE;
+		fd->first_recovery = false;
 		free_prev(fd);
 		free_victims(fd);
 		free_leaving(fd);
@@ -532,7 +532,7 @@
 		  fd->last_stop, fd->last_start, fd->last_finish);
 
 	if (!fd->first_recovery) {
-		fd->first_recovery = TRUE;
+		fd->first_recovery = true;
 		add_first_victims(fd);
 	} else
 		add_victims(fd, ev, cl_nodes);
diff -urN -x CVS cvs/fence_tool/fence_tool.c cvs-patch01-bool/fence_tool/fence_tool.c
--- cvs/fence_tool/fence_tool.c	2005-02-15 04:54:40.000000000 +0100
+++ cvs-patch01-bool/fence_tool/fence_tool.c	2005-02-17 18:09:30.000000000 +0100
@@ -17,6 +17,7 @@
 #include <stddef.h>
 #include <signal.h>
 #include <string.h>
+#include <stdbool.h>
 #include <stdint.h>
 #include <sys/ioctl.h>
 #include <sys/types.h>
@@ -32,11 +33,6 @@
 #include "ccs.h"
 #include "copyright.cf"
 
-#ifndef TRUE
-#define TRUE 1
-#define FALSE 0
-#endif
-
 #define OPTION_STRING			("VhScj:f:Dw")
 #define LOCKFILE_NAME                   "/var/run/fenced.pid"
 #define FENCED_SOCK_PATH                "fenced_socket"
@@ -57,10 +53,10 @@
 while (0)
 
 char *prog_name;
-int debug;
+bool debug = false;
 int operation;
-int skip_unfence;
-int child_wait;
+bool skip_unfence = false;
+bool child_wait = false;
 int cl_sock;
 char our_name[MAX_CLUSTER_MEMBER_NAME_LEN+1];
 
@@ -380,7 +376,7 @@
 
 static void decode_arguments(int argc, char *argv[])
 {
-	int cont = TRUE;
+	bool cont = true;
 	int optchar;
 
 	while (cont) {
@@ -401,15 +397,15 @@
 			break;
 
 		case 'S':
-			skip_unfence = TRUE;
+			skip_unfence = true;
 			break;
 
 		case 'D':
-			debug = TRUE;
+			debug = true;
 			break;
 
 		case 'w':
-			child_wait = TRUE;
+			child_wait = true;
 			break;
 
 		case ':':
@@ -419,7 +415,7 @@
 			break;
 
 		case EOF:
-			cont = FALSE;
+			cont = false;
 			break;
 
 		case 'c':

Attachment: signature.asc
Description: Digital signature


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