diff options
author | Dagfinn Ilmari Mannsåker <ilmari@ilmari.org> | 2020-07-06 16:24:33 +0100 |
---|---|---|
committer | Dagfinn Ilmari Mannsåker <ilmari@ilmari.org> | 2020-07-20 13:58:53 +0100 |
commit | c1d551e18b0505f4fadf5d7cd6b07de35589bd42 (patch) | |
tree | d20843f84286df374ee0a6d0e0b0b905b3b6acc9 | |
parent | 233050fdd35e6b614a1a299227c441350fbcc1e3 (diff) | |
download | perl-c1d551e18b0505f4fadf5d7cd6b07de35589bd42.tar.gz |
Use static asserts when comparing sizeof() to a constant
-rw-r--r-- | regcomp.c | 2 | ||||
-rw-r--r-- | sv.c | 2 | ||||
-rw-r--r-- | sv.h | 4 |
3 files changed, 4 insertions, 4 deletions
@@ -7416,7 +7416,7 @@ S_set_regex_pv(pTHX_ RExC_state_t *pRExC_state, REGEXP *Rx) PERL_ARGS_ASSERT_SET_REGEX_PV; /* make sure PL_bitcount bounds not exceeded */ - assert(sizeof(STD_PAT_MODS) <= 8); + STATIC_ASSERT_STMT(sizeof(STD_PAT_MODS) <= 8); p = sv_grow(MUTABLE_SV(Rx), wraplen + 1); /* +1 for the ending NUL */ SvPOK_on(Rx); @@ -12824,7 +12824,7 @@ Perl_sv_vcatpvfn_flags(pTHX_ SV *const sv, const char *const pat, const STRLEN p (!UVCHR_IS_INVARIANT(uv) && SvUTF8(sv))) && !IN_BYTES) { - assert(sizeof(ebuf) >= UTF8_MAXBYTES + 1); + STATIC_ASSERT_STMT(sizeof(ebuf) >= UTF8_MAXBYTES + 1); eptr = ebuf; elen = uvchr_to_utf8((U8*)eptr, uv) - (U8*)ebuf; is_utf8 = TRUE; @@ -2302,7 +2302,7 @@ Evaluates C<sv> more than once. Sets C<len> to 0 if C<SvOOK(sv)> is false. 10:28 <+meta> Nicholas: crash */ # define SvOOK_offset(sv, offset) STMT_START { \ - assert(sizeof(offset) == sizeof(STRLEN)); \ + STATIC_ASSERT_STMT(sizeof(offset) == sizeof(STRLEN)); \ if (SvOOK(sv)) { \ const U8 *_crash = (U8*)SvPVX_const(sv); \ (offset) = *--_crash; \ @@ -2326,7 +2326,7 @@ Evaluates C<sv> more than once. Sets C<len> to 0 if C<SvOOK(sv)> is false. #else /* This is the same code, but avoids using any temporary variables: */ # define SvOOK_offset(sv, offset) STMT_START { \ - assert(sizeof(offset) == sizeof(STRLEN)); \ + STATIC_ASSERT_STMT(sizeof(offset) == sizeof(STRLEN)); \ if (SvOOK(sv)) { \ (offset) = ((U8*)SvPVX_const(sv))[-1]; \ if (!(offset)) { \ |