All of lore.kernel.org
 help / color / mirror / Atom feed
From: Aron Griffis <aron@hp.com>
To: Keir.Fraser@cl.cam.ac.uk
Cc: Christoph.Egger@amd.com, xen-devel@lists.xensource.com,
	xen-ia64-devel@lists.xensource.com
Subject: [PATCH] Clean up and fix errors in strncpy -> strlcpy conversion
Date: Mon, 29 Jan 2007 20:10:54 -0500	[thread overview]
Message-ID: <20070130011053.GE27235@fc.hp.com> (raw)

This patch is for the staging tree.  Please apply.

# HG changeset patch
# User Aron Griffis <aron@hp.com>
# Date 1170118368 18000
# Node ID 23560e2248fd267bad6490113ed52d0a27d7e219
# Parent  5e3b47bcc311e7698959f1fa79c4654190593499
Clean up and fix errors in strncpy -> strlcpy conversion

Signed-off-by: Aron Griffis <aron@hp.com>

diff -r 5e3b47bcc311 -r 23560e2248fd xen/arch/ia64/xen/dom_fw.c
--- a/xen/arch/ia64/xen/dom_fw.c	Mon Jan 29 22:43:51 2007 +0000
+++ b/xen/arch/ia64/xen/dom_fw.c	Mon Jan 29 19:52:48 2007 -0500
@@ -333,13 +333,13 @@ dom_fw_fake_acpi(struct domain *d, struc
 	memset(tables, 0, sizeof(struct fake_acpi_tables));
 
 	/* setup XSDT (64bit version of RSDT) */
-	strlcpy(xsdt->signature, XSDT_SIG, sizeof(xsdt->signature));
+	memcpy(xsdt->signature, XSDT_SIG, sizeof(xsdt->signature));
 	/* XSDT points to both the FADT and the MADT, so add one entry */
 	xsdt->length = sizeof(struct xsdt_descriptor_rev2) + sizeof(u64);
 	xsdt->revision = 1;
-	strlcpy(xsdt->oem_id, "XEN", sizeof(xsdt->oem_id));
-	strlcpy(xsdt->oem_table_id, "Xen/ia64", sizeof(xsdt->oem_table_id));
-	strlcpy(xsdt->asl_compiler_id, "XEN", sizeof(xsdt->asl_compiler_id));
+	safe_strcpy(xsdt->oem_id, "XEN");
+	safe_strcpy(xsdt->oem_table_id, "Xen/ia64");
+	safe_strcpy(xsdt->asl_compiler_id, "XEN");
 	xsdt->asl_compiler_revision = (xen_major_version() << 16) |
 		xen_minor_version();
 
@@ -349,16 +349,16 @@ dom_fw_fake_acpi(struct domain *d, struc
 	xsdt->checksum = generate_acpi_checksum(xsdt, xsdt->length);
 
 	/* setup FADT */
-	strlcpy(fadt->signature, FADT_SIG, sizeof(fadt->signature));
+	memcpy(fadt->signature, FADT_SIG, sizeof(fadt->signature));
 	fadt->length = sizeof(struct fadt_descriptor_rev2);
 	fadt->revision = FADT2_REVISION_ID;
-	strlcpy(fadt->oem_id, "XEN", sizeof(fadt->oem_id));
-	strlcpy(fadt->oem_table_id, "Xen/ia64", sizeof(fadt->oem_table_id));
-	strlcpy(fadt->asl_compiler_id, "XEN", sizeof(fadt->asl_compiler_id));
+	safe_strcpy(fadt->oem_id, "XEN");
+	safe_strcpy(fadt->oem_table_id, "Xen/ia64");
+	safe_strcpy(fadt->asl_compiler_id, "XEN");
 	fadt->asl_compiler_revision = (xen_major_version() << 16) |
 		xen_minor_version();
 
-	strlcpy(facs->signature, FACS_SIG, sizeof(facs->signature));
+	memcpy(facs->signature, FACS_SIG, sizeof(facs->signature));
 	facs->version = 1;
 	facs->length = sizeof(struct facs_descriptor_rev2);
 
@@ -386,8 +386,8 @@ dom_fw_fake_acpi(struct domain *d, struc
 	fadt->checksum = generate_acpi_checksum(fadt, fadt->length);
 
 	/* setup RSDP */
-	strlcpy(rsdp->signature, RSDP_SIG, sizeof(rsdp->signature));
-	strlcpy(rsdp->oem_id, "XEN", sizeof(rsdp->oem_id));
+	safe_strcpy(rsdp->signature, RSDP_SIG);
+	safe_strcpy(rsdp->oem_id, "XEN");
 	rsdp->revision = 2; /* ACPI 2.0 includes XSDT */
 	rsdp->length = sizeof(struct acpi20_table_rsdp);
 	rsdp->xsdt_address = ACPI_TABLE_MPA(xsdt);
@@ -397,11 +397,11 @@ dom_fw_fake_acpi(struct domain *d, struc
 	rsdp->ext_checksum = generate_acpi_checksum(rsdp, rsdp->length);
 
 	/* setup DSDT with trivial namespace. */ 
-	strlcpy(dsdt->signature, DSDT_SIG, sizeof(dsdt->signature));
+	safe_strcpy(dsdt->signature, DSDT_SIG);
 	dsdt->revision = 1;
-	strlcpy(dsdt->oem_id, "XEN", sizeof(dsdt->oem_id));
-	strlcpy(dsdt->oem_table_id, "Xen/ia64", sizeof(dsdt->oem_table_id));
-	strlcpy(dsdt->asl_compiler_id, "XEN", sizeof(dsdt->asl_compiler_id));
+	safe_strcpy(dsdt->oem_id, "XEN");
+	safe_strcpy(dsdt->oem_table_id, "Xen/ia64");
+	safe_strcpy(dsdt->asl_compiler_id, "XEN");
 	dsdt->asl_compiler_revision = (xen_major_version() << 16) |
 		xen_minor_version();
 
@@ -409,7 +409,7 @@ dom_fw_fake_acpi(struct domain *d, struc
 	tables->aml[0] = 0x10; /* Scope */
 	tables->aml[1] = 0x40; /* length/offset to next object (patched) */
 	tables->aml[2] = 0x00;
-	strlcpy((char *)&tables->aml[3], "_SB_", 5);
+	memcpy(&tables->aml[3], "_SB_", 4);
 
 	/* The processor object isn't absolutely necessary, revist for SMP */
 	aml_len = 7;
@@ -437,14 +437,11 @@ dom_fw_fake_acpi(struct domain *d, struc
 	dsdt->checksum = generate_acpi_checksum(dsdt, dsdt->length);
 
 	/* setup MADT */
-	strlcpy(madt->header.signature, APIC_SIG, sizeof(madt->header.signature));
+	memcpy(madt->header.signature, APIC_SIG, sizeof(madt->header.signature));
 	madt->header.revision = 2;
-	strlcpy(madt->header.oem_id, "XEN",
-		sizeof(madt->header.oem_id));
-	strlcpy(madt->header.oem_table_id, "Xen/ia64",
-		sizeof(madt->header.oem_table_id));
-	strlcpy(madt->header.asl_compiler_id, "XEN",
-		sizeof(madt->header.asl_compiler_id));
+	safe_strcpy(madt->header.oem_id, "XEN");
+	safe_strcpy(madt->header.oem_table_id, "Xen/ia64");
+	safe_strcpy(madt->header.asl_compiler_id, "XEN");
 	madt->header.asl_compiler_revision = (xen_major_version() << 16) |
 		xen_minor_version();
 
@@ -763,10 +760,8 @@ dom_fw_init(struct domain *d,
 	tables->sal_systab.sal_rev_major = 0;
 	tables->sal_systab.entry_count = 2;
 
-	strlcpy((char *)tables->sal_systab.oem_id, "Xen/ia64",
-		sizeof(tables->sal_systab.oem_id));
-	strlcpy((char *)tables->sal_systab.product_id, "Xen/ia64",
-		sizeof(tables->sal_systab.product_id));
+	safe_strcpy((char *)tables->sal_systab.oem_id, "Xen/ia64");
+	safe_strcpy((char *)tables->sal_systab.product_id, "Xen/ia64");
 
 	/* PAL entry point: */
 	tables->sal_ed.type = SAL_DESC_ENTRY_POINT;
diff -r 5e3b47bcc311 -r 23560e2248fd xen/arch/ia64/xen/oprofile/perfmon.c
--- a/xen/arch/ia64/xen/oprofile/perfmon.c	Mon Jan 29 22:43:51 2007 +0000
+++ b/xen/arch/ia64/xen/oprofile/perfmon.c	Mon Jan 29 19:52:48 2007 -0500
@@ -120,7 +120,6 @@ xenoprof_arch_init(int *num_events, int 
 {
     *num_events = 0;
     strlcpy(cpu_type, get_cpu_type(), XENOPROF_CPU_TYPE_SIZE);
-    cpu_type[XENOPROF_CPU_TYPE_SIZE - 1] = '\0';
 
     *is_primary = 0;
     if (xenoprof_primary_profiler == NULL) {

             reply	other threads:[~2007-01-30  1:10 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-01-30  1:10 Aron Griffis [this message]
2007-01-30  8:23 ` [PATCH] Clean up and fix errors in strncpy -> strlcpy conversion Christoph Egger
2007-01-30  9:32   ` Keir Fraser
2007-01-30 13:47   ` Aron Griffis
2007-01-30 14:01     ` Christoph Egger
2007-01-30 15:26     ` Christoph Egger
2007-01-30 15:46       ` Keir Fraser
2007-01-30 17:29         ` Alex Williamson
2007-01-30 17:37           ` Keir Fraser

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20070130011053.GE27235@fc.hp.com \
    --to=aron@hp.com \
    --cc=Christoph.Egger@amd.com \
    --cc=Keir.Fraser@cl.cam.ac.uk \
    --cc=xen-devel@lists.xensource.com \
    --cc=xen-ia64-devel@lists.xensource.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.