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] hvmloader: Avoid compile warnings char vs

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] hvmloader: Avoid compile warnings char vs. unsigned char.
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Tue, 13 Mar 2007 08:30:18 -0700
Delivery-date: Tue, 13 Mar 2007 08:30:08 -0700
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
# Date 1173781972 0
# Node ID 7c0d7736f960439039bc02f88a4216d25659284f
# Parent  1877857352aef3fac726a13acbdbf043195458f6
hvmloader: Avoid compile warnings char vs. unsigned char.
Avoid 'magic number' hardcoded string lengths.
Signed-off-by: Keir Fraser <keir@xxxxxxxxxxxxx>
---
 tools/firmware/hvmloader/acpi/acpi2_0.h |    8 ++++----
 tools/firmware/hvmloader/acpi/build.c   |   26 ++++++++++++++------------
 2 files changed, 18 insertions(+), 16 deletions(-)

diff -r 1877857352ae -r 7c0d7736f960 tools/firmware/hvmloader/acpi/acpi2_0.h
--- a/tools/firmware/hvmloader/acpi/acpi2_0.h   Tue Mar 13 10:02:45 2007 +0000
+++ b/tools/firmware/hvmloader/acpi/acpi2_0.h   Tue Mar 13 10:32:52 2007 +0000
@@ -49,8 +49,8 @@ struct acpi_header {
     uint32_t length;
     uint8_t  revision;
     uint8_t  checksum;
-    uint8_t  oem_id[6];
-    uint8_t  oem_table_id[8];
+    char     oem_id[6];
+    char     oem_table_id[8];
     uint32_t oem_revision;
     uint32_t creator_id;
     uint32_t creator_revision;
@@ -90,7 +90,7 @@ struct acpi_10_rsdp {
 struct acpi_10_rsdp {
     uint64_t signature;
     uint8_t  checksum;
-    uint8_t  oem_id[6];
+    char     oem_id[6];
     uint8_t  reserved;
     uint32_t rsdt_address;
 };
@@ -101,7 +101,7 @@ struct acpi_20_rsdp {
 struct acpi_20_rsdp {
     uint64_t signature;
     uint8_t  checksum;
-    uint8_t  oem_id[6];
+    char     oem_id[6];
     uint8_t  revision;
     uint32_t rsdt_address;
     uint32_t length;
diff -r 1877857352ae -r 7c0d7736f960 tools/firmware/hvmloader/acpi/build.c
--- a/tools/firmware/hvmloader/acpi/build.c     Tue Mar 13 10:02:45 2007 +0000
+++ b/tools/firmware/hvmloader/acpi/build.c     Tue Mar 13 10:32:52 2007 +0000
@@ -22,7 +22,8 @@
 #include "../util.h"
 #include <xen/hvm/e820.h>
 
-#define align16(sz) (((sz) + 15) & ~15)
+#define align16(sz)        (((sz) + 15) & ~15)
+#define fixed_strcpy(d, s) strncpy((d), (s), sizeof(d))
 
 extern struct acpi_20_rsdp Rsdp;
 extern struct acpi_20_rsdt Rsdt;
@@ -57,8 +58,8 @@ int construct_madt(struct acpi_20_madt *
     memset(madt, 0, sizeof(*madt));
     madt->header.signature    = ACPI_2_0_MADT_SIGNATURE;
     madt->header.revision     = ACPI_2_0_MADT_REVISION;
-    strncpy(madt->header.oem_id, ACPI_OEM_ID, 6);
-    strncpy(madt->header.oem_table_id, ACPI_OEM_TABLE_ID, 8);
+    fixed_strcpy(madt->header.oem_id, ACPI_OEM_ID);
+    fixed_strcpy(madt->header.oem_table_id, ACPI_OEM_TABLE_ID);
     madt->header.oem_revision = ACPI_OEM_REVISION;
     madt->header.creator_id   = ACPI_CREATOR_ID;
     madt->header.creator_revision = ACPI_CREATOR_REVISION;
@@ -131,8 +132,8 @@ int construct_hpet(struct acpi_20_hpet *
     memset(hpet, 0, sizeof(*hpet));
     hpet->header.signature    = ACPI_2_0_HPET_SIGNATURE;
     hpet->header.revision     = ACPI_2_0_HPET_REVISION;
-    strncpy(hpet->header.oem_id, ACPI_OEM_ID, 6);
-    strncpy(hpet->header.oem_table_id, ACPI_OEM_TABLE_ID, 8);
+    fixed_strcpy(hpet->header.oem_id, ACPI_OEM_ID);
+    fixed_strcpy(hpet->header.oem_table_id, ACPI_OEM_TABLE_ID);
     hpet->header.oem_revision = ACPI_OEM_REVISION;
     hpet->header.creator_id   = ACPI_CREATOR_ID;
     hpet->header.creator_revision = ACPI_CREATOR_REVISION;
@@ -150,6 +151,7 @@ int construct_processor_objects(uint8_t 
 {
     static const char pdat[13] = { 0x5b, 0x83, 0x0b, 0x50, 0x52 };
     static const char hex[] = "0123456789ABCDEF";
+    static const char pr_scope[] = "\\_PR_";
     unsigned int i, length, nr_cpus = get_vcpu_nr();
     struct acpi_header *hdr;
     uint8_t *p = buf;
@@ -161,8 +163,8 @@ int construct_processor_objects(uint8_t 
     hdr = (struct acpi_header *)p;
     hdr->signature = ASCII32('S','S','D','T');
     hdr->revision  = 2;
-    strncpy(hdr->oem_id, ACPI_OEM_ID, 6);
-    strncpy(hdr->oem_table_id, ACPI_OEM_TABLE_ID, 8);
+    fixed_strcpy(hdr->oem_id, ACPI_OEM_ID);
+    fixed_strcpy(hdr->oem_table_id, ACPI_OEM_TABLE_ID);
     hdr->oem_revision = ACPI_OEM_REVISION;
     hdr->creator_id = ACPI_CREATOR_ID;
     hdr->creator_revision = ACPI_CREATOR_REVISION;
@@ -176,7 +178,7 @@ int construct_processor_objects(uint8_t 
     *p++ = 0x10;
 
     /* PkgLength (includes length bytes!). */
-    length = 1 + 5 + (nr_cpus * sizeof(pdat));
+    length = 1 + strlen(pr_scope) + (nr_cpus * sizeof(pdat));
     if ( length <= 0x3f )
     {
         *p++ = length;
@@ -195,8 +197,8 @@ int construct_processor_objects(uint8_t 
     }
 
     /* NameString */
-    strncpy(p, "\\_PR_", 5);
-    p += 5;
+    strncpy(p, pr_scope, strlen(pr_scope));
+    p += strlen(pr_scope);
 
     /*
      * 3. Processor Objects.
@@ -263,8 +265,8 @@ int construct_secondary_tables(uint8_t *
         tcpa->header.signature = ACPI_2_0_TCPA_SIGNATURE;
         tcpa->header.length    = sizeof(*tcpa);
         tcpa->header.revision  = ACPI_2_0_TCPA_REVISION;
-        strncpy(tcpa->header.oem_id, ACPI_OEM_ID, 6);
-        strncpy(tcpa->header.oem_table_id, ACPI_OEM_TABLE_ID, 8);
+        fixed_strcpy(tcpa->header.oem_id, ACPI_OEM_ID);
+        fixed_strcpy(tcpa->header.oem_table_id, ACPI_OEM_TABLE_ID);
         tcpa->header.oem_revision = ACPI_OEM_REVISION;
         tcpa->header.creator_id   = ACPI_CREATOR_ID;
         tcpa->header.creator_revision = ACPI_CREATOR_REVISION;

_______________________________________________
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] hvmloader: Avoid compile warnings char vs. unsigned char., Xen patchbot-unstable <=