[Libguestfs] [PATCH 2/3] daemon: move AUGEAS_ERROR to the common header

Pino Toscano ptoscano at redhat.com
Tue Aug 26 14:29:10 UTC 2014


Other than for current aug_* API, it will be useful for further code
using augeas directly.
---
 daemon/augeas.c | 17 -----------------
 daemon/daemon.h | 17 +++++++++++++++++
 2 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/daemon/augeas.c b/daemon/augeas.c
index e31cab4..74f3ba7 100644
--- a/daemon/augeas.c
+++ b/daemon/augeas.c
@@ -55,23 +55,6 @@ aug_finalize (void)
   }									\
   while (0)
 
-/* Calls reply_with_error, but includes the Augeas error details. */
-#define AUGEAS_ERROR(fs,...)                                            \
-  do {                                                                  \
-      int code = aug_error (aug);                                       \
-      if (code == AUG_ENOMEM)                                           \
-        reply_with_error (fs ": augeas out of memory", ##__VA_ARGS__);  \
-      else {                                                            \
-            const char *message = aug_error_message (aug);              \
-            const char *minor = aug_error_minor_message (aug);          \
-            const char *details = aug_error_details (aug);              \
-            reply_with_error (fs ": %s%s%s%s%s", ##__VA_ARGS__,         \
-                                message,                                \
-                                minor ? ": " : "", minor ? minor : "",  \
-                                details ? ": " : "", details ? details : ""); \
-            }                                                           \
-  } while (0)
-
 /* We need to rewrite the root path so it is based at /sysroot. */
 int
 do_aug_init (const char *root, int flags)
diff --git a/daemon/daemon.h b/daemon/daemon.h
index 705aa95..d90b3e7 100644
--- a/daemon/daemon.h
+++ b/daemon/daemon.h
@@ -403,6 +403,23 @@ is_zero (const char *buffer, size_t size)
     }                                                   \
     while (0)
 
+/* Calls reply_with_error, but includes the Augeas error details. */
+#define AUGEAS_ERROR(fs,...)                                            \
+  do {                                                                  \
+    int code = aug_error (aug);                                         \
+    if (code == AUG_ENOMEM)                                             \
+      reply_with_error (fs ": augeas out of memory", ##__VA_ARGS__);    \
+    else {                                                              \
+      const char *message = aug_error_message (aug);                    \
+      const char *minor = aug_error_minor_message (aug);                \
+      const char *details = aug_error_details (aug);                    \
+      reply_with_error (fs ": %s%s%s%s%s", ##__VA_ARGS__,               \
+                          message,                                      \
+                          minor ? ": " : "", minor ? minor : "",        \
+                          details ? ": " : "", details ? details : ""); \
+    }                                                                   \
+  } while (0)
+
 #ifdef HAVE_ATTRIBUTE_CLEANUP
 #define CLEANUP_FREE __attribute__((cleanup(cleanup_free)))
 #define CLEANUP_FREE_STRING_LIST                        \
-- 
1.9.3




More information about the Libguestfs mailing list