diff --git a/libsrc4/nc4var.c b/libsrc4/nc4var.c index 61f43ec13..049dbf119 100644 --- a/libsrc4/nc4var.c +++ b/libsrc4/nc4var.c @@ -659,7 +659,7 @@ nc4_convert_type(const void *src, void *dest, const nc_type src_type, { if (*bp < 0) (*range_error)++; - *ubp++ = *bp++; + *ubp++ = (unsigned char)*bp++; } break; case NC_SHORT: @@ -671,7 +671,7 @@ nc4_convert_type(const void *src, void *dest, const nc_type src_type, { if (*bp < 0) (*range_error)++; - *usp++ = *bp++; + *usp++ = (unsigned short)*bp++; } break; case NC_INT: @@ -683,7 +683,7 @@ nc4_convert_type(const void *src, void *dest, const nc_type src_type, { if (*bp < 0) (*range_error)++; - *uip++ = *bp++; + *uip++ = (unsigned int)*bp++; } break; case NC_INT64: @@ -695,7 +695,7 @@ nc4_convert_type(const void *src, void *dest, const nc_type src_type, { if (*bp < 0) (*range_error)++; - *ulip++ = *bp++; + *ulip++ = (unsigned long long)*bp++; } break; case NC_FLOAT: @@ -721,7 +721,7 @@ nc4_convert_type(const void *src, void *dest, const nc_type src_type, { if (!strict_nc3 && *ubp > X_SCHAR_MAX) (*range_error)++; - *bp++ = *ubp++; + *bp++ = (signed char)*ubp++; } break; case NC_SHORT: @@ -775,7 +775,7 @@ nc4_convert_type(const void *src, void *dest, const nc_type src_type, { if (*sp > X_UCHAR_MAX || *sp < 0) (*range_error)++; - *ubp++ = *sp++; + *ubp++ = (unsigned char)*sp++; } break; case NC_BYTE: @@ -783,7 +783,7 @@ nc4_convert_type(const void *src, void *dest, const nc_type src_type, { if (*sp > X_SCHAR_MAX || *sp < X_SCHAR_MIN) (*range_error)++; - *bp++ = *sp++; + *bp++ = (signed char)*sp++; } break; case NC_SHORT: @@ -795,7 +795,7 @@ nc4_convert_type(const void *src, void *dest, const nc_type src_type, { if (*sp < 0) (*range_error)++; - *usp++ = *sp++; + *usp++ = (unsigned short)*sp++; } break; case NC_INT: @@ -807,7 +807,7 @@ nc4_convert_type(const void *src, void *dest, const nc_type src_type, { if (*sp < 0) (*range_error)++; - *uip++ = *sp++; + *uip++ = (unsigned int)*sp++; } break; case NC_INT64: @@ -819,7 +819,7 @@ nc4_convert_type(const void *src, void *dest, const nc_type src_type, { if (*sp < 0) (*range_error)++; - *ulip++ = *sp++; + *ulip++ = (unsigned long long)*sp++; } break; case NC_FLOAT: @@ -845,7 +845,7 @@ nc4_convert_type(const void *src, void *dest, const nc_type src_type, { if (*usp > X_UCHAR_MAX) (*range_error)++; - *ubp++ = *usp++; + *ubp++ = (unsigned char)*usp++; } break; case NC_BYTE: @@ -853,7 +853,7 @@ nc4_convert_type(const void *src, void *dest, const nc_type src_type, { if (*usp > X_SCHAR_MAX) (*range_error)++; - *bp++ = *usp++; + *bp++ = (signed char)*usp++; } break; case NC_SHORT: @@ -861,7 +861,7 @@ nc4_convert_type(const void *src, void *dest, const nc_type src_type, { if (*usp > X_SHORT_MAX) (*range_error)++; - *sp++ = *usp++; + *sp++ = (signed short)*usp++; } break; case NC_USHORT: @@ -907,7 +907,7 @@ nc4_convert_type(const void *src, void *dest, const nc_type src_type, { if (*ip > X_UCHAR_MAX || *ip < 0) (*range_error)++; - *ubp++ = *ip++; + *ubp++ = (unsigned char)*ip++; } break; case NC_BYTE: @@ -915,7 +915,7 @@ nc4_convert_type(const void *src, void *dest, const nc_type src_type, { if (*ip > X_SCHAR_MAX || *ip < X_SCHAR_MIN) (*range_error)++; - *bp++ = *ip++; + *bp++ = (signed char)*ip++; } break; case NC_SHORT: @@ -923,7 +923,7 @@ nc4_convert_type(const void *src, void *dest, const nc_type src_type, { if (*ip > X_SHORT_MAX || *ip < X_SHORT_MIN) (*range_error)++; - *sp++ = *ip++; + *sp++ = (short)*ip++; } break; case NC_USHORT: @@ -931,7 +931,7 @@ nc4_convert_type(const void *src, void *dest, const nc_type src_type, { if (*ip > X_USHORT_MAX || *ip < 0) (*range_error)++; - *usp++ = *ip++; + *usp++ = (unsigned short)*ip++; } break; case NC_INT: /* src is int */ @@ -947,7 +947,7 @@ nc4_convert_type(const void *src, void *dest, const nc_type src_type, { if (*ip > X_UINT_MAX || *ip < 0) (*range_error)++; - *uip++ = *ip++; + *uip++ = (unsigned int)*ip++; } break; case NC_INT64: @@ -959,16 +959,16 @@ nc4_convert_type(const void *src, void *dest, const nc_type src_type, { if (*ip < 0) (*range_error)++; - *ulip++ = *ip++; + *ulip++ = (unsigned long long)*ip++; } break; case NC_FLOAT: for (ip = (int *)src, fp = dest; count < len; count++) - *fp++ = *ip++; + *fp++ = (float)*ip++; break; case NC_DOUBLE: for (ip = (int *)src, dp = dest; count < len; count++) - *dp++ = *ip++; + *dp++ = (double)*ip++; break; default: LOG((0, "%s: unexpected dest type. src_type %d, dest_type %d", @@ -985,7 +985,7 @@ nc4_convert_type(const void *src, void *dest, const nc_type src_type, { if (*uip > X_UCHAR_MAX) (*range_error)++; - *ubp++ = *uip++; + *ubp++ = (unsigned char)*uip++; } break; case NC_BYTE: @@ -993,7 +993,7 @@ nc4_convert_type(const void *src, void *dest, const nc_type src_type, { if (*uip > X_SCHAR_MAX) (*range_error)++; - *bp++ = *uip++; + *bp++ = (signed char)*uip++; } break; case NC_SHORT: @@ -1001,7 +1001,7 @@ nc4_convert_type(const void *src, void *dest, const nc_type src_type, { if (*uip > X_SHORT_MAX) (*range_error)++; - *sp++ = *uip++; + *sp++ = (signed short)*uip++; } break; case NC_USHORT: @@ -1009,7 +1009,7 @@ nc4_convert_type(const void *src, void *dest, const nc_type src_type, { if (*uip > X_USHORT_MAX) (*range_error)++; - *usp++ = *uip++; + *usp++ = (unsigned short)*uip++; } break; case NC_INT: @@ -1017,7 +1017,7 @@ nc4_convert_type(const void *src, void *dest, const nc_type src_type, { if (*uip > X_INT_MAX) (*range_error)++; - *ip++ = *uip++; + *ip++ = (int)*uip++; } break; case NC_UINT: @@ -1038,7 +1038,7 @@ nc4_convert_type(const void *src, void *dest, const nc_type src_type, break; case NC_FLOAT: for (uip = (unsigned int *)src, fp = dest; count < len; count++) - *fp++ = *uip++; + *fp++ = (float)*uip++; break; case NC_DOUBLE: for (uip = (unsigned int *)src, dp = dest; count < len; count++) @@ -1059,7 +1059,7 @@ nc4_convert_type(const void *src, void *dest, const nc_type src_type, { if (*lip > X_UCHAR_MAX || *lip < 0) (*range_error)++; - *ubp++ = *lip++; + *ubp++ = (unsigned char)*lip++; } break; case NC_BYTE: @@ -1067,7 +1067,7 @@ nc4_convert_type(const void *src, void *dest, const nc_type src_type, { if (*lip > X_SCHAR_MAX || *lip < X_SCHAR_MIN) (*range_error)++; - *bp++ = *lip++; + *bp++ = (signed char)*lip++; } break; case NC_SHORT: @@ -1075,7 +1075,7 @@ nc4_convert_type(const void *src, void *dest, const nc_type src_type, { if (*lip > X_SHORT_MAX || *lip < X_SHORT_MIN) (*range_error)++; - *sp++ = *lip++; + *sp++ = (short)*lip++; } break; case NC_USHORT: @@ -1083,7 +1083,7 @@ nc4_convert_type(const void *src, void *dest, const nc_type src_type, { if (*lip > X_USHORT_MAX || *lip < 0) (*range_error)++; - *usp++ = *lip++; + *usp++ = (unsigned short)*lip++; } break; case NC_UINT: @@ -1091,7 +1091,7 @@ nc4_convert_type(const void *src, void *dest, const nc_type src_type, { if (*lip > X_UINT_MAX || *lip < 0) (*range_error)++; - *uip++ = *lip++; + *uip++ = (unsigned int)*lip++; } break; case NC_INT: @@ -1099,7 +1099,7 @@ nc4_convert_type(const void *src, void *dest, const nc_type src_type, { if (*lip > X_INT_MAX || *lip < X_INT_MIN) (*range_error)++; - *ip++ = *lip++; + *ip++ = (int)*lip++; } break; case NC_INT64: @@ -1111,16 +1111,16 @@ nc4_convert_type(const void *src, void *dest, const nc_type src_type, { if (*lip < 0) (*range_error)++; - *ulip++ = *lip++; + *ulip++ = (unsigned long long)*lip++; } break; case NC_FLOAT: for (lip = (long long *)src, fp = dest; count < len; count++) - *fp++ = *lip++; + *fp++ = (float)*lip++; break; case NC_DOUBLE: for (lip = (long long *)src, dp = dest; count < len; count++) - *dp++ = *lip++; + *dp++ = (double)*lip++; break; default: LOG((0, "%s: unexpected dest type. src_type %d, dest_type %d", @@ -1137,7 +1137,7 @@ nc4_convert_type(const void *src, void *dest, const nc_type src_type, { if (*ulip > X_UCHAR_MAX) (*range_error)++; - *ubp++ = *ulip++; + *ubp++ = (unsigned char)*ulip++; } break; case NC_BYTE: @@ -1145,7 +1145,7 @@ nc4_convert_type(const void *src, void *dest, const nc_type src_type, { if (*ulip > X_SCHAR_MAX) (*range_error)++; - *bp++ = *ulip++; + *bp++ = (signed char)*ulip++; } break; case NC_SHORT: @@ -1153,7 +1153,7 @@ nc4_convert_type(const void *src, void *dest, const nc_type src_type, { if (*ulip > X_SHORT_MAX) (*range_error)++; - *sp++ = *ulip++; + *sp++ = (short)*ulip++; } break; case NC_USHORT: @@ -1161,7 +1161,7 @@ nc4_convert_type(const void *src, void *dest, const nc_type src_type, { if (*ulip > X_USHORT_MAX) (*range_error)++; - *usp++ = *ulip++; + *usp++ = (unsigned short)*ulip++; } break; case NC_UINT: @@ -1169,7 +1169,7 @@ nc4_convert_type(const void *src, void *dest, const nc_type src_type, { if (*ulip > X_UINT_MAX) (*range_error)++; - *uip++ = *ulip++; + *uip++ = (unsigned int)*ulip++; } break; case NC_INT: @@ -1177,7 +1177,7 @@ nc4_convert_type(const void *src, void *dest, const nc_type src_type, { if (*ulip > X_INT_MAX) (*range_error)++; - *ip++ = *ulip++; + *ip++ = (int)*ulip++; } break; case NC_INT64: @@ -1185,7 +1185,7 @@ nc4_convert_type(const void *src, void *dest, const nc_type src_type, { if (*ulip > X_INT64_MAX) (*range_error)++; - *lip++ = *ulip++; + *lip++ = (long long)*ulip++; } break; case NC_UINT64: @@ -1194,11 +1194,11 @@ nc4_convert_type(const void *src, void *dest, const nc_type src_type, break; case NC_FLOAT: for (ulip = (unsigned long long *)src, fp = dest; count < len; count++) - *fp++ = *ulip++; + *fp++ = (float)*ulip++; break; case NC_DOUBLE: for (ulip = (unsigned long long *)src, dp = dest; count < len; count++) - *dp++ = *ulip++; + *dp++ = (double)*ulip++; break; default: LOG((0, "%s: unexpected dest type. src_type %d, dest_type %d", @@ -1215,7 +1215,7 @@ nc4_convert_type(const void *src, void *dest, const nc_type src_type, { if (*fp > X_UCHAR_MAX || *fp < 0) (*range_error)++; - *ubp++ = *fp++; + *ubp++ = (unsigned char)*fp++; } break; case NC_BYTE: @@ -1223,7 +1223,7 @@ nc4_convert_type(const void *src, void *dest, const nc_type src_type, { if (*fp > (double)X_SCHAR_MAX || *fp < (double)X_SCHAR_MIN) (*range_error)++; - *bp++ = *fp++; + *bp++ = (signed char)*fp++; } break; case NC_SHORT: @@ -1231,7 +1231,7 @@ nc4_convert_type(const void *src, void *dest, const nc_type src_type, { if (*fp > (double)X_SHORT_MAX || *fp < (double)X_SHORT_MIN) (*range_error)++; - *sp++ = *fp++; + *sp++ = (short)*fp++; } break; case NC_USHORT: @@ -1239,15 +1239,15 @@ nc4_convert_type(const void *src, void *dest, const nc_type src_type, { if (*fp > X_USHORT_MAX || *fp < 0) (*range_error)++; - *usp++ = *fp++; + *usp++ = (unsigned short)*fp++; } break; case NC_UINT: for (fp = (float *)src, uip = dest; count < len; count++) { - if (*fp > X_UINT_MAX || *fp < 0) + if (*fp > (float)X_UINT_MAX || *fp < 0) (*range_error)++; - *uip++ = *fp++; + *uip++ = (unsigned int)*fp++; } break; case NC_INT: @@ -1255,23 +1255,23 @@ nc4_convert_type(const void *src, void *dest, const nc_type src_type, { if (*fp > (double)X_INT_MAX || *fp < (double)X_INT_MIN) (*range_error)++; - *ip++ = *fp++; + *ip++ = (int)*fp++; } break; case NC_INT64: for (fp = (float *)src, lip = dest; count < len; count++) { - if (*fp > X_INT64_MAX || *fp (float)X_INT64_MAX || *fp X_UINT64_MAX || *fp < 0) + if (*fp > (float)X_UINT64_MAX || *fp < 0) (*range_error)++; - *lip++ = *fp++; + *ulip++ = (unsigned long long)*fp++; } break; case NC_FLOAT: @@ -1297,7 +1297,7 @@ nc4_convert_type(const void *src, void *dest, const nc_type src_type, { if (*dp > X_UCHAR_MAX || *dp < 0) (*range_error)++; - *ubp++ = *dp++; + *ubp++ = (unsigned char)*dp++; } break; case NC_BYTE: @@ -1305,7 +1305,7 @@ nc4_convert_type(const void *src, void *dest, const nc_type src_type, { if (*dp > X_SCHAR_MAX || *dp < X_SCHAR_MIN) (*range_error)++; - *bp++ = *dp++; + *bp++ = (signed char)*dp++; } break; case NC_SHORT: @@ -1313,7 +1313,7 @@ nc4_convert_type(const void *src, void *dest, const nc_type src_type, { if (*dp > X_SHORT_MAX || *dp < X_SHORT_MIN) (*range_error)++; - *sp++ = *dp++; + *sp++ = (short)*dp++; } break; case NC_USHORT: @@ -1321,7 +1321,7 @@ nc4_convert_type(const void *src, void *dest, const nc_type src_type, { if (*dp > X_USHORT_MAX || *dp < 0) (*range_error)++; - *usp++ = *dp++; + *usp++ = (unsigned short)*dp++; } break; case NC_UINT: @@ -1329,7 +1329,7 @@ nc4_convert_type(const void *src, void *dest, const nc_type src_type, { if (*dp > X_UINT_MAX || *dp < 0) (*range_error)++; - *uip++ = *dp++; + *uip++ = (unsigned int)*dp++; } break; case NC_INT: @@ -1337,23 +1337,23 @@ nc4_convert_type(const void *src, void *dest, const nc_type src_type, { if (*dp > X_INT_MAX || *dp < X_INT_MIN) (*range_error)++; - *ip++ = *dp++; + *ip++ = (int)*dp++; } break; case NC_INT64: for (dp = (double *)src, lip = dest; count < len; count++) { - if (*dp > X_INT64_MAX || *dp < X_INT64_MIN) + if (*dp > (double)X_INT64_MAX || *dp < X_INT64_MIN) (*range_error)++; - *lip++ = *dp++; + *lip++ = (long long)*dp++; } break; case NC_UINT64: - for (dp = (double *)src, lip = dest; count < len; count++) + for (dp = (double *)src, ulip = dest; count < len; count++) { - if (*dp > X_UINT64_MAX || *dp < 0) + if (*dp > (double)X_UINT64_MAX || *dp < 0) (*range_error)++; - *lip++ = *dp++; + *ulip++ = (unsigned long long)*dp++; } break; case NC_FLOAT: @@ -1361,7 +1361,7 @@ nc4_convert_type(const void *src, void *dest, const nc_type src_type, { if (isgreater(*dp, X_FLOAT_MAX) || isless(*dp, X_FLOAT_MIN)) (*range_error)++; - *fp++ = *dp++; + *fp++ = (float)*dp++; } break; case NC_DOUBLE: