[PATCH v7 05/15] Add ErrorFSigSafe() alternative to ErrorF()

Peter Hutterer peter.hutterer at who-t.net
Wed Jun 20 22:56:36 PDT 2012


From: Chase Douglas <chase.douglas at canonical.com>

ErrorF() is not signal safe. Use ErrorSigSafe() whenever an error
message may be logged in signal context.

[whot: edited to "ErrorFSigSafe"]

Signed-off-by: Chase Douglas <chase.douglas at canonical.com>
Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>
---
Changes to previous version:
- ErrorFSigSafe, to be consistent with naming.

 include/os.h |    6 ++++++
 os/log.c     |   16 ++++++++++++++++
 2 files changed, 22 insertions(+)

diff --git a/include/os.h b/include/os.h
index b3f9088..e93c48a 100644
--- a/include/os.h
+++ b/include/os.h
@@ -656,6 +656,12 @@ extern _X_EXPORT void
 ErrorF(const char *f, ...)
 _X_ATTRIBUTE_PRINTF(1, 2);
 extern _X_EXPORT void
+VErrorFSigSafe(const char *f, va_list args)
+_X_ATTRIBUTE_PRINTF(1, 0);
+extern _X_EXPORT void
+ErrorFSigSafe(const char *f, ...)
+_X_ATTRIBUTE_PRINTF(1, 2);
+extern _X_EXPORT void
 LogPrintMarkers(void);
 
 extern _X_EXPORT void
diff --git a/os/log.c b/os/log.c
index a3c1305..6048246 100644
--- a/os/log.c
+++ b/os/log.c
@@ -771,6 +771,22 @@ ErrorF(const char *f, ...)
 }
 
 void
+VErrorFSigSafe(const char *f, va_list args)
+{
+    LogVMessageVerbSigSafe(X_ERROR, -1, f, args);
+}
+
+void
+ErrorFSigSafe(const char *f, ...)
+{
+    va_list args;
+
+    va_start(args, f);
+    VErrorFSigSafe(f, args);
+    va_end(args);
+}
+
+void
 LogPrintMarkers(void)
 {
     /* Show what the message marker symbols mean. */
-- 
1.7.10.2



More information about the xorg-devel mailing list