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

[xen master] tools/xenstore: make log macro globally available



commit ab5fa21c8d91f7057f0373ac63abc659f05b0c69
Author:     Juergen Gross <jgross@xxxxxxxx>
AuthorDate: Wed Jan 18 10:50:03 2023 +0100
Commit:     Julien Grall <jgrall@xxxxxxxxxx>
CommitDate: Fri Jan 20 09:23:51 2023 +0000

    tools/xenstore: make log macro globally available
    
    Move the definition of the log() macro to xenstored_core.h in order
    to make it usable from other source files, too.
    
    While at it preserve errno from being modified.
    
    Signed-off-by: Juergen Gross <jgross@xxxxxxxx>
    Reviewed-by: Julien Grall <jgrall@xxxxxxxxxx>
---
 tools/xenstore/xenstored_core.c | 14 --------------
 tools/xenstore/xenstored_core.h | 15 +++++++++++++++
 2 files changed, 15 insertions(+), 14 deletions(-)

diff --git a/tools/xenstore/xenstored_core.c b/tools/xenstore/xenstored_core.c
index 1650821922..d30f35e642 100644
--- a/tools/xenstore/xenstored_core.c
+++ b/tools/xenstore/xenstored_core.c
@@ -88,20 +88,6 @@ TDB_CONTEXT *tdb_ctx = NULL;
 
 static const char *sockmsg_string(enum xsd_sockmsg_type type);
 
-#define log(...)                                                       \
-       do {                                                            \
-               char *s = talloc_asprintf(NULL, __VA_ARGS__);           \
-               if (s) {                                                \
-                       trace("%s\n", s);                               \
-                       syslog(LOG_ERR, "%s\n",  s);                    \
-                       talloc_free(s);                                 \
-               } else {                                                \
-                       trace("talloc failure during logging\n");       \
-                       syslog(LOG_ERR, "talloc failure during logging\n"); \
-               }                                                       \
-       } while (0)
-
-
 int quota_nb_entry_per_domain = 1000;
 int quota_nb_watch_per_domain = 128;
 int quota_max_entry_size = 2048; /* 2K */
diff --git a/tools/xenstore/xenstored_core.h b/tools/xenstore/xenstored_core.h
index 37006d508d..89055cbb21 100644
--- a/tools/xenstore/xenstored_core.h
+++ b/tools/xenstore/xenstored_core.h
@@ -267,6 +267,21 @@ void trace(const char *fmt, ...) __attribute__ ((format 
(printf, 1, 2)));
 void reopen_log(void);
 void close_log(void);
 
+#define log(...)                                                       \
+       do {                                                            \
+               int _saved_errno = errno;                               \
+               char *s = talloc_asprintf(NULL, __VA_ARGS__);           \
+               if (s) {                                                \
+                       trace("%s\n", s);                               \
+                       syslog(LOG_ERR, "%s\n", s);                     \
+                       talloc_free(s);                                 \
+               } else {                                                \
+                       trace("talloc failure during logging\n");       \
+                       syslog(LOG_ERR, "talloc failure during logging\n"); \
+               }                                                       \
+               errno = _saved_errno;                                   \
+       } while (0)
+
 extern int orig_argc;
 extern char **orig_argv;
 
--
generated by git-patchbot for /home/xen/git/xen.git#master



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.