summaryrefslogtreecommitdiff
path: root/procmem/procmem.c
diff options
context:
space:
mode:
authorAshok Bhat <ashok.bhat@arm.com>2013-01-10 16:24:59 +0000
committerDavid Butcher <david.butcher@arm.com>2013-12-12 17:31:12 +0000
commit10e29de62eb805045437cc9b6ec5a39a464cee67 (patch)
treebb6ec6c7d47651909562219be842e3d12cee8d82 /procmem/procmem.c
parent144d160d4d21e70472fcc6a725ceb2358c1de3fc (diff)
downloadextras-10e29de62eb805045437cc9b6ec5a39a464cee67.tar.gz
procmem: Use size_t instead of int to remove a potential bug.
In procmem.c, num_maps and num_pages are declared as int. Pointers (int*) to these variables are being passed to functions pm_process_maps and pm_map_pagemap respectively, both of which expect size_t * argument. This will lead to problems in 64-bit systems where size_t and int_t have different size. To avoid the issue, num_maps and num_pages are declared as size_t. In addition, loop counters i and j are now declared as size_t to avoid comparison of signed int with unsigned int. Change-Id: I3fc51f9386c9b2d289d34808e19e3811ca4a3dae Signed-off-by: Ashok Bhat <ashok.bhat@arm.com>
Diffstat (limited to 'procmem/procmem.c')
-rw-r--r--procmem/procmem.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/procmem/procmem.c b/procmem/procmem.c
index a9ac68d2..dac00a03 100644
--- a/procmem/procmem.c
+++ b/procmem/procmem.c
@@ -47,13 +47,13 @@ int main(int argc, char *argv[]) {
pm_process_t *proc;
/* maps and such */
- pm_map_t **maps; int num_maps;
+ pm_map_t **maps; size_t num_maps;
struct map_info **mis;
struct map_info *mi;
/* pagemap information */
- uint64_t *pagemap; int num_pages;
+ uint64_t *pagemap; size_t num_pages;
unsigned long address; uint64_t mapentry;
uint64_t count, flags;
@@ -70,7 +70,7 @@ int main(int argc, char *argv[]) {
int hide_zeros;
/* temporary variables */
- int i, j;
+ size_t i, j;
char *endptr;
int error;
@@ -82,7 +82,7 @@ int main(int argc, char *argv[]) {
ws = WS_OFF;
compfn = NULL;
hide_zeros = 0;
- for (i = 1; i < argc - 1; i++) {
+ for (i = 1; i < (size_t)(argc - 1); i++) {
if (!strcmp(argv[i], "-w")) { ws = WS_ONLY; continue; }
if (!strcmp(argv[i], "-W")) { ws = WS_RESET; continue; }
if (!strcmp(argv[i], "-m")) { compfn = NULL; continue; }