Skip to content

Commit

Permalink
memory_display: Use consistent types
Browse files Browse the repository at this point in the history
memory_display uses three different types for 32bit variables, three
types for 16bit variables and three types for 8bit variables. Clean up
this mess and use one type per variable width.

Signed-off-by: Sascha Hauer <[email protected]>
  • Loading branch information
saschahauer committed May 28, 2015
1 parent 6792d94 commit ccd8dd4
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions common/memory_display.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,29 @@

int memory_display(const void *addr, loff_t offs, unsigned nbytes, int size, int swab)
{
ulong linebytes, i;
u_char *cp;
unsigned long linebytes, i;
unsigned char *cp;

/* Print the lines.
*
* We buffer all read data, so we can make sure data is read only
* once, and all accesses are with the specified bus width.
*/
do {
char linebuf[DISP_LINE_LEN];
uint32_t *uip = (uint *)linebuf;
uint16_t *usp = (ushort *)linebuf;
uint8_t *ucp = (u_char *)linebuf;
unsigned char linebuf[DISP_LINE_LEN];
uint32_t *uip = (uint32_t *)linebuf;
uint16_t *usp = (uint16_t *)linebuf;
uint8_t *ucp = (uint8_t *)linebuf;
unsigned count = 52;

printf("%08llx:", offs);
linebytes = (nbytes > DISP_LINE_LEN) ? DISP_LINE_LEN : nbytes;

for (i = 0; i < linebytes; i += size) {
if (size == 4) {
u32 res;
uint32_t res;
data_abort_mask();
res = *((uint *)addr);
res = *((uint32_t *)addr);
if (swab)
res = __swab32(res);
if (data_abort_unmask()) {
Expand All @@ -39,9 +39,9 @@ int memory_display(const void *addr, loff_t offs, unsigned nbytes, int size, int
}
*uip++ = res;
} else if (size == 2) {
u16 res;
uint16_t res;
data_abort_mask();
res = *((ushort *)addr);
res = *((uint16_t *)addr);
if (swab)
res = __swab16(res);
if (data_abort_unmask()) {
Expand All @@ -52,9 +52,9 @@ int memory_display(const void *addr, loff_t offs, unsigned nbytes, int size, int
}
*usp++ = res;
} else {
u8 res;
uint8_t res;
data_abort_mask();
res = *((u_char *)addr);
res = *((uint8_t *)addr);
if (data_abort_unmask()) {
res = 0xff;
count -= printf(" xx");
Expand All @@ -70,7 +70,7 @@ int memory_display(const void *addr, loff_t offs, unsigned nbytes, int size, int
while (count--)
putchar(' ');

cp = (uint8_t *)linebuf;
cp = linebuf;
for (i = 0; i < linebytes; i++) {
if ((*cp < 0x20) || (*cp > 0x7e))
putchar('.');
Expand Down

0 comments on commit ccd8dd4

Please sign in to comment.