This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
In pp_pack.c, refactor DO_BO_(UN)?PACK_N to use sizeof() on the variable.
authorNicholas Clark <nick@ccl4.org>
Mon, 6 May 2013 14:22:01 +0000 (16:22 +0200)
committerNicholas Clark <nick@ccl4.org>
Mon, 20 May 2013 19:19:43 +0000 (21:19 +0200)
Previously they were using sizeof() on the type argument passed to the
macro. This change makes their implementation more like DO_BO_(UN)?PACK
and DO_BO_(UN)?PACK_PTR.

pp_pack.c

index 2690b55..8a59e69 100644 (file)
--- a/pp_pack.c
+++ b/pp_pack.c
@@ -270,14 +270,14 @@ S_mul128(pTHX_ SV *sv, U8 m)
 # define DO_BO_UNPACK_N(var, type)                                            \
          STMT_START {                                                         \
            if (TYPE_ENDIANNESS(datumtype) == TYPE_IS_LITTLE_ENDIAN) {         \
-              my_letohn(&var, sizeof(type));                                  \
+              my_letohn(&var, sizeof(var));                                   \
            }                                                                  \
          } STMT_END
 
 # define DO_BO_PACK_N(var, type)                                              \
          STMT_START {                                                         \
            if (TYPE_ENDIANNESS(datumtype) == TYPE_IS_LITTLE_ENDIAN) {         \
-             my_htolen(&var, sizeof(type));                                   \
+             my_htolen(&var, sizeof(var));                                    \
            }                                                                  \
          } STMT_END
 
@@ -314,14 +314,14 @@ S_mul128(pTHX_ SV *sv, U8 m)
 # define DO_BO_UNPACK_N(var, type)                                            \
          STMT_START {                                                         \
            if (TYPE_ENDIANNESS(datumtype) == TYPE_IS_BIG_ENDIAN) {            \
-              my_betohn(&var, sizeof(type));                                  \
+              my_betohn(&var, sizeof(var));                                   \
            }                                                                  \
          } STMT_END
 
 # define DO_BO_PACK_N(var, type)                                              \
          STMT_START {                                                         \
            if (TYPE_ENDIANNESS(datumtype) == TYPE_IS_BIG_ENDIAN) {            \
-             my_htoben(&var, sizeof(type));                                   \
+             my_htoben(&var, sizeof(var));                                    \
            }                                                                  \
          } STMT_END