[Linux-cluster] [PATCH 2/4] fence - Remove GNU-isms
Bastian Blank
bastian at waldi.eu.org
Thu Feb 17 18:35:45 UTC 2005
This patch removes the GNU-isms in the die defines and replaces them
with inline functions.
Bastian
--
She won' go Warp 7, Cap'n! The batteries are dead!
-------------- next part --------------
diff -urN -x CVS cvs-patch01-bool/fenced/fd.h cvs-patch02-gnuism/fenced/fd.h
--- cvs-patch01-bool/fenced/fd.h 2005-02-17 18:43:21.000000000 +0100
+++ cvs-patch02-gnuism/fenced/fd.h 2005-02-17 18:43:29.000000000 +0100
@@ -15,6 +15,7 @@
#define __FD_DOT_H__
#include <pthread.h>
+#include <stdarg.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
@@ -57,24 +58,30 @@
#define MAX_NAME_LEN 33
/* use this one before we fork into the background */
-#define die1(fmt, args...) \
-do \
-{ \
- fprintf(stderr, "%s: ", prog_name); \
- fprintf(stderr, fmt "\n", ##args); \
- exit(EXIT_FAILURE); \
-} \
-while (0)
+static inline void die1(const char *fmt, ...)
+{
+ va_list ap;
+ fputs(prog_name, stderr);
+ fputs(": ", stderr);
+ va_start(ap, fmt);
+ vfprintf(stderr, fmt, ap);
+ va_end(ap);
+ fputs("\n", stderr);
+ exit(EXIT_FAILURE);
+}
-#define die(fmt, args...) \
-do \
-{ \
- fprintf(stderr, "%s: ", prog_name); \
- fprintf(stderr, fmt "\n", ##args); \
- syslog(LOG_ERR, fmt, ##args); \
- exit(EXIT_FAILURE); \
-} \
-while (0)
+static inline void die(const char *fmt, ...)
+{
+ va_list ap;
+ fputs(prog_name, stderr);
+ fputs(": ", stderr);
+ va_start(ap, fmt);
+ vfprintf(stderr, fmt, ap);
+ fputs("\n", stderr);
+ vsyslog(LOG_ERR, fmt, ap);
+ va_end(ap);
+ exit(EXIT_FAILURE);
+}
#define FENCE_ASSERT(x, todo) \
do \
diff -urN -x CVS cvs-patch01-bool/fence_node/fence_node.c cvs-patch02-gnuism/fence_node/fence_node.c
--- cvs-patch01-bool/fence_node/fence_node.c 2005-02-10 06:33:28.000000000 +0100
+++ cvs-patch02-gnuism/fence_node/fence_node.c 2005-02-17 18:25:38.000000000 +0100
@@ -11,6 +11,7 @@
*******************************************************************************
******************************************************************************/
+#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
@@ -22,21 +23,24 @@
#define OPTION_STRING ("hOuV")
-#define die(fmt, args...) \
-do \
-{ \
- fprintf(stderr, "%s: ", prog_name); \
- fprintf(stderr, fmt "\n", ##args); \
- exit(EXIT_FAILURE); \
-} \
-while (0)
-
static char *prog_name;
static int unfence;
static int force;
int dispatch_fence_agent(int cd, char *victim, int in);
+static inline void die(const char *fmt, ...)
+{
+ va_list ap;
+ fputs(prog_name, stderr);
+ fputs(": ", stderr);
+ va_start(ap, fmt);
+ vfprintf(stderr, fmt, ap);
+ va_end(ap);
+ fputs("\n", stderr);
+ exit(EXIT_FAILURE);
+}
+
static void print_usage(void)
{
printf("Usage:\n");
diff -urN -x CVS cvs-patch01-bool/fence_tool/fence_tool.c cvs-patch02-gnuism/fence_tool/fence_tool.c
--- cvs-patch01-bool/fence_tool/fence_tool.c 2005-02-17 18:09:30.000000000 +0100
+++ cvs-patch02-gnuism/fence_tool/fence_tool.c 2005-02-17 18:19:19.000000000 +0100
@@ -17,6 +17,7 @@
#include <stddef.h>
#include <signal.h>
#include <string.h>
+#include <stdarg.h>
#include <stdbool.h>
#include <stdint.h>
#include <sys/ioctl.h>
@@ -42,16 +43,6 @@
#define OP_MONITOR 3
#define OP_WAIT 4
-
-#define die(fmt, args...) \
-do \
-{ \
- fprintf(stderr, "%s: ", prog_name); \
- fprintf(stderr, fmt "\n", ##args); \
- exit(EXIT_FAILURE); \
-} \
-while (0)
-
char *prog_name;
bool debug = false;
int operation;
@@ -62,6 +53,17 @@
int dispatch_fence_agent(int cd, char *victim, int in);
+static inline void die(const char *fmt, ...)
+{
+ va_list ap;
+ fputs(prog_name, stderr);
+ fputs(": ", stderr);
+ va_start(ap, fmt);
+ vfprintf(stderr, fmt, ap);
+ va_end(ap);
+ fputs("\n", stderr);
+ exit(EXIT_FAILURE);
+}
static int check_mounted(void)
{
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 197 bytes
Desc: Digital signature
URL: <http://listman.redhat.com/archives/linux-cluster/attachments/20050217/b835bf86/attachment.sig>
More information about the Linux-cluster
mailing list