summaryrefslogtreecommitdiff
path: root/pp_pack.c
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2013-05-07 10:08:53 +0200
committerNicholas Clark <nick@ccl4.org>2013-05-20 21:19:43 +0200
commite396d2357dcec18c01b1cc78d9edc80a3aa4066d (patch)
tree786b536af0941250070ec67dc7a8df18d5c64294 /pp_pack.c
parent2b4ad5699f46c7f63185ad4e7d1f61e16aaa73f6 (diff)
downloadperl-e396d2357dcec18c01b1cc78d9edc80a3aa4066d.tar.gz
Refactor the two uses of SHIFT{16,32} not followed by DO_BO_UNPACK().
There is one place where SHIFT16() is not immediately followed by DO_BO_UNPACK() ('n!' and 'v!'), and one place where SHIFT32() is not immediately followed by DO_BO_UNPACK() ('N!' and 'V!'). Every other use of either macro is followed by DO_BO_UNPACK(). For the two locations that don't have DO_BO_UNPACK(), the modifiers '<' and '>' are illegal, hence DO_BO_UNPACK() will always be a no-op. Hence add DO_BO_UNPACK() to both (which permits refactoring to simplify things), and add assert()s that the assumptions are true.
Diffstat (limited to 'pp_pack.c')
-rw-r--r--pp_pack.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/pp_pack.c b/pp_pack.c
index fbda44ccdd..4062832faa 100644
--- a/pp_pack.c
+++ b/pp_pack.c
@@ -1417,6 +1417,9 @@ S_unpack_rec(pTHX_ tempsym_t* symptr, const char *s, const char *strbeg, const c
ai16 = 0;
# endif
SHIFT16(utf8, s, strend, &ai16, datumtype);
+ DO_BO_UNPACK(ai16);
+ /* There should never be any byte-swapping here. */
+ assert(!TYPE_ENDIANNESS(datumtype));
if (datumtype == ('n' | TYPE_IS_SHRIEKING))
ai16 = (I16) PerlSock_ntohs((U16) ai16);
if (datumtype == ('v' | TYPE_IS_SHRIEKING))
@@ -1566,6 +1569,9 @@ S_unpack_rec(pTHX_ tempsym_t* symptr, const char *s, const char *strbeg, const c
ai32 = 0;
#endif
SHIFT32(utf8, s, strend, &ai32, datumtype);
+ DO_BO_UNPACK(ai32);
+ /* There should never be any byte swapping here. */
+ assert(!TYPE_ENDIANNESS(datumtype));
if (datumtype == ('N' | TYPE_IS_SHRIEKING))
ai32 = (I32)PerlSock_ntohl((U32)ai32);
if (datumtype == ('V' | TYPE_IS_SHRIEKING))