Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 20 May 2013 22:18:18 +0000 (UTC)
From:      Jung-uk Kim <jkim@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r250834 - head/sys/dev/acpica/Osd
Message-ID:  <201305202218.r4KMII2J075613@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jkim
Date: Mon May 20 22:18:18 2013
New Revision: 250834
URL: http://svnweb.freebsd.org/changeset/base/250834

Log:
  - Prefer ACPI_COMPARE_NAME(a, b) macro over strncmp(a, b, ACPI_NAME_SIZE).
  - Make sure the predefined name is a string type.
  - Return slightly more useful errors.

Modified:
  head/sys/dev/acpica/Osd/OsdTable.c

Modified: head/sys/dev/acpica/Osd/OsdTable.c
==============================================================================
--- head/sys/dev/acpica/Osd/OsdTable.c	Mon May 20 22:10:01 2013	(r250833)
+++ head/sys/dev/acpica/Osd/OsdTable.c	Mon May 20 22:18:18 2013	(r250834)
@@ -54,8 +54,8 @@ AcpiOsPredefinedOverride(const ACPI_PRED
 		return (AE_BAD_PARAMETER);
 
 	*NewVal = NULL;
-	if (strncmp(InitVal->Name, "_OS_", ACPI_NAME_SIZE) == 0 &&
-	    strlen(acpi_osname) > 0) {
+	if (ACPI_COMPARE_NAME(InitVal->Name, "_OS_") &&
+	    InitVal->Type == ACPI_TYPE_STRING && strlen(acpi_osname) > 0) {
 		printf("ACPI: Overriding _OS definition with \"%s\"\n",
 		    acpi_osname);
 		*NewVal = acpi_osname;
@@ -80,18 +80,17 @@ AcpiOsTableOverride(ACPI_TABLE_HEADER *E
 	for (int i = 0; i < ACPI_NAME_SIZE; i++)
 		modname[i + 5] = tolower(ExistingTable->Signature[i]);
 #else
-	/* If we're not overriding the DSDT, just return. */
-	if (strncmp(ExistingTable->Signature, ACPI_SIG_DSDT,
-	    ACPI_NAME_SIZE) != 0)
-		return (AE_OK);
+	if (!ACPI_COMPARE_NAME(ExistingTable->Signature, ACPI_SIG_DSDT))
+		return (AE_SUPPORT);
 #endif
 	acpi_table = preload_search_by_type(modname);
 	if (acpi_table == NULL)
-		return (AE_OK);
+		return (AE_NOT_FOUND);
 	hdr = preload_fetch_addr(acpi_table);
 	sz = preload_fetch_size(acpi_table);
-	if (hdr != NULL && sz != 0)
-		*NewTable = hdr;
+	if (hdr == NULL || sz == 0)
+		return (AE_ERROR);
+	*NewTable = hdr;
 	return (AE_OK);
 }
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201305202218.r4KMII2J075613>