[fedfs-utils] [PATCH 3/8] libxlog: Remove hidden calls to exit(2)

Chuck Lever chuck.lever at oracle.com
Mon Oct 21 14:51:01 PDT 2013


A packaging lint program caught a reference to exit(2) in our
plug-in library.  This call site was in libxlog, which is invoked
from all of our libraries.  As a rule, libraries should never exit
out from under running programs.

Fortunately, no-one in fedfs-utils uses L_FATAL or invokes
xlog_err().  This exit(2) call is never invoked during run-time,
and is safe to simply remove.

Signed-off-by: Chuck Lever <chuck.lever at oracle.com>
---
 src/include/xlog.h |    4 +---
 src/libxlog/xlog.c |   22 ----------------------
 2 files changed, 1 insertion(+), 25 deletions(-)

diff --git a/src/include/xlog.h b/src/include/xlog.h
index 9c9ec75..44f5efe 100644
--- a/src/include/xlog.h
+++ b/src/include/xlog.h
@@ -12,8 +12,7 @@
 
 #include <stdarg.h>
 
-/* These are logged always. L_FATAL also does exit(1) */
-#define L_FATAL		0x0100
+/* These are logged always. */
 #define L_ERROR		0x0200
 #define L_WARNING	0x0400
 #define L_NOTICE	0x0800
@@ -47,7 +46,6 @@ void	xlog_sconfig(char *, int on);
 int	xlog_enabled(int fac);
 void	xlog(int fac, const char *fmt, ...);
 void	xlog_warn(const char *fmt, ...);
-void	xlog_err(const char *fmt, ...);
 void	xlog_backend(int fac, const char *fmt, va_list args);
 
 #endif	/* !_FEDFS_XLOG_H_ */
diff --git a/src/libxlog/xlog.c b/src/libxlog/xlog.c
index cc21abc..8140b74 100644
--- a/src/libxlog/xlog.c
+++ b/src/libxlog/xlog.c
@@ -17,7 +17,6 @@
 #include <unistd.h>
 #include <signal.h>
 #include <time.h>
-#include <stdlib.h>
 #include <string.h>
 #include <stdio.h>
 #include <stdarg.h>
@@ -191,9 +190,6 @@ xlog_backend(int kind, const char *fmt, va_list args)
 
 	if (log_syslog) {
 		switch (kind) {
-		case L_FATAL:
-			vsyslog(LOG_ERR, fmt, args);
-			break;
 		case L_ERROR:
 			vsyslog(LOG_ERR, fmt, args);
 			break;
@@ -228,9 +224,6 @@ xlog_backend(int kind, const char *fmt, va_list args)
 		fprintf(stderr, "\n");
 		va_end(args2);
 	}
-
-	if (kind == L_FATAL)
-		exit(1);
 }
 
 /**
@@ -263,18 +256,3 @@ xlog_warn(const char* fmt, ...)
 	xlog_backend(L_WARNING, fmt, args);
 	va_end(args);
 }
-
-/**
- * Post a fatal log message
- *
- * @param fmt NUL-terminated C string containing printf-style format
- */
-void
-xlog_err(const char* fmt, ...)
-{
-	va_list args;
-
-	va_start(args, fmt);
-	xlog_backend(L_FATAL, fmt, args);
-	va_end(args);
-}




More information about the fedfs-utils-devel mailing list