ia64/xen-unstable

changeset 17824:f70dff36213b

xenstat: some cleanups
sprintf -> snprintf
malloc(n * m) -> calloc(n, m)
get rid of a cast

Signed-off-by: Christoph Egger <Christoph.Egger@amd.com>
author Keir Fraser <keir.fraser@citrix.com>
date Tue Jun 10 14:15:53 2008 +0100 (2008-06-10)
parents d77214a97e04
children 57b8c74c35ef
files tools/xenstat/libxenstat/src/xenstat_linux.c tools/xenstat/xentop/xentop.c
line diff
     1.1 --- a/tools/xenstat/libxenstat/src/xenstat_linux.c	Tue Jun 10 13:50:31 2008 +0100
     1.2 +++ b/tools/xenstat/libxenstat/src/xenstat_linux.c	Tue Jun 10 14:15:53 2008 +0100
     1.3 @@ -165,7 +165,8 @@ static int read_attributes_vbd(const cha
     1.4  	static char file_name[80];
     1.5  	int fd, num_read;
     1.6  
     1.7 -	sprintf(file_name, "%s/%s/%s", SYSFS_VBD_PATH, vbd_directory, what);
     1.8 +	snprintf(file_name, sizeof(file_name), "%s/%s/%s",
     1.9 +		SYSFS_VBD_PATH, vbd_directory, what);
    1.10  	fd = open(file_name, O_RDONLY, 0);
    1.11  	if (fd==-1) return -1;
    1.12  	num_read = read(fd, ret, cap - 1);
     2.1 --- a/tools/xenstat/xentop/xentop.c	Tue Jun 10 13:50:31 2008 +0100
     2.2 +++ b/tools/xenstat/xentop/xentop.c	Tue Jun 10 14:15:53 2008 +0100
     2.3 @@ -755,10 +755,11 @@ void do_summary(void)
     2.4  	unsigned i, num_domains = 0;
     2.5  	unsigned long long used = 0;
     2.6  	xenstat_domain *domain;
     2.7 +	time_t curt;
     2.8  
     2.9  	/* Print program name, current time, and number of domains */
    2.10 -	strftime(time_str, TIME_STR_LEN, TIME_STR_FORMAT,
    2.11 -	         localtime((const time_t *)&curtime.tv_sec));
    2.12 +	curt = curtime.tv_sec;
    2.13 +	strftime(time_str, TIME_STR_LEN, TIME_STR_FORMAT, localtime(&curt));
    2.14  	num_domains = xenstat_node_num_domains(cur_node);
    2.15  	ver_str = xenstat_node_xen_version(cur_node);
    2.16  	print("xentop - %s   Xen %s\n", time_str, ver_str);
    2.17 @@ -978,7 +979,7 @@ static void top(void)
    2.18  	/* Count the number of domains for which to report data */
    2.19  	num_domains = xenstat_node_num_domains(cur_node);
    2.20  
    2.21 -	domains = malloc(num_domains*sizeof(xenstat_domain *));
    2.22 +	domains = calloc(num_domains, sizeof(xenstat_domain *));
    2.23  	if(domains == NULL)
    2.24  		fail("Failed to allocate memory\n");
    2.25