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] [LIBXC] Clean up use of sterror(). Define

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] [LIBXC] Clean up use of sterror(). Define a thread-safe
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Fri, 08 Dec 2006 15:10:16 +0000
Delivery-date: Fri, 08 Dec 2006 07:10:10 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
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/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/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 kfraser@xxxxxxxxxxxxxxxxxxxxx
# Node ID da87dc126b33d771f50336de30330c81d8eed32d
# Parent  6f0f80aa817de63ff730098a54e333c9bac776d6
[LIBXC] Clean up use of sterror(). Define a thread-safe
version which uses strerror_r(), and tries to cope with
the POSIX and GNU versions of that function.
Signed-off-by: Keir Fraser <keir@xxxxxxxxxxxxx>
---
 tools/libxc/ia64/xc_ia64_linux_save.c |    2 +-
 tools/libxc/xc_core.c                 |    4 ++--
 tools/libxc/xc_linux_build.c          |    4 ++--
 tools/libxc/xc_private.c              |   13 +++++++++++++
 tools/libxc/xc_private.h              |    3 ++-
 5 files changed, 20 insertions(+), 6 deletions(-)

diff -r 6f0f80aa817d -r da87dc126b33 tools/libxc/ia64/xc_ia64_linux_save.c
--- a/tools/libxc/ia64/xc_ia64_linux_save.c     Fri Dec 08 11:47:09 2006 +0000
+++ b/tools/libxc/ia64/xc_ia64_linux_save.c     Fri Dec 08 11:57:06 2006 +0000
@@ -353,7 +353,7 @@ xc_linux_save(int xc_handle, int io_fd, 
                    It will be remarked dirty.
                    FIXME: to be tracked.  */
                 fprintf(stderr, "cannot map page %lx: %s\n",
-                        page_array[N], strerror (errno));
+                        page_array[N], safe_strerror(errno));
                 continue;
             }
 
diff -r 6f0f80aa817d -r da87dc126b33 tools/libxc/xc_core.c
--- a/tools/libxc/xc_core.c     Fri Dec 08 11:47:09 2006 +0000
+++ b/tools/libxc/xc_core.c     Fri Dec 08 11:57:06 2006 +0000
@@ -140,7 +140,7 @@ static int local_file_dump(void *args, c
         bytes = write(da->fd, &buffer[offset], length-offset);
         if ( bytes <= 0 )
         {
-            PERROR("Failed to write buffer: %s", strerror(errno));
+            PERROR("Failed to write buffer");
             return -errno;
         }
     }
@@ -158,7 +158,7 @@ xc_domain_dumpcore(int xc_handle,
 
     if ( (da.fd = open(corename, O_CREAT|O_RDWR, S_IWUSR|S_IRUSR)) < 0 )
     {
-        PERROR("Could not open corefile %s: %s", corename, strerror(errno));
+        PERROR("Could not open corefile %s", corename);
         return -errno;
     }
 
diff -r 6f0f80aa817d -r da87dc126b33 tools/libxc/xc_linux_build.c
--- a/tools/libxc/xc_linux_build.c      Fri Dec 08 11:47:09 2006 +0000
+++ b/tools/libxc/xc_linux_build.c      Fri Dec 08 11:57:06 2006 +0000
@@ -593,8 +593,8 @@ static int setup_guest(int xc_handle,
     /* shared_info page starts its life empty. */
     shared_info = xc_map_foreign_range(
         xc_handle, dom, PAGE_SIZE, PROT_READ|PROT_WRITE, shared_info_frame);
-    printf("shared_info = %p, err=%s frame=%lx\n",
-           shared_info, strerror (errno), shared_info_frame);
+    printf("shared_info = %p frame=%lx\n",
+           shared_info, shared_info_frame);
     //memset(shared_info, 0, PAGE_SIZE);
     /* Mask all upcalls... */
     for ( i = 0; i < MAX_VIRT_CPUS; i++ )
diff -r 6f0f80aa817d -r da87dc126b33 tools/libxc/xc_private.c
--- a/tools/libxc/xc_private.c  Fri Dec 08 11:47:09 2006 +0000
+++ b/tools/libxc/xc_private.c  Fri Dec 08 11:57:06 2006 +0000
@@ -483,6 +483,19 @@ unsigned long xc_make_page_below_4G(
     return new_mfn;
 }
 
+char *safe_strerror(int errcode)
+{
+    static __thread char errbuf[32];
+#ifdef __GLIBC__
+    /* Broken GNU definition of strerror_r may not use our supplied buffer. */
+    return strerror_r(errcode, errbuf, sizeof(errbuf));
+#else
+    /* Assume we have the POSIX definition of strerror_r. */
+    strerror_r(errcode, errbuf, sizeof(errbuf));
+    return errbuf;
+#endif
+}
+
 /*
  * Local variables:
  * mode: C
diff -r 6f0f80aa817d -r da87dc126b33 tools/libxc/xc_private.h
--- a/tools/libxc/xc_private.h  Fri Dec 08 11:47:09 2006 +0000
+++ b/tools/libxc/xc_private.h  Fri Dec 08 11:57:06 2006 +0000
@@ -59,11 +59,12 @@
 #define PPRINTF(_f, _a...)
 #endif
 
+char *safe_strerror(int errcode);
 void xc_set_error(int code, const char *fmt, ...);
 
 #define ERROR(_m, _a...)  xc_set_error(XC_INTERNAL_ERROR, _m , ## _a )
 #define PERROR(_m, _a...) xc_set_error(XC_INTERNAL_ERROR, _m " (%d = %s)", \
-                                       ## _a , errno, strerror(errno))
+                                       ## _a , errno, safe_strerror(errno))
 
 int lock_pages(void *addr, size_t len);
 void unlock_pages(void *addr, size_t len);

_______________________________________________
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] [LIBXC] Clean up use of sterror(). Define a thread-safe, Xen patchbot-unstable <=