Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/usb When dumping iot[] contents to the console for d...



details:   https://anonhg.NetBSD.org/src/rev/de3df8e66f10
branches:  trunk
changeset: 805998:de3df8e66f10
user:      gson <gson%NetBSD.org@localhost>
date:      Mon Jan 26 20:32:17 2015 +0000

description:
When dumping iot[] contents to the console for debugging, don't crash
if iot[i].output is NULL for some i.  Share code with the dumping of
iot[i].inputs[], which already handled NULLs.

diffstat:

 sys/dev/usb/uaudio.c |  39 +++++++++++++++++++++++----------------
 1 files changed, 23 insertions(+), 16 deletions(-)

diffs (77 lines):

diff -r fa5db4184564 -r de3df8e66f10 sys/dev/usb/uaudio.c
--- a/sys/dev/usb/uaudio.c      Mon Jan 26 11:05:20 2015 +0000
+++ b/sys/dev/usb/uaudio.c      Mon Jan 26 20:32:17 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: uaudio.c,v 1.141 2015/01/26 09:25:08 gson Exp $        */
+/*     $NetBSD: uaudio.c,v 1.142 2015/01/26 20:32:17 gson Exp $        */
 
 /*
  * Copyright (c) 1999, 2012 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uaudio.c,v 1.141 2015/01/26 09:25:08 gson Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uaudio.c,v 1.142 2015/01/26 20:32:17 gson Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -252,6 +252,10 @@
 };
 #endif
 
+#ifdef UAUDIO_DEBUG
+Static void uaudio_dump_tml
+       (struct terminal_list *tml);
+#endif
 Static usbd_status uaudio_identify_ac
        (struct uaudio_softc *, const usb_config_descriptor_t *);
 Static usbd_status uaudio_identify_as
@@ -1872,6 +1876,21 @@
        return USBD_NORMAL_COMPLETION;
 }
 
+#ifdef UAUDIO_DEBUG
+Static void
+uaudio_dump_tml(struct terminal_list *tml) {
+       if (tml == NULL) {
+               printf("NULL");
+       } else {
+                int i;
+               for (i = 0; i < tml->size; i++)
+                       printf("%s ", uaudio_get_terminal_name
+                              (tml->terminals[i]));
+       }
+       printf("\n");
+}
+#endif
+
 Static usbd_status
 uaudio_identify_ac(struct uaudio_softc *sc, const usb_config_descriptor_t *cdesc)
 {
@@ -2015,23 +2034,11 @@
                                  iot[i].d.desc->bDescriptorSubtype);
                }
                for (j = 0; j < iot[i].inputs_size; j++) {
-                       int k;
                        printf("\tinput%d: ", j);
-                       tml = iot[i].inputs[j];
-                       if (tml == NULL) {
-                               printf("NULL\n");
-                               continue;
-                       }
-                       for (k = 0; k < tml->size; k++)
-                               printf("%s ", uaudio_get_terminal_name
-                                         (tml->terminals[k]));
-                       printf("\n");
+                       uaudio_dump_tml(iot[i].inputs[j]);
                }
                printf("\toutput: ");
-               tml = iot[i].output;
-               for (j = 0; j < tml->size; j++)
-                       printf("%s ", uaudio_get_terminal_name(tml->terminals[j]));
-               printf("\n");
+               uaudio_dump_tml(iot[i].output);
        }
 #endif
 



Home | Main Index | Thread Index | Old Index