We cannot assume char is signed or unsigned.

This commit is contained in:
Ward Fisher 2017-02-07 14:20:59 -07:00
parent 7a0e61f97c
commit e100aaf6b0
2 changed files with 8 additions and 7 deletions

View File

@ -2426,7 +2426,7 @@ dnl
define(`NCX_GETN_Byte_Body',dnl define(`NCX_GETN_Byte_Body',dnl
`dnl `dnl
(void) memcpy(tp, *xpp, (size_t)nelems); (void) memcpy(tp, *xpp, (size_t)nelems);
*xpp = (void *)((char *)(*xpp) + nelems); *xpp = (void *)((schar *)(*xpp) + nelems);
return NC_NOERR; return NC_NOERR;
')dnl ')dnl
dnl dnl dnl dnl dnl dnl
@ -2441,7 +2441,7 @@ define(`NCX_PAD_GETN_Byte_Body',dnl
rndup = X_ALIGN - rndup; rndup = X_ALIGN - rndup;
(void) memcpy(tp, *xpp, (size_t)nelems); (void) memcpy(tp, *xpp, (size_t)nelems);
*xpp = (void *)((char *)(*xpp) + nelems + rndup); *xpp = (void *)((schar *)(*xpp) + nelems + rndup);
return NC_NOERR; return NC_NOERR;
')dnl ')dnl

View File

@ -979,7 +979,7 @@ void
check_vars(int ncid) check_vars(int ncid)
{ {
size_t index[MAX_RANK]; size_t index[MAX_RANK];
char text, name[NC_MAX_NAME]; signed char text, name[NC_MAX_NAME];
int i, err; /* status */ int i, err; /* status */
size_t j; size_t j;
int nok = 0; /* count of valid comparisons */ int nok = 0; /* count of valid comparisons */
@ -987,6 +987,7 @@ check_vars(int ncid)
double value, expect; double value, expect;
nc_type xtype; nc_type xtype;
size_t length; size_t length;
signed char tmp_char;
for (i = 0; i < numVars; i++) { for (i = 0; i < numVars; i++) {
isChar = var_type[i] == NC_CHAR; isChar = var_type[i] == NC_CHAR;
@ -1013,11 +1014,11 @@ check_vars(int ncid)
expect = hash( var_type[i], var_rank[i], index ); expect = hash( var_type[i], var_rank[i], index );
if (isChar) { if (isChar) {
err = nc_get_var1_text(ncid, i, index, &text); err = nc_get_var1_text(ncid, i, index, &text);
IF (err) IF (err)
error("nc_get_var1_text: %s", nc_strerror(err)); error("nc_get_var1_text: %s", nc_strerror(err));
IF (text != (char)expect) { IF (text != expect) {
error("Var %s [%lu] value read %hhd not that expected %g ", error("Var %s [%lu] value read %hhd not that expected %g ",
var_name[i], j, text, expect); var_name[i], j, text, expect);
print_n_size_t(var_rank[i], index); print_n_size_t(var_rank[i], index);
} else { } else {
nok++; nok++;