Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/acpi with new ACPICA, idstr may be NULL.



details:   https://anonhg.NetBSD.org/src/rev/127b1716633f
branches:  trunk
changeset: 746729:127b1716633f
user:      cegger <cegger%NetBSD.org@localhost>
date:      Tue Aug 18 21:33:29 2009 +0000

description:
with new ACPICA, idstr may be NULL.
Check against NULL, this fixes a crash on my HP Pavilion dv9700 Laptop.
While here simplify the loop via __arraycount()

diffstat:

 sys/dev/acpi/wss_acpi.c |  11 ++++++-----
 1 files changed, 6 insertions(+), 5 deletions(-)

diffs (40 lines):

diff -r 68277dfc9317 -r 127b1716633f sys/dev/acpi/wss_acpi.c
--- a/sys/dev/acpi/wss_acpi.c   Tue Aug 18 21:31:51 2009 +0000
+++ b/sys/dev/acpi/wss_acpi.c   Tue Aug 18 21:33:29 2009 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: wss_acpi.c,v 1.24 2009/08/18 16:41:02 jmcneill Exp $ */
+/* $NetBSD: wss_acpi.c,v 1.25 2009/08/18 21:33:29 cegger Exp $ */
 
 /*
  * Copyright (c) 2002 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -26,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: wss_acpi.c,v 1.24 2009/08/18 16:41:02 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: wss_acpi.c,v 1.25 2009/08/18 21:33:29 cegger Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -73,7 +73,6 @@
        { "NMX2210", 1, 2, WSS_CODEC },
        { "CSC0000", 0, 1, 0 },         /* Dell Latitude CPi */
        { "CSC0100", 0, 1, 0 },         /* CS4610 with CS4236 codec */
-       { { 0 }, 0, 0, 0 }
 };
 
 static int wss_acpi_hints_index (const char *);
@@ -81,9 +80,11 @@
 static int
 wss_acpi_hints_index(const char *idstr)
 {
-       int idx = 0;
+       int idx;
 
-       while (wss_acpi_hints[idx].idstr[0] != 0) {
+       if (idstr == NULL)
+               return -1;
+       for (idx = 0; idx < __arraycount(wss_acpi_hints); idx++) {
                if (!strcmp(wss_acpi_hints[idx].idstr, idstr))
                        return idx;
                ++idx;



Home | Main Index | Thread Index | Old Index