[svn-r10035] Purpose: Bug fix

Description: On SGI Altix(cobalt) Linux, wrong values were printed out for enum data type
members.  No apparent reason was discovered.

Solution:  use another pointer to the buffer containing the member value.  It seems fix the
problem.

Platforms tested:  cobalt - simple change, where the bug was discovered.
This commit is contained in:
Raymond Lu 2005-02-17 15:49:08 -05:00
parent 45f2b11026
commit 055c563da4
2 changed files with 18 additions and 4 deletions

View File

@ -3671,6 +3671,7 @@ print_enum(hid_t type)
{ {
char **name = NULL; /*member names */ char **name = NULL; /*member names */
unsigned char *value = NULL; /*value array */ unsigned char *value = NULL; /*value array */
unsigned char *copy = NULL; /*a pointer to value array */
unsigned nmembs; /*number of members */ unsigned nmembs; /*number of members */
int nchars; /*number of output characters */ int nchars; /*number of output characters */
hid_t super; /*enum base integer type */ hid_t super; /*enum base integer type */
@ -3733,11 +3734,17 @@ print_enum(hid_t type)
for (j = 0; j < dst_size; j++) for (j = 0; j < dst_size; j++)
printf("%02x", value[i * dst_size + j]); printf("%02x", value[i * dst_size + j]);
} else if (H5T_SGN_NONE == H5Tget_sign(native)) { } else if (H5T_SGN_NONE == H5Tget_sign(native)) {
/*On SGI Altix(cobalt), wrong values were printed out with "value+i*dst_size"
*strangely, unless use another pointer "copy".*/
copy = value+i*dst_size;
HDfprintf(stdout,"%" H5_PRINTF_LL_WIDTH "u", *((unsigned long_long *) HDfprintf(stdout,"%" H5_PRINTF_LL_WIDTH "u", *((unsigned long_long *)
((void *) (value + i * dst_size)))); ((void *)copy)));
} else { } else {
/*On SGI Altix(cobalt), wrong values were printed out with "value+i*dst_size"
*strangely, unless use another pointer "copy".*/
copy = value+i*dst_size;
HDfprintf(stdout,"%" H5_PRINTF_LL_WIDTH "d", HDfprintf(stdout,"%" H5_PRINTF_LL_WIDTH "d",
*((long_long *) ((void *) (value + i * dst_size)))); *((long_long *) ((void *)copy)));
} }
printf(";\n"); printf(";\n");

View File

@ -759,6 +759,7 @@ display_enum_type(hid_t type, int ind)
{ {
char **name=NULL; /* member names */ char **name=NULL; /* member names */
unsigned char *value=NULL; /* value array */ unsigned char *value=NULL; /* value array */
unsigned char *copy = NULL; /* a pointer to value array */
unsigned nmembs; /* number of members */ unsigned nmembs; /* number of members */
int nchars; /* number of output characters */ int nchars; /* number of output characters */
hid_t super; /* enum base integer type */ hid_t super; /* enum base integer type */
@ -816,11 +817,17 @@ display_enum_type(hid_t type, int ind)
for (j=0; j<dst_size; j++) for (j=0; j<dst_size; j++)
printf("%02x", value[i*dst_size+j]); printf("%02x", value[i*dst_size+j]);
} else if (H5T_SGN_NONE==H5Tget_sign(native)) { } else if (H5T_SGN_NONE==H5Tget_sign(native)) {
/*On SGI Altix(cobalt), wrong values were printed out with "value+i*dst_size"
*strangely, unless use another pointer "copy".*/
copy = value+i*dst_size;
HDfprintf(stdout,"%"H5_PRINTF_LL_WIDTH"u", HDfprintf(stdout,"%"H5_PRINTF_LL_WIDTH"u",
*((unsigned long_long*)((void*)(value+i*dst_size)))); *((unsigned long_long*)((void*)copy)));
} else { } else {
/*On SGI Altix(cobalt), wrong values were printed out with "value+i*dst_size"
*strangely, unless use another pointer "copy".*/
copy = value+i*dst_size;
HDfprintf(stdout,"%"H5_PRINTF_LL_WIDTH"d", HDfprintf(stdout,"%"H5_PRINTF_LL_WIDTH"d",
*((long_long*)((void*)(value+i*dst_size)))); *((long_long*)((void*)copy)));
} }
} }