This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
[perl #126242] make the constant hash seeds unsigned char *
authorTony Cook <tony@develop-help.com>
Tue, 13 Oct 2015 23:51:21 +0000 (10:51 +1100)
committerTony Cook <tony@develop-help.com>
Tue, 13 Oct 2015 23:51:21 +0000 (10:51 +1100)
...to prevent warnings on most C compilers and build failures on C++
compilers for -DNO_HASH_SEED builds.

hv_func.h
perl.c

index ce60e53..8866db9 100644 (file)
--- a/hv_func.h
+++ b/hv_func.h
 #   if defined(USE_HASH_SEED) || defined(USE_HASH_SEED_EXPLICIT)
 #       define PERL_HASH_SEED PL_hash_seed
 #   elif PERL_HASH_SEED_BYTES == 4
-#       define PERL_HASH_SEED "PeRl"
+#       define PERL_HASH_SEED ((const U8 *)"PeRl")
 #   elif PERL_HASH_SEED_BYTES == 8
-#       define PERL_HASH_SEED "PeRlHaSh"
+#       define PERL_HASH_SEED ((const U8 *)"PeRlHaSh")
 #   elif PERL_HASH_SEED_BYTES == 16
-#       define PERL_HASH_SEED "PeRlHaShhAcKpErl"
+#       define PERL_HASH_SEED ((const U8 *)"PeRlHaShhAcKpErl")
 #   else
 #       error "No PERL_HASH_SEED definition for " PERL_HASH_FUNC
 #   endif
diff --git a/perl.c b/perl.c
index b16c87e..e3d6545 100644 (file)
--- a/perl.c
+++ b/perl.c
@@ -1485,8 +1485,8 @@ perl_parse(pTHXx_ XSINIT_t xsinit, int argc, char **argv, char **env)
         const char * const s = PerlEnv_getenv("PERL_HASH_SEED_DEBUG");
 
         if (s && strEQ(s, "1")) {
-            unsigned char *seed= PERL_HASH_SEED;
-            unsigned char *seed_end= PERL_HASH_SEED + PERL_HASH_SEED_BYTES;
+            const unsigned char *seed= PERL_HASH_SEED;
+            const unsigned char *seed_end= PERL_HASH_SEED + PERL_HASH_SEED_BYTES;
             PerlIO_printf(Perl_debug_log, "HASH_FUNCTION = %s HASH_SEED = 0x", PERL_HASH_FUNC);
             while (seed < seed_end) {
                 PerlIO_printf(Perl_debug_log, "%02x", *seed++);