Skip to content

Commit 15b8ca2

Browse files
avalentinoFrancescAlted
authored andcommitted
Fix compatibility with glibc v2.42
Before checking a possible error of the strtol() function the 'errno' have to be reset to zero. Apparently there are situations in which 'errno' can be legally set to a non-zaro value and this interferes with the error checking of strtol(). Without the patch, the unit test suite stalls when it is executed in an environment with glibc v2.42 and linux kernel < v6.13. Patch kindly provided by Aurelien Jarno. Original bub report: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1115531.
1 parent ae52f60 commit 15b8ca2

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

blosc/blosc2.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2725,6 +2725,7 @@ int blosc2_compress(int clevel, int doshuffle, int32_t typesize,
27252725
envvar = getenv("BLOSC_CLEVEL");
27262726
if (envvar != NULL) {
27272727
long value;
2728+
errno = 0; /* To distinguish success/failure after call */
27282729
value = strtol(envvar, NULL, 10);
27292730
if ((errno != EINVAL) && (value >= 0)) {
27302731
clevel = (int)value;
@@ -2768,6 +2769,7 @@ int blosc2_compress(int clevel, int doshuffle, int32_t typesize,
27682769
envvar = getenv("BLOSC_TYPESIZE");
27692770
if (envvar != NULL) {
27702771
long value;
2772+
errno = 0; /* To distinguish success/failure after call */
27712773
value = strtol(envvar, NULL, 10);
27722774
if ((errno != EINVAL) && (value > 0)) {
27732775
typesize = (int32_t)value;
@@ -2790,6 +2792,7 @@ int blosc2_compress(int clevel, int doshuffle, int32_t typesize,
27902792
envvar = getenv("BLOSC_BLOCKSIZE");
27912793
if (envvar != NULL) {
27922794
long blocksize;
2795+
errno = 0; /* To distinguish success/failure after call */
27932796
blocksize = strtol(envvar, NULL, 10);
27942797
if ((errno != EINVAL) && (blocksize > 0)) {
27952798
blosc1_set_blocksize((size_t) blocksize);
@@ -2803,6 +2806,7 @@ int blosc2_compress(int clevel, int doshuffle, int32_t typesize,
28032806
envvar = getenv("BLOSC_NTHREADS");
28042807
if (envvar != NULL) {
28052808
long nthreads;
2809+
errno = 0; /* To distinguish success/failure after call */
28062810
nthreads = strtol(envvar, NULL, 10);
28072811
if ((errno != EINVAL) && (nthreads > 0)) {
28082812
result = blosc2_set_nthreads((int16_t) nthreads);
@@ -2986,6 +2990,7 @@ int blosc2_decompress(const void* src, int32_t srcsize, void* dest, int32_t dest
29862990
/* Check for a BLOSC_NTHREADS environment variable */
29872991
envvar = getenv("BLOSC_NTHREADS");
29882992
if (envvar != NULL) {
2993+
errno = 0; /* To distinguish success/failure after call */
29892994
nthreads = strtol(envvar, NULL, 10);
29902995
if ((errno != EINVAL)) {
29912996
if ((nthreads <= 0) || (nthreads > INT16_MAX)) {
@@ -4031,6 +4036,7 @@ blosc2_context* blosc2_create_cctx(blosc2_cparams cparams) {
40314036
envvar = getenv("BLOSC_TYPESIZE");
40324037
if (envvar != NULL) {
40334038
int32_t value;
4039+
errno = 0; /* To distinguish success/failure after call */
40344040
value = (int32_t) strtol(envvar, NULL, 10);
40354041
if ((errno != EINVAL) && (value > 0)) {
40364042
context->typesize = value;
@@ -4046,6 +4052,7 @@ blosc2_context* blosc2_create_cctx(blosc2_cparams cparams) {
40464052
envvar = getenv("BLOSC_CLEVEL");
40474053
if (envvar != NULL) {
40484054
int value;
4055+
errno = 0; /* To distinguish success/failure after call */
40494056
value = (int)strtol(envvar, NULL, 10);
40504057
if ((errno != EINVAL) && (value >= 0)) {
40514058
context->clevel = value;
@@ -4073,6 +4080,7 @@ blosc2_context* blosc2_create_cctx(blosc2_cparams cparams) {
40734080
envvar = getenv("BLOSC_BLOCKSIZE");
40744081
if (envvar != NULL) {
40754082
int32_t blocksize;
4083+
errno = 0; /* To distinguish success/failure after call */
40764084
blocksize = (int32_t) strtol(envvar, NULL, 10);
40774085
if ((errno != EINVAL) && (blocksize > 0)) {
40784086
context->blocksize = blocksize;
@@ -4086,6 +4094,7 @@ blosc2_context* blosc2_create_cctx(blosc2_cparams cparams) {
40864094
/* Check for a BLOSC_NTHREADS environment variable */
40874095
envvar = getenv("BLOSC_NTHREADS");
40884096
if (envvar != NULL) {
4097+
errno = 0; /* To distinguish success/failure after call */
40894098
int16_t nthreads = (int16_t) strtol(envvar, NULL, 10);
40904099
if ((errno != EINVAL) && (nthreads > 0)) {
40914100
context->nthreads = nthreads;
@@ -4174,6 +4183,7 @@ blosc2_context* blosc2_create_dctx(blosc2_dparams dparams) {
41744183
context->nthreads = dparams.nthreads;
41754184
char* envvar = getenv("BLOSC_NTHREADS");
41764185
if (envvar != NULL) {
4186+
errno = 0; /* To distinguish success/failure after call */
41774187
long nthreads = strtol(envvar, NULL, 10);
41784188
if ((errno != EINVAL) && (nthreads > 0)) {
41794189
context->nthreads = (int16_t) nthreads;

0 commit comments

Comments
 (0)