[alsa-devel] [PATCH] 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().
Signed-off-by: Ozan Çağlayan ozan@pardus.org.tr --- hda-analyzer/hda_codec.py | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/hda-analyzer/hda_codec.py b/hda-analyzer/hda_codec.py index cbea3f8..d587a28 100644 --- a/hda-analyzer/hda_codec.py +++ b/hda-analyzer/hda_codec.py @@ -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
On Thu, 4 Feb 2010, Ozan Çağlayan wrote:
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 perex@perex.cz Linux Kernel Sound Maintainer ALSA Project, Red Hat, Inc.
participants (2)
-
Jaroslav Kysela
-
Ozan Çağlayan