Skip to contentSkip to conversation

hda-analyzer: Avoid AttributeError when codec has no nodes

PATCH In review Ozan Çağlayan 2 participants 2 messages Feb 4, 2010

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hda-analyzer: Avoid AttributeError when codec has no nodes

When traversing card/codec/nodes during treewidget creation, it's quite possible that codec.nodes raises an AttributeError if the current codec doesn't seem to have a nodes dictionary.

Simply initialize it to an empty dictionary in the beginning of analyze().

---
 hda-analyzer/hda_codec.py |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
hda-analyzer/hda_codec.py +1 -1
index cbea3f8..d587a28 100644
@@ -818,6 +818,7 @@ class HDACodec:
   def analyze(self):
     self.afg = None
     self.mfg = None
+    self.nodes = {}
     self.vendor_id = self.param_read(AC_NODE_ROOT, PARAMS['VENDOR_ID'])
     self.subsystem_id = self.param_read(AC_NODE_ROOT, PARAMS['SUBSYSTEM_ID'])
     self.revision_id = self.param_read(AC_NODE_ROOT, PARAMS['REV_ID'])
@@ -866,7 +867,6 @@ class HDACodec:
 
     nodes_count, nid = self.get_sub_nodes(self.afg)
     self.base_nid = nid
-    self.nodes = {}
     for i in range(nodes_count):
       self.nodes[nid] = HDANode(self, nid)
       nid += 1
Signature · 6 lines
1.6.5.6

_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
#1 lore raw
Quoted 6 lines · Ozan Çağlayan

When traversing card/codec/nodes during treewidget creation, it's quite possible that codec.nodes raises an AttributeError if the current codec doesn't seem to have a nodes dictionary.

Simply initialize it to an empty dictionary in the beginning of analyze().

Thank you for your patch. I had already this change in my local tree. I pushed it to git.alsa-project.org now.

Jaroslav

-----
Jaroslav Kysela <[email protected]>
Linux Kernel Sound Maintainer
ALSA Project, Red Hat, Inc.

_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel