summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@linux.intel.com>2010-12-08 20:40:00 (GMT)
committerH. Peter Anvin <hpa@linux.intel.com>2010-12-08 20:40:00 (GMT)
commit722f0f45ce8c001628a35f5994ac7a627678ddbc (patch)
treee4471efaf05d45d672687c0d1256d4b8a4e6ffef
parent9526a8dc64dc3e065e01065be0f295b1431b6ea6 (diff)
downloadmemhack-master.zip
memhack-master.tar.gz
memhack-master.tar.bz2
memhack-master.tar.xz
getmem: don't clobber "len", we need it for outputHEADmaster
-rw-r--r--getmem.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/getmem.c b/getmem.c
index 22a06cb..160125a 100644
--- a/getmem.c
+++ b/getmem.c
@@ -55,7 +55,7 @@ void usage(void)
int main(int argc, char *argv[])
{
- uintptr_t start, mapstart, len, maplen;
+ uintptr_t start, mapstart, len, left, maplen;
char *mem, *buffer;
volatile char *ptr;
int fd;
@@ -128,13 +128,14 @@ int main(int argc, char *argv[])
memcpy(buffer, mem+(start-mapstart), len);
} else {
ptr = mem;
+ left = len;
- while (len) {
+ while (left) {
static const int next_lower_power_of_2[8] =
{ 0, 1, 2, 2, 4, 4, 4, 4 };
- if (len < size)
- size = next_lower_power_of_2[len];
+ if (left < size)
+ size = next_lower_power_of_2[left];
switch (size) {
case 1:
@@ -153,7 +154,7 @@ int main(int argc, char *argv[])
abort();
}
buffer += size;
- len -= size;
+ left -= size;
}
}