Skip to content

Commit e771dad

Browse files
committed
Fixes for suggestions in reviews
1 parent e9a6514 commit e771dad

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

blosc/b2nd.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1338,7 +1338,7 @@ int b2nd_concatenate(b2nd_context_t *ctx, const b2nd_array_t *src1, const b2nd_a
13381338

13391339
// Validate the axis parameter
13401340
if (axis < 0 || axis >= src1->ndim) {
1341-
BLOSC_TRACE_ERROR("Axis parameter is out of bounds");
1341+
BLOSC_TRACE_ERROR("axis parameter is out of bounds: axis=%d, expected range=[0, %d)", axis, src1->ndim - 1);
13421342
BLOSC_ERROR(BLOSC2_ERROR_INVALID_PARAM);
13431343
}
13441344

@@ -1390,8 +1390,11 @@ int b2nd_concatenate(b2nd_context_t *ctx, const b2nd_array_t *src1, const b2nd_a
13901390
void *buffer = malloc(src2->sc->typesize * src2->extchunknitems);
13911391
BLOSC_ERROR_NULL(buffer, BLOSC2_ERROR_MEMORY_ALLOC);
13921392
for (int64_t nchunk = 0; nchunk < src2->sc->nchunks; ++nchunk) {
1393-
BLOSC_ERROR(blosc2_schunk_decompress_chunk(src2->sc, nchunk, buffer,
1394-
src2->sc->typesize * src2->extchunknitems));
1393+
if (blosc2_schunk_decompress_chunk(src2->sc, nchunk, buffer,
1394+
src2->sc->typesize * (int32_t)src2->extchunknitems) <= 0) {
1395+
BLOSC_TRACE_ERROR("Error decompressing chunk");
1396+
goto cleanup;
1397+
}
13951398
// Get multidimensional chunk position
13961399
int64_t nchunk_ndim[B2ND_MAX_DIM] = {0};
13971400
int64_t chunkshape[B2ND_MAX_DIM] = {0};
@@ -1400,7 +1403,7 @@ int b2nd_concatenate(b2nd_context_t *ctx, const b2nd_array_t *src1, const b2nd_a
14001403
}
14011404
int64_t chunks_in_dim[B2ND_MAX_DIM] = {0};
14021405
for (int8_t i = 0; i < src2->ndim; ++i) {
1403-
chunks_in_dim[i] = (src2->extshape[i] + src2->chunkshape[i] - 1) / src2->chunkshape[i];
1406+
chunks_in_dim[i] = src2->extshape[i] / src2->chunkshape[i];
14041407
}
14051408
blosc2_unidim_to_multidim(src2->ndim, chunks_in_dim, nchunk, nchunk_ndim);
14061409

@@ -1424,6 +1427,8 @@ int b2nd_concatenate(b2nd_context_t *ctx, const b2nd_array_t *src1, const b2nd_a
14241427
src2->sc->typesize * src2->extchunknitems,
14251428
start, stop, *array));
14261429
}
1430+
1431+
cleanup:
14271432
free(buffer);
14281433

14291434
return BLOSC2_ERROR_SUCCESS;

0 commit comments

Comments
 (0)