diff options
author | Charles Harris <charlesr.harris@gmail.com> | 2021-09-25 10:05:21 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-25 10:05:21 -0600 |
commit | 05fcb6544f72ea173011a77cee14d72979ffe293 (patch) | |
tree | 99261e196c8b6a23deb03c62715ad286acf6de4a | |
parent | 7b22284af25279a9332947d024066c0cb43ef25a (diff) | |
parent | cfadd9f5ee5c1a3740a094648d73ad07a893aefc (diff) | |
download | numpy-05fcb6544f72ea173011a77cee14d72979ffe293.tar.gz |
Merge pull request #19951 from DimitriPapadopoulos/lgtm_warning_sizeof_Dragon4_Scratch_repr
MAINT: Fix LGTM.com warning: Comparison is always false because `bufferSize` >= 16384
-rw-r--r-- | numpy/core/src/multiarray/dragon4.c | 65 |
1 files changed, 6 insertions, 59 deletions
diff --git a/numpy/core/src/multiarray/dragon4.c b/numpy/core/src/multiarray/dragon4.c index 1d8c27570..ce0293615 100644 --- a/numpy/core/src/multiarray/dragon4.c +++ b/numpy/core/src/multiarray/dragon4.c @@ -2206,7 +2206,7 @@ Dragon4_PrintFloat_IEEE_binary16( Dragon4_Scratch *scratch, npy_half *value, Dragon4_Options *opt) { char *buffer = scratch->repr; - npy_uint32 bufferSize = sizeof(scratch->repr); + const npy_uint32 bufferSize = sizeof(scratch->repr); BigInt *bigints = scratch->bigints; npy_uint16 val = *value; @@ -2218,15 +2218,6 @@ Dragon4_PrintFloat_IEEE_binary16( npy_bool hasUnequalMargins; char signbit = '\0'; - if (bufferSize == 0) { - return 0; - } - - if (bufferSize == 1) { - buffer[0] = '\0'; - return 0; - } - /* deconstruct the floating point value */ floatMantissa = val & bitmask_u32(10); floatExponent = (val >> 10) & bitmask_u32(5); @@ -2303,7 +2294,7 @@ Dragon4_PrintFloat_IEEE_binary32( Dragon4_Options *opt) { char *buffer = scratch->repr; - npy_uint32 bufferSize = sizeof(scratch->repr); + const npy_uint32 bufferSize = sizeof(scratch->repr); BigInt *bigints = scratch->bigints; union @@ -2319,15 +2310,6 @@ Dragon4_PrintFloat_IEEE_binary32( npy_bool hasUnequalMargins; char signbit = '\0'; - if (bufferSize == 0) { - return 0; - } - - if (bufferSize == 1) { - buffer[0] = '\0'; - return 0; - } - /* deconstruct the floating point value */ floatUnion.floatingPoint = *value; floatMantissa = floatUnion.integer & bitmask_u32(23); @@ -2404,7 +2386,7 @@ Dragon4_PrintFloat_IEEE_binary64( Dragon4_Scratch *scratch, npy_float64 *value, Dragon4_Options *opt) { char *buffer = scratch->repr; - npy_uint32 bufferSize = sizeof(scratch->repr); + const npy_uint32 bufferSize = sizeof(scratch->repr); BigInt *bigints = scratch->bigints; union @@ -2421,14 +2403,6 @@ Dragon4_PrintFloat_IEEE_binary64( npy_bool hasUnequalMargins; char signbit = '\0'; - if (bufferSize == 0) { - return 0; - } - - if (bufferSize == 1) { - buffer[0] = '\0'; - return 0; - } /* deconstruct the floating point value */ floatUnion.floatingPoint = *value; @@ -2527,7 +2501,7 @@ Dragon4_PrintFloat_Intel_extended( Dragon4_Scratch *scratch, FloatVal128 value, Dragon4_Options *opt) { char *buffer = scratch->repr; - npy_uint32 bufferSize = sizeof(scratch->repr); + const npy_uint32 bufferSize = sizeof(scratch->repr); BigInt *bigints = scratch->bigints; npy_uint32 floatExponent, floatSign; @@ -2539,15 +2513,6 @@ Dragon4_PrintFloat_Intel_extended( npy_bool hasUnequalMargins; char signbit = '\0'; - if (bufferSize == 0) { - return 0; - } - - if (bufferSize == 1) { - buffer[0] = '\0'; - return 0; - } - /* deconstruct the floating point value (we ignore the intbit) */ floatMantissa = value.lo & bitmask_u64(63); floatExponent = value.hi & bitmask_u32(15); @@ -2748,7 +2713,7 @@ Dragon4_PrintFloat_IEEE_binary128( Dragon4_Scratch *scratch, FloatVal128 val128, Dragon4_Options *opt) { char *buffer = scratch->repr; - npy_uint32 bufferSize = sizeof(scratch->repr); + const npy_uint32 bufferSize = sizeof(scratch->repr); BigInt *bigints = scratch->bigints; npy_uint32 floatExponent, floatSign; @@ -2759,15 +2724,6 @@ Dragon4_PrintFloat_IEEE_binary128( npy_bool hasUnequalMargins; char signbit = '\0'; - if (bufferSize == 0) { - return 0; - } - - if (bufferSize == 1) { - buffer[0] = '\0'; - return 0; - } - mantissa_hi = val128.hi & bitmask_u64(48); mantissa_lo = val128.lo; floatExponent = (val128.hi >> 48) & bitmask_u32(15); @@ -2917,7 +2873,7 @@ Dragon4_PrintFloat_IBM_double_double( Dragon4_Scratch *scratch, npy_float128 *value, Dragon4_Options *opt) { char *buffer = scratch->repr; - npy_uint32 bufferSize = sizeof(scratch->repr); + const npy_uint32 bufferSize = sizeof(scratch->repr); BigInt *bigints = scratch->bigints; FloatVal128 val128; @@ -2934,15 +2890,6 @@ Dragon4_PrintFloat_IBM_double_double( npy_bool hasUnequalMargins; char signbit = '\0'; - if (bufferSize == 0) { - return 0; - } - - if (bufferSize == 1) { - buffer[0] = '\0'; - return 0; - } - /* The high part always comes before the low part, regardless of the * endianness of the system. */ buf128.floatingPoint = *value; |