[Pdbg] [PATCH v3 01/22] libpdbg: class name and name should be const
Amitay Isaacs
amitay at ozlabs.org
Mon Sep 23 18:48:20 AEST 2019
Each function returns a pointer to the actual name. User must not be
able to modify that.
Signed-off-by: Amitay Isaacs <amitay at ozlabs.org>
Reviewed-by: Alistair Popple <alistair at popple.id.au>
---
libpdbg/libpdbg.c | 4 ++--
libpdbg/libpdbg.h | 4 ++--
src/main.c | 2 +-
src/scom.c | 2 +-
4 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/libpdbg/libpdbg.c b/libpdbg/libpdbg.c
index 0c5a451..aade5d3 100644
--- a/libpdbg/libpdbg.c
+++ b/libpdbg/libpdbg.c
@@ -120,12 +120,12 @@ uint32_t pdbg_parent_index(struct pdbg_target *target, char *class)
return -1;
}
-char *pdbg_target_class_name(struct pdbg_target *target)
+const char *pdbg_target_class_name(struct pdbg_target *target)
{
return target->class;
}
-char *pdbg_target_name(struct pdbg_target *target)
+const char *pdbg_target_name(struct pdbg_target *target)
{
return target->name;
}
diff --git a/libpdbg/libpdbg.h b/libpdbg/libpdbg.h
index 235ff85..44af8cf 100644
--- a/libpdbg/libpdbg.h
+++ b/libpdbg/libpdbg.h
@@ -113,8 +113,8 @@ uint32_t pdbg_target_index(struct pdbg_target *target);
char *pdbg_target_path(const struct pdbg_target *target);
struct pdbg_target *pdbg_target_from_path(struct pdbg_target *target, const char *path);
uint32_t pdbg_parent_index(struct pdbg_target *target, char *klass);
-char *pdbg_target_class_name(struct pdbg_target *target);
-char *pdbg_target_name(struct pdbg_target *target);
+const char *pdbg_target_class_name(struct pdbg_target *target);
+const char *pdbg_target_name(struct pdbg_target *target);
const char *pdbg_target_dn_name(struct pdbg_target *target);
void *pdbg_target_priv(struct pdbg_target *target);
void pdbg_target_priv_set(struct pdbg_target *target, void *priv);
diff --git a/src/main.c b/src/main.c
index efdc4bb..44d1c55 100644
--- a/src/main.c
+++ b/src/main.c
@@ -518,7 +518,7 @@ static void print_target(struct pdbg_target *target, int level)
int i;
struct pdbg_target *next;
enum pdbg_target_status status;
- char *classname;
+ const char *classname;
/* Does this target actually exist? */
status = pdbg_target_status(target);
diff --git a/src/scom.c b/src/scom.c
index 8d8e988..c747f3d 100644
--- a/src/scom.c
+++ b/src/scom.c
@@ -29,7 +29,7 @@
/* Check if a target has scom region */
static bool scommable(struct pdbg_target *target)
{
- char *classname;
+ const char *classname;
classname = pdbg_target_class_name(target);
if (!strcmp(classname, "pib") ||
--
2.21.0
More information about the Pdbg
mailing list