From: Chip Salzenberg Date: Sat, 21 Jul 2012 05:11:23 +0000 (-0700) Subject: make SvOOK_offset macro safer, with parens and underscores X-Git-Tag: upstream/5.20.0~6041 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d845901fab02ff3b498515ad6e2d06c711724d24;p=platform%2Fupstream%2Fperl.git make SvOOK_offset macro safer, with parens and underscores --- diff --git a/sv.h b/sv.h index c841c3e..882ba92 100644 --- a/sv.h +++ b/sv.h @@ -2074,23 +2074,23 @@ Evaluates I more than once. Sets I to 0 if C is false. # define SvOOK_offset(sv, offset) STMT_START { \ assert(sizeof(offset) == sizeof(STRLEN)); \ if (SvOOK(sv)) { \ - const U8 *crash = (U8*)SvPVX_const(sv); \ - offset = *--crash; \ - if (!offset) { \ - crash -= sizeof(STRLEN); \ - Copy(crash, (U8 *)&offset, sizeof(STRLEN), U8); \ + const U8 *_crash = (U8*)SvPVX_const(sv); \ + (offset) = *--_crash; \ + if (!(offset)) { \ + _crash -= sizeof(STRLEN); \ + Copy(_crash, (U8 *)&(offset), sizeof(STRLEN), U8); \ } \ { \ /* Validate the preceding buffer's sentinels to \ verify that no-one is using it. */ \ - const U8 *const bonk = (U8 *) SvPVX_const(sv) - offset; \ - while (crash > bonk) { \ - --crash; \ - assert (*crash == (U8)PTR2UV(crash)); \ + const U8 *const _bonk = (U8*)SvPVX_const(sv) - (offset);\ + while (_crash > _bonk) { \ + --_crash; \ + assert (*_crash == (U8)PTR2UV(_crash)); \ } \ } \ } else { \ - offset = 0; \ + (offset) = 0; \ } \ } STMT_END #else @@ -2098,13 +2098,13 @@ Evaluates I more than once. Sets I to 0 if C is false. # define SvOOK_offset(sv, offset) STMT_START { \ assert(sizeof(offset) == sizeof(STRLEN)); \ if (SvOOK(sv)) { \ - offset = ((U8*)SvPVX_const(sv))[-1]; \ - if (!offset) { \ + (offset) = ((U8*)SvPVX_const(sv))[-1]; \ + if (!(offset)) { \ Copy(SvPVX_const(sv) - 1 - sizeof(STRLEN), \ - (U8 *)&offset, sizeof(STRLEN), U8); \ + (U8*)&(offset), sizeof(STRLEN), U8); \ } \ } else { \ - offset = 0; \ + (offset) = 0; \ } \ } STMT_END #endif