This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
util.c - assign HS_GETXSVERLEN() to var before assert
authorYves Orton <demerphq@gmail.com>
Thu, 23 Mar 2023 10:42:56 +0000 (11:42 +0100)
committerYves Orton <demerphq@gmail.com>
Wed, 29 Mar 2023 12:54:49 +0000 (20:54 +0800)
This makes it easier to see the value with gdb, and also avoids an
assignment in the if condition body.

util.c

diff --git a/util.c b/util.c
index 420eaef..cedde45 100644 (file)
--- a/util.c
+++ b/util.c
@@ -5535,9 +5535,9 @@ Perl_xs_handshake(const U32 key, void * v_my_perl, const char * file, ...)
         }
     }
     {
-        U32 xsverlen;
-        assert(HS_GETXSVERLEN(key) <= UCHAR_MAX && HS_GETXSVERLEN(key) <= HS_APIVERLEN_MAX);
-        if((xsverlen = HS_GETXSVERLEN(key)))
+        U32 xsverlen = HS_GETXSVERLEN(key);
+        assert(xsverlen <= UCHAR_MAX && xsverlen <= HS_APIVERLEN_MAX);
+        if(xsverlen)
             S_xs_version_bootcheck(aTHX_
                 items, ax, va_arg(args, char*), xsverlen);
     }