summaryrefslogtreecommitdiff
path: root/doop.c
diff options
context:
space:
mode:
authorKarl Williamson <khw@cpan.org>2021-07-30 06:42:18 -0600
committerKarl Williamson <khw@cpan.org>2021-08-06 08:48:16 -0600
commitf77b2d0e2503b5ff6743b62d7cd34ef9887cd6b1 (patch)
tree24a4ddd1139a2fabddc8f313cc378c3f7c7a9260 /doop.c
parent6c4aa50c3d02831e0adee8be4d10577b03de815d (diff)
downloadperl-f77b2d0e2503b5ff6743b62d7cd34ef9887cd6b1.tar.gz
doop.c: do_vecget(): Add trivial case to the switch()
We can save another conditional by adding a default: case to the switch statement created by the previous commit.
Diffstat (limited to 'doop.c')
-rw-r--r--doop.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/doop.c b/doop.c
index e179c0f835..5a9c0d8f46 100644
--- a/doop.c
+++ b/doop.c
@@ -731,7 +731,7 @@ Perl_do_sprintf(pTHX_ SV *sv, SSize_t len, SV **sarg)
UV
Perl_do_vecget(pTHX_ SV *sv, STRLEN offset, int size)
{
- STRLEN srclen, avail, uoffset;
+ STRLEN srclen;
const I32 svpv_flags = ((PL_op->op_flags & OPf_MOD || LVRET)
? SV_UNDEF_RETURNS_NULL : 0);
unsigned char *s = (unsigned char *)
@@ -760,7 +760,7 @@ Perl_do_vecget(pTHX_ SV *sv, STRLEN offset, int size)
if (size <= 8) {
STRLEN bitoffs = ((offset % 8) * size) % 8;
- uoffset = offset / (8 / size);
+ STRLEN uoffset = offset / (8 / size);
if (uoffset >= srclen)
return 0;
@@ -769,6 +769,7 @@ Perl_do_vecget(pTHX_ SV *sv, STRLEN offset, int size)
}
else {
int n = size / 8; /* required number of bytes */
+ SSize_t uoffset;
#ifdef UV_IS_QUAD
@@ -782,12 +783,9 @@ Perl_do_vecget(pTHX_ SV *sv, STRLEN offset, int size)
uoffset = offset * n;
- if (uoffset >= srclen)
- return 0;
-
- avail = srclen - uoffset; /* available number of bytes */
-
- switch (MIN(n, avail)) {
+ /* Switch on the number of bytes available, but no more than the number
+ * required */
+ switch (MIN(n, (SSize_t) srclen - uoffset)) {
#ifdef UV_IS_QUAD
@@ -816,6 +814,9 @@ Perl_do_vecget(pTHX_ SV *sv, STRLEN offset, int size)
case 1:
retnum += ((UV) s[uoffset ] << (size - 8));
break;
+
+ default:
+ return 0;
}
}