summaryrefslogtreecommitdiffstats
path: root/src/H5Znbit.c
diff options
context:
space:
mode:
authorjhendersonHDF <jhenderson@hdfgroup.org>2022-02-04 16:53:55 (GMT)
committerGitHub <noreply@github.com>2022-02-04 16:53:55 (GMT)
commit36d9a165e428eb883f9fd72b6707555536292845 (patch)
tree61848a7a985725dcbb52daab3a986ff490cf909c /src/H5Znbit.c
parent856de93673f2bd097b90e2803475ef4fc3d689fa (diff)
downloadhdf5-36d9a165e428eb883f9fd72b6707555536292845.zip
hdf5-36d9a165e428eb883f9fd72b6707555536292845.tar.gz
hdf5-36d9a165e428eb883f9fd72b6707555536292845.tar.bz2
Fix a few issues noted by LGTM (#1421)
Diffstat (limited to 'src/H5Znbit.c')
-rw-r--r--src/H5Znbit.c29
1 files changed, 15 insertions, 14 deletions
diff --git a/src/H5Znbit.c b/src/H5Znbit.c
index 21363bc..905d417 100644
--- a/src/H5Znbit.c
+++ b/src/H5Znbit.c
@@ -975,7 +975,7 @@ H5Z__filter_nbit(unsigned flags, size_t cd_nelmts, const unsigned cd_values[], s
/* input; decompress */
if (flags & H5Z_FLAG_REVERSE) {
- size_out = d_nelmts * cd_values[4]; /* cd_values[4] stores datatype size */
+ size_out = d_nelmts * (size_t)cd_values[4]; /* cd_values[4] stores datatype size */
/* allocate memory space for decompressed buffer */
if (NULL == (outbuf = (unsigned char *)H5MM_malloc(size_out)))
@@ -1170,7 +1170,8 @@ H5Z__nbit_decompress_one_array(unsigned char *data, size_t data_offset, unsigned
n = total_size / p.size;
for (i = 0; i < n; i++)
- H5Z__nbit_decompress_one_atomic(data, data_offset + i * p.size, buffer, j, buf_len, &p);
+ H5Z__nbit_decompress_one_atomic(data, data_offset + i * (size_t)p.size, buffer, j, buf_len,
+ &p);
break;
case H5Z_NBIT_ARRAY:
@@ -1178,8 +1179,8 @@ H5Z__nbit_decompress_one_array(unsigned char *data, size_t data_offset, unsigned
n = total_size / base_size; /* number of base_type elements inside the array datatype */
begin_index = *parms_index;
for (i = 0; i < n; i++) {
- if (H5Z__nbit_decompress_one_array(data, data_offset + i * base_size, buffer, j, buf_len,
- parms, parms_index) < 0)
+ if (H5Z__nbit_decompress_one_array(data, data_offset + i * (size_t)base_size, buffer, j,
+ buf_len, parms, parms_index) < 0)
HGOTO_ERROR(H5E_PLINE, H5E_CANTFILTER, FAIL, "can't decompress array")
*parms_index = begin_index;
}
@@ -1190,8 +1191,8 @@ H5Z__nbit_decompress_one_array(unsigned char *data, size_t data_offset, unsigned
n = total_size / base_size; /* number of base_type elements inside the array datatype */
begin_index = *parms_index;
for (i = 0; i < n; i++) {
- if (H5Z__nbit_decompress_one_compound(data, data_offset + i * base_size, buffer, j, buf_len,
- parms, parms_index) < 0)
+ if (H5Z__nbit_decompress_one_compound(data, data_offset + i * (size_t)base_size, buffer, j,
+ buf_len, parms, parms_index) < 0)
HGOTO_ERROR(H5E_PLINE, H5E_CANTFILTER, FAIL, "can't decompress compound")
*parms_index = begin_index;
}
@@ -1291,7 +1292,7 @@ H5Z__nbit_decompress(unsigned char *data, unsigned d_nelmts, unsigned char *buff
FUNC_ENTER_STATIC
/* may not have to initialize to zeros */
- HDmemset(data, 0, d_nelmts * parms[4]);
+ HDmemset(data, 0, d_nelmts * (size_t)parms[4]);
/* initialization before the loop */
j = 0;
@@ -1309,7 +1310,7 @@ H5Z__nbit_decompress(unsigned char *data, unsigned d_nelmts, unsigned char *buff
HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "invalid datatype precision/offset")
for (i = 0; i < d_nelmts; i++)
- H5Z__nbit_decompress_one_atomic(data, i * p.size, buffer, &j, &buf_len, &p);
+ H5Z__nbit_decompress_one_atomic(data, i * (size_t)p.size, buffer, &j, &buf_len, &p);
break;
case H5Z_NBIT_ARRAY:
@@ -1468,7 +1469,7 @@ H5Z__nbit_compress_one_array(unsigned char *data, size_t data_offset, unsigned c
p.offset = parms[(*parms_index)++];
n = total_size / p.size;
for (i = 0; i < n; i++)
- H5Z__nbit_compress_one_atomic(data, data_offset + i * p.size, buffer, j, buf_len, &p);
+ H5Z__nbit_compress_one_atomic(data, data_offset + i * (size_t)p.size, buffer, j, buf_len, &p);
break;
case H5Z_NBIT_ARRAY:
@@ -1476,8 +1477,8 @@ H5Z__nbit_compress_one_array(unsigned char *data, size_t data_offset, unsigned c
n = total_size / base_size; /* number of base_type elements inside the array datatype */
begin_index = *parms_index;
for (i = 0; i < n; i++) {
- H5Z__nbit_compress_one_array(data, data_offset + i * base_size, buffer, j, buf_len, parms,
- parms_index);
+ H5Z__nbit_compress_one_array(data, data_offset + i * (size_t)base_size, buffer, j, buf_len,
+ parms, parms_index);
*parms_index = begin_index;
}
break;
@@ -1487,8 +1488,8 @@ H5Z__nbit_compress_one_array(unsigned char *data, size_t data_offset, unsigned c
n = total_size / base_size; /* number of base_type elements inside the array datatype */
begin_index = *parms_index;
for (i = 0; i < n; i++) {
- H5Z__nbit_compress_one_compound(data, data_offset + i * base_size, buffer, j, buf_len, parms,
- parms_index);
+ H5Z__nbit_compress_one_compound(data, data_offset + i * (size_t)base_size, buffer, j, buf_len,
+ parms, parms_index);
*parms_index = begin_index;
}
break;
@@ -1574,7 +1575,7 @@ H5Z__nbit_compress(unsigned char *data, unsigned d_nelmts, unsigned char *buffer
p.offset = parms[7];
for (i = 0; i < d_nelmts; i++)
- H5Z__nbit_compress_one_atomic(data, i * p.size, buffer, &new_size, &buf_len, &p);
+ H5Z__nbit_compress_one_atomic(data, i * (size_t)p.size, buffer, &new_size, &buf_len, &p);
break;
case H5Z_NBIT_ARRAY: