<div dir="ltr"><div class="gmail_default" style="font-family:verdana,sans-serif">That's a good idea. I will add a check for elements.<br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Sep 22, 2014 at 4:36 PM, Colin Ian King <span dir="ltr"><<a href="mailto:colin.king@canonical.com" target="_blank">colin.king@canonical.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On 22/09/14 03:06, Alex Hung wrote:<br>
> Hi,<br>
><br>
> I filed a LP bug #1370924 but forgot to include this information on the<br>
> patch...<br>
><br>
> On Mon, Sep 22, 2014 at 9:52 AM, Alex Hung <<a href="mailto:alex.hung@canonical.com">alex.hung@canonical.com</a><br>
</span><span class="">> <mailto:<a href="mailto:alex.hung@canonical.com">alex.hung@canonical.com</a>>> wrote:<br>
><br>
>     Signed-off-by: Alex Hung <<a href="mailto:alex.hung@canonical.com">alex.hung@canonical.com</a><br>
</span>>     <mailto:<a href="mailto:alex.hung@canonical.com">alex.hung@canonical.com</a>>><br>
<div><div class="h5">>     ---<br>
>      src/acpi/method/method.c | 85<br>
>     ++++++++++++++++++++++++++++++++++++++++++++++--<br>
>      1 file changed, 83 insertions(+), 2 deletions(-)<br>
><br>
>     diff --git a/src/acpi/method/method.c b/src/acpi/method/method.c<br>
>     index a21e4b1..5d42852 100644<br>
>     --- a/src/acpi/method/method.c<br>
>     +++ b/src/acpi/method/method.c<br>
>     @@ -62,7 +62,7 @@<br>
>       * _CBA  PCI f/w spec  Y<br>
>       * _CCA  6.2.17                Y<br>
>       * _CDM  6.2.1         Y<br>
>     - * _CID  6.1.2         N<br>
>     + * _CID  6.1.2         Y<br>
>       * _CLS  6.1.3         N requires PCI SIG class info<br>
>       * _CPC  8.4.5         Y<br>
>       * _CRS  6.2.2         Y<br>
>     @@ -1060,10 +1060,91 @@ static int method_test_HID(fwts_framework *fw)<br>
>                     "_HID", NULL, 0, method_test_HID_return, NULL);<br>
>      }<br>
><br>
>     +static void method_valid_CID_Type(<br>
>     +       fwts_framework *fw,<br>
>     +       char *name,<br>
>     +       ACPI_OBJECT *obj)<br>
>     +{<br>
>     +       char tmp[8];<br>
>     +<br>
>     +       switch (obj->Type) {<br>
>     +       case ACPI_TYPE_STRING:<br>
>     +               if (obj->String.Pointer) {<br>
>     +                       if<br>
>     (method_valid_HID_string(obj->String.Pointer))<br>
>     +                               fwts_passed(fw,<br>
>     +                                       "%s returned a string '%s' "<br>
>     +                                       "as expected.",<br>
>     +                                       name, obj->String.Pointer);<br>
>     +                       else<br>
>     +                               fwts_failed(fw, LOG_LEVEL_MEDIUM,<br>
>     +                                       "MethodCIDInvalidString",<br>
>     +                                       "%s returned a string '%s' "<br>
>     +                                       "but it was not a valid PNP<br>
>     ID or a "<br>
>     +                                       "valid ACPI ID.",<br>
>     +                                       name, obj->String.Pointer);<br>
>     +               } else {<br>
>     +                       fwts_failed(fw, LOG_LEVEL_MEDIUM,<br>
>     +                               "Method_CIDNullString",<br>
>     +                               "%s returned a NULL string.", name);<br>
>     +               }<br>
>     +               break;<br>
>     +       case ACPI_TYPE_INTEGER:<br>
>     +               if (method_valid_EISA_ID((uint32_t)obj->Integer.Value,<br>
>     +                       tmp, sizeof(tmp)))<br>
>     +                       fwts_passed(fw, "%s returned an integer "<br>
>     +                               "0x%8.8" PRIx64 " (EISA ID %s).",<br>
>     +                               name, (uint64_t)obj->Integer.Value,<br>
>     tmp);<br>
>     +               else<br>
>     +                       fwts_failed(fw, LOG_LEVEL_MEDIUM,<br>
>     +                               "MethodCIDInvalidInteger",<br>
>     +                               "%s returned a integer 0x%8.8"<br>
>     PRIx64 " "<br>
>     +                               "(EISA ID %s) but the this is not a<br>
>     valid "<br>
>     +                               "EISA ID encoded PNP ID.",<br>
>     +                               name, (uint64_t)obj->Integer.Value,<br>
>     tmp);<br>
>     +               break;<br>
>     +       }<br>
>     +}<br>
>     +<br>
>     +static void method_test_CID_return(<br>
>     +       fwts_framework *fw,<br>
>     +       char *name,<br>
>     +       ACPI_BUFFER *buf,<br>
>     +       ACPI_OBJECT *obj,<br>
>     +       void *private)<br>
>     +{<br>
>     +       uint32_t i;<br>
>     +       ACPI_OBJECT *pkg;<br>
>     +<br>
>     +       FWTS_UNUSED(buf);<br>
>     +       FWTS_UNUSED(private);<br>
>     +<br>
>     +       if (obj == NULL) {<br>
>     +               method_failed_null_object(fw, name, "a buffer or<br>
>     integer");<br>
>     +               return;<br>
>     +       }<br>
>     +<br>
>     +       switch (obj->Type) {<br>
>     +       case ACPI_TYPE_STRING:<br>
>     +       case ACPI_TYPE_INTEGER:<br>
>     +               method_valid_CID_Type(fw, name, obj);<br>
>     +               break;<br>
>     +       case ACPI_TYPE_PACKAGE:<br>
>     +               for (i = 0; i < obj->Package.Count; i++){<br>
>     +                       pkg = &obj->Package.Elements[i];<br>
>     +                       method_valid_CID_Type(fw, name, pkg);<br>
>     +               }<br>
>     +               break;<br>
<br>
</div></div>Section 3.1.2 does state:<br>
<br>
"An Integer or String containing a single CID or a Package containing a<br>
list of CIDs"<br>
<br>
..so should we conclude from that statement that the package should have<br>
1 or more elements?  If so, perhaps that is worth checking too.<br>
<div class="HOEnZb"><div class="h5"><br>
>     +       default:<br>
>     +               fwts_failed(fw, LOG_LEVEL_MEDIUM,<br>
>     "Method_CIDBadReturnType",<br>
>     +                       "%s did not return a string or an integer.",<br>
>     name);<br>
>     +               break;<br>
>     +       }<br>
>     +}<br>
>     +<br>
>      static int method_test_CID(fwts_framework *fw)<br>
>      {<br>
>             return method_evaluate_method(fw, METHOD_OPTIONAL,<br>
>     -               "_CID", NULL, 0, method_test_HID_return, NULL);<br>
>     +               "_CID", NULL, 0, method_test_CID_return, NULL);<br>
>      }<br>
><br>
>      static int method_test_HRV(fwts_framework *fw)<br>
>     --<br>
>     1.9.1<br>
><br>
><br>
><br>
><br>
> --<br>
> Cheers,<br>
> Alex Hung<br>
><br>
><br>
<br>
<br>
</div></div><span class="HOEnZb"><font color="#888888">--<br>
fwts-devel mailing list<br>
<a href="mailto:fwts-devel@lists.ubuntu.com">fwts-devel@lists.ubuntu.com</a><br>
Modify settings or unsubscribe at: <a href="https://lists.ubuntu.com/mailman/listinfo/fwts-devel" target="_blank">https://lists.ubuntu.com/mailman/listinfo/fwts-devel</a><br>
</font></span></blockquote></div><br><br clear="all"><br>-- <br><div dir="ltr">Cheers,<br>Alex Hung<br></div>
</div>