diff options
author | Keir Fraser <keir.fraser@citrix.com> | 2009-10-15 08:29:33 +0100 |
---|---|---|
committer | Keir Fraser <keir.fraser@citrix.com> | 2009-10-15 08:29:33 +0100 |
commit | 01dbe5547145beb337feb8e5f61e6d595d27ed17 (patch) | |
tree | e8f1eb4dcff1d391c2c63253034bc91317096eaa /tools/misc/xenlockprof.c | |
parent | 51f36202c47f6bb84a67c6e387c1b7afb69c1347 (diff) | |
download | xen-01dbe5547145beb337feb8e5f61e6d595d27ed17.tar.gz xen-01dbe5547145beb337feb8e5f61e6d595d27ed17.tar.bz2 xen-01dbe5547145beb337feb8e5f61e6d595d27ed17.zip |
lockprof: Fix x86_32 build and clean up coding style
Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
Diffstat (limited to 'tools/misc/xenlockprof.c')
-rw-r--r-- | tools/misc/xenlockprof.c | 35 |
1 files changed, 19 insertions, 16 deletions
diff --git a/tools/misc/xenlockprof.c b/tools/misc/xenlockprof.c index f2a0a90568..3e22e949a6 100644 --- a/tools/misc/xenlockprof.c +++ b/tools/misc/xenlockprof.c @@ -16,6 +16,7 @@ #include <sys/mman.h> #include <errno.h> #include <string.h> +#include <inttypes.h> static int lock_pages(void *addr, size_t len) { @@ -42,7 +43,7 @@ int main(int argc, char *argv[]) char name[60]; xc_lockprof_data_t *data; - if ((argc > 2) || ((argc == 2) && (strcmp(argv[1], "-r") != 0))) + if ( (argc > 2) || ((argc == 2) && (strcmp(argv[1], "-r") != 0)) ) { printf("%s: [-r]\n", argv[0]); printf("no args: print lock profile data\n"); @@ -50,28 +51,28 @@ int main(int argc, char *argv[]) return 1; } - if ((xc_handle = xc_interface_open()) == -1) + if ( (xc_handle = xc_interface_open()) == -1 ) { fprintf(stderr, "Error opening xc interface: %d (%s)\n", errno, strerror(errno)); return 1; } - if (argc > 1) + if ( argc > 1 ) { - if (xc_lockprof_control(xc_handle, XEN_SYSCTL_LOCKPROF_reset, NULL, - NULL, NULL) != 0) + if ( xc_lockprof_control(xc_handle, XEN_SYSCTL_LOCKPROF_reset, NULL, + NULL, NULL) != 0 ) { fprintf(stderr, "Error reseting profile data: %d (%s)\n", errno, strerror(errno)); return 1; } - return 1; + return 0; } n = 0; - if (xc_lockprof_control(xc_handle, XEN_SYSCTL_LOCKPROF_query, &n, - NULL, NULL) != 0) + if ( xc_lockprof_control(xc_handle, XEN_SYSCTL_LOCKPROF_query, &n, + NULL, NULL) != 0 ) { fprintf(stderr, "Error getting number of profile records: %d (%s)\n", errno, strerror(errno)); @@ -80,7 +81,7 @@ int main(int argc, char *argv[]) n += 32; /* just to be sure */ data = malloc(sizeof(*data) * n); - if ((data == NULL) || (lock_pages(data, sizeof(*data) * n) != 0)) + if ( (data == NULL) || (lock_pages(data, sizeof(*data) * n) != 0) ) { fprintf(stderr, "Could not alloc or lock buffers: %d (%s)\n", errno, strerror(errno)); @@ -89,7 +90,7 @@ int main(int argc, char *argv[]) i = n; if ( xc_lockprof_control(xc_handle, XEN_SYSCTL_LOCKPROF_query, &i, - &time, data) != 0) + &time, data) != 0 ) { fprintf(stderr, "Error getting profile records: %d (%s)\n", errno, strerror(errno)); @@ -98,16 +99,17 @@ int main(int argc, char *argv[]) unlock_pages(data, sizeof(*data) * n); - if (i > n) + if ( i > n ) { printf("data incomplete, %d records are missing!\n\n", i - n); i = n; } + sl = 0; sb = 0; - for (j = 0; j < i; j++) + for ( j = 0; j < i; j++ ) { - switch (data[j].type) + switch ( data[j].type ) { case LOCKPROF_TYPE_GLOBAL: sprintf(name, "global lock %s", data[j].name); @@ -117,15 +119,16 @@ int main(int argc, char *argv[]) break; default: sprintf(name, "unknown type(%d) %d lock %s", data[j].type, - data[j].idx, data[j].name); + data[j].idx, data[j].name); break; } l = (double)(data[j].lock_time) / 1E+09; b = (double)(data[j].block_time) / 1E+09; sl += l; sb += b; - printf("%-50s: lock:%12ld(%20.9fs), block:%12ld(%20.9fs)\n", - name, data[j].lock_cnt, l, data[j].block_cnt, b); + printf("%-50s: lock:%12"PRId64"(%20.9fs), " + "block:%12"PRId64"(%20.9fs)\n", + name, data[j].lock_cnt, l, data[j].block_cnt, b); } l = (double)time / 1E+09; printf("total profiling time: %20.9fs\n", l); |