WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] [xen-unstable] libxl: Make logging functions preserve er

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] libxl: Make logging functions preserve errno
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Tue, 13 Apr 2010 14:55:19 -0700
Delivery-date: Tue, 13 Apr 2010 14:59:34 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1271090297 -3600
# Node ID 5993c6b9f4e5a2431e0ae7590aef9884a9387382
# Parent  7eeb131880b20a33e7675cc1726ae312a489be2d
libxl: Make logging functions preserve errno

This is needed by the following patches.  It makes it much more
convenient for libxl functions to return the errno value from the
failure, when they fail.

Signed-off-by: Ian Jackson <Ian.Jackson@xxxxxxxxxxxxx>
---
 tools/libxl/libxl_internal.c |    5 ++++-
 tools/libxl/libxl_internal.h |    2 ++
 2 files changed, 6 insertions(+), 1 deletion(-)

diff -r 7eeb131880b2 -r 5993c6b9f4e5 tools/libxl/libxl_internal.c
--- a/tools/libxl/libxl_internal.c      Mon Apr 12 17:36:54 2010 +0100
+++ b/tools/libxl/libxl_internal.c      Mon Apr 12 17:38:17 2010 +0100
@@ -156,11 +156,13 @@ void xl_logv(struct libxl_ctx *ctx, int 
 {
     char *enomem = "[out of memory formatting log message]";
     char *s;
-    int rc;
+    int rc, esave;
 
     if (!ctx->log_callback)
         return;
 
+    esave = errno;
+    
     rc = vasprintf(&s, fmt, ap);
     if (rc<0) { s = enomem; goto x; }
 
@@ -180,6 +182,7 @@ void xl_logv(struct libxl_ctx *ctx, int 
     ctx->log_callback(ctx->log_userdata, loglevel, file, line, func, s);
     if (s != enomem)
         free(s);
+    errno = esave;
 }
 
 void xl_log(struct libxl_ctx *ctx, int loglevel, int errnoval,
diff -r 7eeb131880b2 -r 5993c6b9f4e5 tools/libxl/libxl_internal.h
--- a/tools/libxl/libxl_internal.h      Mon Apr 12 17:36:54 2010 +0100
+++ b/tools/libxl/libxl_internal.h      Mon Apr 12 17:38:17 2010 +0100
@@ -47,6 +47,7 @@
 #define XL_LOG_ERRNO(ctx, loglevel, _f, _a...)
 #define XL_LOG_ERRNOVAL(ctx, loglevel, errnoval, _f, _a...)
 #endif
+  /* all of these macros preserve errno (saving and restoring) */
 
 #define XL_LOG_DEBUG 3
 #define XL_LOG_INFO 2
@@ -56,6 +57,7 @@
 /* logging */
 void xl_logv(struct libxl_ctx *ctx, int errnoval, int loglevel, const char 
*file, int line, const char *func, char *fmt, va_list al);
 void xl_log(struct libxl_ctx *ctx, int errnoval, int loglevel, const char 
*file, int line, const char *func, char *fmt, ...);
+  /* these functions preserve errno (saving and restoring) */
 
 
 typedef enum {

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] libxl: Make logging functions preserve errno, Xen patchbot-unstable <=