tools/misc: Use const whenever we point to literal strings
authorJulien Grall <jgrall@amazon.com>
Tue, 18 May 2021 13:50:32 +0000 (14:50 +0100)
committerJulien Grall <jgrall@amazon.com>
Tue, 18 May 2021 13:54:05 +0000 (14:54 +0100)
literal strings are not meant to be modified. So we should use const
char * rather than char * when we we to store a pointer to them.

Signed-off-by: Julien Grall <jgrall@amazon.com>
Reviewed-by: Anthony PERARD <anthony.perard@citrix.com>
Acked-by: Wei Liu <wl@xen.org>
tools/misc/xen-detect.c
tools/misc/xenhypfs.c

index eac9e46a35bbf1ab7ec381359275c38eef4ec137..18b28dabf3110ce89d71c7f300409e8e1ce40704 100644 (file)
@@ -44,7 +44,7 @@ enum guest_type {
     XEN_NONE = 3
 };
 
-static char *type;
+static const char *type;
 static char *ver;
 
 static void cpuid(uint32_t idx, uint32_t *regs, int pv_context)
index 5da24aed905c95940e9193e2474bc05a9043b904..df398b07bdc0ddb553ae3bb3d254a8859082d844 100644 (file)
@@ -81,9 +81,9 @@ static int xenhypfs_wr(char *path, char *val)
     return ret;
 }
 
-static char *xenhypfs_type(struct xenhypfs_dirent *ent)
+static const char *xenhypfs_type(struct xenhypfs_dirent *ent)
 {
-    char *res;
+    const char *res;
 
     switch (ent->type) {
     case xenhypfs_type_dir:
@@ -134,7 +134,7 @@ static int xenhypfs_ls(char *path)
     return ret;
 }
 
-static int xenhypfs_tree_sub(char *path, unsigned int depth)
+static int xenhypfs_tree_sub(const char *path, unsigned int depth)
 {
     struct xenhypfs_dirent *ent;
     unsigned int n, i;