[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [xen staging] tools/libs: stat: Use const whenever we point to literal strings
commit 89aae4ad8f495b647de33f2df5046b3ce68225f8 Author: Julien Grall <jgrall@xxxxxxxxxx> AuthorDate: Tue May 18 14:35:07 2021 +0100 Commit: Julien Grall <jgrall@xxxxxxxxxx> CommitDate: Tue May 18 14:54:05 2021 +0100 tools/libs: stat: Use const whenever we point to literal strings literal strings are not meant to be modified. So we should use const char * rather than char * when we want to store a pointer to them. Signed-off-by: Julien Grall <jgrall@xxxxxxxxxx> Reviewed-by: Anthony PERARD <anthony.perard@xxxxxxxxxx> Acked-by: Wei Liu <wl@xxxxxxx> --- tools/libs/stat/xenstat_linux.c | 4 ++-- tools/libs/stat/xenstat_qmp.c | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/tools/libs/stat/xenstat_linux.c b/tools/libs/stat/xenstat_linux.c index c00b26d4d8..875a0617ad 100644 --- a/tools/libs/stat/xenstat_linux.c +++ b/tools/libs/stat/xenstat_linux.c @@ -66,7 +66,7 @@ static const char PROCNETDEV_HEADER[] = /* We need to get the name of the bridge interface for use with bonding interfaces */ /* Use excludeName parameter to avoid adding bridges we don't care about, eg. virbr0 */ -static void getBridge(char *excludeName, char *result, size_t resultLen) +static void getBridge(const char *excludeName, char *result, size_t resultLen) { struct dirent *de; DIR *d; @@ -113,7 +113,7 @@ static int parseNetDevLine(char *line, char *iface, unsigned long long *rxBytes, int num = 19; /* Regular exception to parse all the information from /proc/net/dev line */ - char *regex = "([^:]*):([^ ]*)[ ]*([^ ]*)[ ]*([^ ]*)[ ]*([^ ]*)[ ]*([^ ]*)[ ]*([^ ]*)" + const char *regex = "([^:]*):([^ ]*)[ ]*([^ ]*)[ ]*([^ ]*)[ ]*([^ ]*)[ ]*([^ ]*)[ ]*([^ ]*)" "[ ]*([^ ]*)[ ]*([^ ]*)[ ]*([^ ]*)[ ]*([^ ]*)[ ]*([^ ]*)[ ]*([^ ]*)[ ]*" "([^ ]*)[ ]*([^ ]*)[ ]*([^ ]*)[ ]*([^ ]*)[ ]*([^ ]*)"; diff --git a/tools/libs/stat/xenstat_qmp.c b/tools/libs/stat/xenstat_qmp.c index 0c5748ba68..2205a04131 100644 --- a/tools/libs/stat/xenstat_qmp.c +++ b/tools/libs/stat/xenstat_qmp.c @@ -38,7 +38,7 @@ #include <yajl/yajl_tree.h> -static unsigned char *qmp_query(int, char *); +static unsigned char *qmp_query(int, const char *); enum query_blockstats { QMP_STATS_RETURN = 0, @@ -80,7 +80,7 @@ enum query_block { static char *qmp_get_block_image(xenstat_node *node, char *qmp_devname, int qfd) { char *tmp, *file = NULL; - char *query_block_cmd = "{ \"execute\": \"query-block\" }"; + const char *query_block_cmd = "{ \"execute\": \"query-block\" }"; static const char *const qblock[] = { [ QMP_BLOCK_RETURN ] = "return", [ QMP_BLOCK_DEVICE ] = "device", @@ -264,7 +264,7 @@ done: } /* Write a command via the QMP. Returns number of bytes written */ -static size_t qmp_write(int qfd, char *cmd, size_t cmd_len) +static size_t qmp_write(int qfd, const char *cmd, size_t cmd_len) { size_t pos = 0; ssize_t res; @@ -317,7 +317,7 @@ static int qmp_read(int qfd, unsigned char **qstats) } /* With the given cmd, query QMP for requested data. Returns allocated buffer containing data or NULL */ -static unsigned char *qmp_query(int qfd, char *cmd) +static unsigned char *qmp_query(int qfd, const char *cmd) { unsigned char *qstats = NULL; int n; @@ -385,8 +385,8 @@ static int qmp_connect(char *path) */ static void read_attributes_qdisk_dom(xenstat_node *node, domid_t domain) { - char *cmd_mode = "{ \"execute\": \"qmp_capabilities\" }"; - char *query_blockstats_cmd = "{ \"execute\": \"query-blockstats\" }"; + const char *cmd_mode = "{ \"execute\": \"qmp_capabilities\" }"; + const char *query_blockstats_cmd = "{ \"execute\": \"query-blockstats\" }"; unsigned char *qmp_stats, *val; char path[80]; int qfd; -- generated by git-patchbot for /home/xen/git/xen.git#staging
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |