[Pdbg] [PATCH v2 4/7] libpdbg/htm: Both `chtm` and `nhtm` classes are valid

Cyril Bur cyrilbur at gmail.com
Wed Feb 14 15:27:40 AEDT 2018


Signed-off-by: Cyril Bur <cyrilbur at gmail.com>
---
 libpdbg/htm.c    | 6 ++++--
 libpdbg/target.c | 8 ++++++++
 libpdbg/target.h | 1 +
 3 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/libpdbg/htm.c b/libpdbg/htm.c
index 33fe64c..692b4e0 100644
--- a/libpdbg/htm.c
+++ b/libpdbg/htm.c
@@ -168,8 +168,10 @@ struct htm_status {
 
 static struct htm *check_and_convert(struct pdbg_target *target)
 {
-	if (strcmp(target->class, "nhtm"))
-		return NULL;
+
+	if (!pdbg_target_is_class(target, "nhtm") &&
+	    !pdbg_target_is_class(target, "chtm"))
+	    return NULL;
 
 	return target_to_htm(target);
 }
diff --git a/libpdbg/target.c b/libpdbg/target.c
index c34271b..1eb85bb 100644
--- a/libpdbg/target.c
+++ b/libpdbg/target.c
@@ -347,3 +347,11 @@ void pdbg_target_probe(void)
 	dt_for_each_node(dt_root, dn)
 		_target_probe(dn);
 }
+
+bool pdbg_target_is_class(struct pdbg_target *target, const char *class)
+{
+	if (!target || !target->class || !class)
+		return false;
+	return strcmp(target->class, class) == 0;
+}
+
diff --git a/libpdbg/target.h b/libpdbg/target.h
index 2ae0106..0a618e2 100644
--- a/libpdbg/target.h
+++ b/libpdbg/target.h
@@ -51,6 +51,7 @@ struct pdbg_target {
 struct pdbg_target *require_target_parent(struct pdbg_target *target);
 struct pdbg_target_class *find_target_class(const char *name);
 struct pdbg_target_class *require_target_class(const char *name);
+bool pdbg_target_is_class(struct pdbg_target *target, const char *class);
 
 extern struct list_head empty_list;
 #define for_each_class_target(class_name, target)			\
-- 
2.16.1



More information about the Pdbg mailing list