[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen-unstable] Clean up arch_get_xen_caps() to not use sprintf().
# 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
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |