Skip to content

Commit

Permalink
Fix long-standing cosmetic HHC02614 cckddiag DEVHDR print bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Fish-Git committed Apr 16, 2019
1 parent b64d579 commit 21692cb
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 11 deletions.
9 changes: 8 additions & 1 deletion cckddiag.c
Original file line number Diff line number Diff line change
Expand Up @@ -663,10 +663,17 @@ char pathname[ MAX_PATH ]; /* file path in host format */

if (cmd_devhdr)
{
BYTE* p = (BYTE*) &devhdr;

// "%s - %d (decimal) bytes:"
printf("\n");
WRMSG( HHC02614, "I", "DEVHDR", (int) CKD_DEVHDR_SIZE );
data_dump( &devhdr, CKD_DEVHDR_SIZE );

// Note: first 8 bytes of DEVHDR is in ASCII, but
// the data_dump function dumps 16 bytes per line.
data_dump_ascii ( p, 16 );
data_dump_offset( p + 16, CKD_DEVHDR_SIZE, 16 );

printf("\n");
}

Expand Down
9 changes: 8 additions & 1 deletion cckddiag64.c
Original file line number Diff line number Diff line change
Expand Up @@ -652,10 +652,17 @@ char pathname[ MAX_PATH ]; /* file path in host format */

if (cmd_devhdr)
{
BYTE* p = (BYTE*) &devhdr;

// "%s - %d (decimal) bytes:"
printf("\n");
WRMSG( HHC02614, "I", "DEVHDR", (int) CKD_DEVHDR_SIZE );
data_dump( &devhdr, CKD_DEVHDR_SIZE );

// Note: first 8 bytes of DEVHDR is in ASCII, but
// the data_dump function dumps 16 bytes per line.
data_dump_ascii ( p, 16 );
data_dump_offset( p + 16, CKD_DEVHDR_SIZE, 16 );

printf("\n");
}

Expand Down
7 changes: 6 additions & 1 deletion dasdblks.h
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,12 @@ DUT_DLL_IMPORT void convert_to_ebcdic( BYTE* dest, int len, const char* source )

DUT_DLL_IMPORT int make_asciiz (char *dest, int destlen, BYTE *src, int srclen);
DUT_DLL_IMPORT void build_vol1( void* buf, const char* volser, const char* owner, bool ckddasd );
DUT_DLL_IMPORT void data_dump( void* addr, unsigned int len );

DUT_DLL_IMPORT void data_dump ( void* addr, unsigned int len );
DUT_DLL_IMPORT void data_dump_ascii( void* addr, unsigned int len );

DUT_DLL_IMPORT void data_dump_offset ( void* addr, unsigned int len, unsigned int offset );
DUT_DLL_IMPORT void data_dump_offset_ascii( void* addr, unsigned int len, unsigned int offset );

DUT_DLL_IMPORT int read_track (CIFBLK *cif, U32 cyl, U8 head);

Expand Down
34 changes: 26 additions & 8 deletions dasdutil.c
Original file line number Diff line number Diff line change
Expand Up @@ -156,15 +156,15 @@ static void same_as_above( int* firstsame, int* lastsame,
/*-------------------------------------------------------------------*/
/* Subroutine to print a data block in hex and character format. */
/*-------------------------------------------------------------------*/
DLL_EXPORT void data_dump ( void* addr, unsigned int len )
static void do_data_dump( bool ascii, void* addr, unsigned int len, unsigned int begoffset )
{
#define DD_BPL 16 // bytes per line
#define MAX_DD 2048 // must be multiple of DD_BPL

CASSERT( MAX_DD == ROUND_UP( MAX_DD, DD_BPL ), dasdutil_c );

unsigned int maxoffset = len > MAX_DD ? MAX_DD : len;
unsigned int i, xi, offset, lineoff = 0;
unsigned int i, xi, offset, lineoff = begoffset;

int firstsame = 0, lastsame = 0;
BYTE c = 0, *pchar = NULL;
Expand All @@ -175,9 +175,9 @@ DLL_EXPORT void data_dump ( void* addr, unsigned int len )

pchar = (BYTE*)addr; /* init pointer to char being processed */

for (offset=0; offset < maxoffset; )
for (offset = begoffset; offset < maxoffset; )
{
if (offset > 0) /* (only if NOT first time) */
if (offset > begoffset) /* (only if NOT first time) */
{
/* Current line same as previous line? */
if (strcmp( hex_chars, prev_hex ) == 0)
Expand Down Expand Up @@ -212,10 +212,8 @@ DLL_EXPORT void data_dump ( void* addr, unsigned int len )
sprintf( hex_chars+xi, "%2.2X", c );
print_chars[i] = '.';

if (isprint(c))
print_chars[i] = c;

c = guest_to_host(c);
if (!ascii)
c = guest_to_host(c);

if (isprint(c))
print_chars[i] = c;
Expand All @@ -240,6 +238,26 @@ DLL_EXPORT void data_dump ( void* addr, unsigned int len )

} /* end function data_dump */

DLL_EXPORT void data_dump( void* addr, unsigned int len )
{
do_data_dump( false, addr, len, 0 );
}

DLL_EXPORT void data_dump_ascii( void* addr, unsigned int len )
{
do_data_dump( true, addr, len, 0 );
}

DLL_EXPORT void data_dump_offset( void* addr, unsigned int len, unsigned int offset )
{
do_data_dump( false, addr, len, offset );
}

DLL_EXPORT void data_dump_offset_ascii( void* addr, unsigned int len, unsigned int offset )
{
do_data_dump( true, addr, len, offset );
}

/*-------------------------------------------------------------------*/
/* Subroutine to read a track from the CKD DASD image */
/* Input: */
Expand Down

0 comments on commit 21692cb

Please sign in to comment.