summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Moore <Robert.Moore@intel.com>2013-12-11 09:30:30 -0800
committerRobert Moore <Robert.Moore@intel.com>2013-12-11 09:30:30 -0800
commit148fae08c5a77a87ce1a94c54c3f6daa6216be06 (patch)
tree5ce168f8ec6ba1539faeedd72ffdf7bfebb0a456
parent041ed76f6968e78433ff1043c75a2c899cfee23c (diff)
iASL: Emit remark for unreferenced objects declared in methods.
Adds support to detect names that are declared within a control method, but are unused (these are temporary names that are only valid during the time the method is executing). A remark is issued for these cases. ACPICA BZ 1022.
-rw-r--r--source/compiler/asllookup.c56
-rw-r--r--source/compiler/aslmessages.h2
2 files changed, 46 insertions, 12 deletions
diff --git a/source/compiler/asllookup.c b/source/compiler/asllookup.c
index 82a833476..259df47e7 100644
--- a/source/compiler/asllookup.c
+++ b/source/compiler/asllookup.c
@@ -177,7 +177,9 @@ LkFindUnreferencedObjects (
* DESCRIPTION: Check for an unreferenced namespace object and emit a warning.
* We have to be careful, because some types and names are
* typically or always unreferenced, we don't want to issue
- * excessive warnings.
+ * excessive warnings. Note: Names that are declared within a
+ * control method are temporary, so we always issue a remark
+ * if they are not referenced.
*
******************************************************************************/
@@ -189,6 +191,7 @@ LkIsObjectUsed (
void **ReturnValue)
{
ACPI_NAMESPACE_NODE *Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, ObjHandle);
+ ACPI_NAMESPACE_NODE *Next;
/* Referenced flag is set during the namespace xref */
@@ -198,23 +201,19 @@ LkIsObjectUsed (
return (AE_OK);
}
- /*
- * Ignore names that start with an underscore,
- * these are the reserved ACPI names and are typically not referenced,
- * they are called by the host OS.
- */
- if (Node->Name.Ascii[0] == '_')
+ if (!Node->Op)
{
return (AE_OK);
}
- /* There are some types that are typically not referenced, ignore them */
+ /* These types are typically never directly referenced, ignore them */
switch (Node->Type)
{
case ACPI_TYPE_DEVICE:
case ACPI_TYPE_PROCESSOR:
case ACPI_TYPE_POWER:
+ case ACPI_TYPE_THERMAL:
case ACPI_TYPE_LOCAL_RESOURCE:
return (AE_OK);
@@ -224,12 +223,47 @@ LkIsObjectUsed (
break;
}
- /* All others are valid unreferenced namespace objects */
+ /* Determine if the name is within a control method */
- if (Node->Op)
+ Next = Node->Parent;
+ while (Next)
{
- AslError (ASL_WARNING2, ASL_MSG_NOT_REFERENCED, LkGetNameOp (Node->Op), NULL);
+ if (Next->Type == ACPI_TYPE_METHOD)
+ {
+ /*
+ * Name is within a method, therefore it is temporary.
+ * Issue a remark even if it is a reserved name (starts
+ * with an underscore).
+ */
+ sprintf (MsgBuffer, "Name is within method [%4.4s]",
+ Next->Name.Ascii);
+ AslError (ASL_REMARK, ASL_MSG_NOT_REFERENCED,
+ LkGetNameOp (Node->Op), MsgBuffer);
+ return (AE_OK);
+ }
+
+ Next = Next->Parent;
}
+
+ /* The name is not within a control method */
+
+ /*
+ * Ignore names that start with an underscore. These are the reserved
+ * ACPI names and are typically not referenced since they are meant
+ * to be called by the host OS.
+ */
+ if (Node->Name.Ascii[0] == '_')
+ {
+ return (AE_OK);
+ }
+
+ /*
+ * What remains is an unresolved user name that is not within a method.
+ * However, the object could be referenced via another table, so issue
+ * the warning at level 2.
+ */
+ AslError (ASL_WARNING2, ASL_MSG_NOT_REFERENCED,
+ LkGetNameOp (Node->Op), NULL);
return (AE_OK);
}
diff --git a/source/compiler/aslmessages.h b/source/compiler/aslmessages.h
index 16c1d9469..a3f6c8bce 100644
--- a/source/compiler/aslmessages.h
+++ b/source/compiler/aslmessages.h
@@ -441,7 +441,7 @@ char *AslMessages [] =
/* ASL_MSG_NOT_METHOD */ "Not a control method, cannot invoke",
/* ASL_MSG_NOT_PARAMETER */ "Not a parameter, used as local only",
/* ASL_MSG_NOT_REACHABLE */ "Object is not accessible from this scope",
-/* ASL_MSG_NOT_REFERENCED */ "Namespace object is not referenced",
+/* ASL_MSG_NOT_REFERENCED */ "Object is not referenced",
/* ASL_MSG_NULL_DESCRIPTOR */ "Min/Max/Length/Gran are all zero, but no resource tag",
/* ASL_MSG_NULL_STRING */ "Invalid zero-length (null) string",
/* ASL_MSG_OPEN */ "Could not open file",