[rtems commit] PR 2021 - mdump address problem with volatile
Joel Sherrill
joel at rtems.org
Fri Mar 30 15:18:24 UTC 2012
Module: rtems
Branch: master
Commit: 4648adea97face2b819dc0d6ed8706d04974631e
Changeset: http://git.rtems.org/rtems/commit/?id=4648adea97face2b819dc0d6ed8706d04974631e
Author: Ric Claus <claus at SLAC.Stanford.edu>
Date: Fri Feb 17 13:29:58 2012 -0800
PR 2021 - mdump address problem with volatile
---
cpukit/libmisc/shell/main_mdump.c | 25 ++++++++++++++++---------
1 files changed, 16 insertions(+), 9 deletions(-)
diff --git a/cpukit/libmisc/shell/main_mdump.c b/cpukit/libmisc/shell/main_mdump.c
index 156a6f2..df0d955 100644
--- a/cpukit/libmisc/shell/main_mdump.c
+++ b/cpukit/libmisc/shell/main_mdump.c
@@ -31,6 +31,7 @@ static int args_parse(int argc, char* argv[], void** addr, int* max, int* sz);
static void mdumpB(void* addr, int m);
static void mdumpW(void* addr, int m);
static void mdumpL(void* addr, int m);
+static void mdumpC(void* addr, int m);
int rtems_mdump(void* addr, int max, int sz);
@@ -43,7 +44,7 @@ int rtems_shell_main_mdump(
int max;
int sz;
- if (args_parse(argc, argv, &addr, &max, &sz))
+ if (args_parse(argc, argv, &addr, &max, &sz))
return -1;
return rtems_mdump(addr, max, sz);
}
@@ -114,11 +115,10 @@ int args_parse(int argc,
int rtems_mdump(void* addr, int max, int sz)
{
- unsigned char n;
- unsigned char m;
- volatile unsigned char *pb;
- int res;
- int cnt;
+ unsigned char m;
+ unsigned char *pb;
+ int res;
+ int cnt;
if (!((sz == 1) || (sz == 2) || (sz == 4))) {
printf( "Size argument (%d) is not one of 1 (bytes), "
@@ -147,9 +147,7 @@ int rtems_mdump(void* addr, int max, int sz)
if (sz == 1) mdumpB(pb, cnt);
else if (sz == 2) mdumpW(pb, cnt);
else if (sz == 4) mdumpL(pb, cnt);
- for (n=0;n<=cnt;n++) {
- printf("%c", isprint(pb[n]) ? pb[n] : '.');
- }
+ mdumpC(pb, cnt);
printf("\n");
pb += 16;
}
@@ -191,6 +189,15 @@ void mdumpL(void* addr, int m)
}
+void mdumpC(void* addr, int m)
+{
+ volatile unsigned char* pb = addr;
+ int n;
+ for (n=0;n<=m;n++)
+ printf("%c", isprint(pb[n]) ? pb[n] : '.');
+}
+
+
rtems_shell_cmd_t rtems_shell_MDUMP_Command = {
"mdump", /* name */
"mdump [address [length [size]]]", /* usage */
More information about the vc
mailing list