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] Clean up arch_get_xen_caps() to not use s

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] Clean up arch_get_xen_caps() to not use sprintf().
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Wed, 31 Jan 2007 07:05:27 -0800
Delivery-date: Wed, 31 Jan 2007 07:51:30 -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 Keir Fraser <keir@xxxxxxxxxxxxx>
# Date 1170174223 0
# Node ID 9578ae319874cfa8918757da52c8f741e3bc244f
# Parent  bd69e83b65ea5c01e3d93d37b1e873f6204b4b7e
Clean up arch_get_xen_caps() to not use sprintf().
Based on a patch from Christoph Egger <Christoph.Egger@xxxxxxx>
Signed-off-by: Keir Fraser <keir@xxxxxxxxxxxxx>
---
 xen/arch/ia64/xen/xensetup.c |   23 +++++++------
 xen/arch/x86/setup.c         |   72 ++++++++++++++++---------------------------
 2 files changed, 40 insertions(+), 55 deletions(-)

diff -r bd69e83b65ea -r 9578ae319874 xen/arch/ia64/xen/xensetup.c
--- a/xen/arch/ia64/xen/xensetup.c      Tue Jan 30 16:14:16 2007 +0000
+++ b/xen/arch/ia64/xen/xensetup.c      Tue Jan 30 16:23:43 2007 +0000
@@ -547,18 +547,19 @@ printk("num_online_cpus=%d, max_cpus=%d\
 
 void arch_get_xen_caps(xen_capabilities_info_t info)
 {
-    char *p=info;
     int major = xen_major_version();
     int minor = xen_minor_version();
-
-    p += snprintf(p,sizeof(info), "xen-%d.%d-ia64 ", major, minor);
+    char s[32];
+
+    info[0] = '\0';
+
+    snprintf(s, sizeof(s), "xen-%d.%d-ia54 ", major, minor);
+    safe_strcat(info, s);
 
     if (vmx_enabled)
-        p += snprintf(p,sizeof(info) - (p - info),"hvm-%d.%d-ia64 ", major, 
minor);
-
-    *(p-1) = 0;
-
-    BUG_ON((p-info)>sizeof(xen_capabilities_info_t));
-
-}
-
+    {
+        snprintf(s, sizeof(s), "hvm-%d.%d-ia64 ", major, minor);
+        safe_strcat(info, s);
+    }
+}
+
diff -r bd69e83b65ea -r 9578ae319874 xen/arch/x86/setup.c
--- a/xen/arch/x86/setup.c      Tue Jan 30 16:14:16 2007 +0000
+++ b/xen/arch/x86/setup.c      Tue Jan 30 16:23:43 2007 +0000
@@ -802,69 +802,53 @@ void __init __start_xen(multiboot_info_t
 
 void arch_get_xen_caps(xen_capabilities_info_t info)
 {
-    char *p = info;
-    int i = 0;
     int major = xen_major_version();
     int minor = xen_minor_version();
+    char s[32];
+
+    info[0] = '\0';
 
 #if defined(CONFIG_X86_32) && !defined(CONFIG_X86_PAE)
 
-    i = snprintf(p, sizeof(xen_capabilities_info_t),
-                 "xen-%d.%d-x86_32 ", major, minor);
-    p += i;
-    if ( hvm_enabled ) {
-        i = snprintf(p, sizeof(xen_capabilities_info_t) - i,
-               "hvm-%d.%d-x86_32 ", major, minor);
-       p += i;
+    snprintf(s, sizeof(s), "xen-%d.%d-x86_32 ", major, minor);
+    safe_strcat(info, s);
+    if ( hvm_enabled )
+    {
+        snprintf(s, sizeof(s), "hvm-%d.%d-x86_32 ", major, minor);
+        safe_strcat(info, s);
     }
 
 #elif defined(CONFIG_X86_32) && defined(CONFIG_X86_PAE)
 
-    i = snprintf(p, sizeof(xen_capabilities_info_t),
-                 "xen-%d.%d-x86_32p ", major, minor);
-    p += i;
+    snprintf(s, sizeof(s), "xen-%d.%d-x86_32p ", major, minor);
+    safe_strcat(info, s);
     if ( hvm_enabled )
     {
-        i = snprintf(p, sizeof(xen_capabilities_info_t),
-                     "hvm-%d.%d-x86_32 ", major, minor);
-        p += i;
-        i = snprintf(p, sizeof(xen_capabilities_info_t) - i,
-                     "hvm-%d.%d-x86_32p ", major, minor);
-        p += i;
+        snprintf(s, sizeof(s), "hvm-%d.%d-x86_32 ", major, minor);
+        safe_strcat(info, s);
+        snprintf(s, sizeof(s), "hvm-%d.%d-x86_32p ", major, minor);
+        safe_strcat(info, s);
     }
 
 #elif defined(CONFIG_X86_64)
 
-    i = snprintf(p, sizeof(xen_capabilities_info_t),
-                 "xen-%d.%d-x86_64 ", major, minor);
-    p += i;
+    snprintf(s, sizeof(s), "xen-%d.%d-x86_64 ", major, minor);
+    safe_strcat(info, s);
 #ifdef CONFIG_COMPAT
-    i = snprintf(p, sizeof(xen_capabilities_info_t) - i,
-                "xen-%d.%d-x86_32p ", major, minor);
-    p += i;
+    snprintf(s, sizeof(s), "xen-%d.%d-x86_32p ", major, minor);
+    safe_strcat(info, s);
 #endif
     if ( hvm_enabled )
     {
-        i = snprintf(p, sizeof(xen_capabilities_info_t) - i,
-                     "hvm-%d.%d-x86_32 ", major, minor);
-        p += i;
-        i = snprintf(p, sizeof(xen_capabilities_info_t) - i,
-                     "hvm-%d.%d-x86_32p ", major, minor);
-        p += i;
-        i = snprintf(p, sizeof(xen_capabilities_info_t) - i,
-                     "hvm-%d.%d-x86_64 ", major, minor);
-        p += i;
-    }
-
-#else
-
-    p++;
-
-#endif
-
-    *(p-1) = 0;
-
-    BUG_ON((p - info) > sizeof(xen_capabilities_info_t));
+        snprintf(s, sizeof(s), "hvm-%d.%d-x86_32 ", major, minor);
+        safe_strcat(info, s);
+        snprintf(s, sizeof(s), "hvm-%d.%d-x86_32p ", major, minor);
+        safe_strcat(info, s);
+        snprintf(s, sizeof(s), "hvm-%d.%d-x86_64 ", major, minor);
+        safe_strcat(info, s);
+    }
+
+#endif
 }
 
 /*

_______________________________________________
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] Clean up arch_get_xen_caps() to not use sprintf()., Xen patchbot-unstable <=