Fix const correctness in hv_func.h
This commit is contained in:
parent
8fcd2745c8
commit
bfea7ab5df
|
@ -0,0 +1,124 @@
|
||||||
|
From 463ddf34c08f2c97199b1bb242da1f17494d4d1a Mon Sep 17 00:00:00 2001
|
||||||
|
From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= <ppisar@redhat.com>
|
||||||
|
Date: Thu, 24 Nov 2016 16:34:09 +0100
|
||||||
|
Subject: [PATCH] Fix const correctness in hv_func.h
|
||||||
|
MIME-Version: 1.0
|
||||||
|
Content-Type: text/plain; charset=UTF-8
|
||||||
|
Content-Transfer-Encoding: 8bit
|
||||||
|
|
||||||
|
Building an XS code with -Wcast-qual yielded warnings about discarding
|
||||||
|
const qualifiers from pointer targets like:
|
||||||
|
|
||||||
|
$ printf '#include "EXTERN.h"\n#include "perl.h"\n' | gcc -Wcast-qual -I/usr/lib64/perl5/CORE -c -x c -
|
||||||
|
In file included from /usr/lib64/perl5/CORE/hv.h:629:0,
|
||||||
|
from /usr/lib64/perl5/CORE/perl.h:3740,
|
||||||
|
from <stdin>:2:
|
||||||
|
/usr/lib64/perl5/CORE/hv_func.h: In function ‘S_perl_hash_siphash_2_4’:
|
||||||
|
/usr/lib64/perl5/CORE/hv_func.h:213:17: warning: cast discards ‘const’ qualifier from pointer target type [-Wcast-qual]
|
||||||
|
U64TYPE k0 = ((U64TYPE*)seed)[0];
|
||||||
|
^
|
||||||
|
|
||||||
|
Signed-off-by: Petr Písař <ppisar@redhat.com>
|
||||||
|
---
|
||||||
|
hv_func.h | 22 +++++++++++-----------
|
||||||
|
1 file changed, 11 insertions(+), 11 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/hv_func.h b/hv_func.h
|
||||||
|
index 8866db9..57b1ed1 100644
|
||||||
|
--- a/hv_func.h
|
||||||
|
+++ b/hv_func.h
|
||||||
|
@@ -118,7 +118,7 @@
|
||||||
|
|
||||||
|
#if (BYTEORDER == 0x1234 || BYTEORDER == 0x12345678) && U32SIZE == 4
|
||||||
|
/* CPU endian matches murmurhash algorithm, so read 32-bit word directly */
|
||||||
|
- #define U8TO32_LE(ptr) (*((U32*)(ptr)))
|
||||||
|
+ #define U8TO32_LE(ptr) (*((const U32*)(ptr)))
|
||||||
|
#elif BYTEORDER == 0x4321 || BYTEORDER == 0x87654321
|
||||||
|
/* TODO: Add additional cases below where a compiler provided bswap32 is available */
|
||||||
|
#if defined(__GNUC__) && (__GNUC__>4 || (__GNUC__==4 && __GNUC_MINOR__>=3))
|
||||||
|
@@ -210,8 +210,8 @@ S_perl_hash_siphash_2_4(const unsigned char * const seed, const unsigned char *i
|
||||||
|
U64 v3 = UINT64_C(0x7465646279746573);
|
||||||
|
|
||||||
|
U64 b;
|
||||||
|
- U64 k0 = ((U64*)seed)[0];
|
||||||
|
- U64 k1 = ((U64*)seed)[1];
|
||||||
|
+ U64 k0 = ((const U64*)seed)[0];
|
||||||
|
+ U64 k1 = ((const U64*)seed)[1];
|
||||||
|
U64 m;
|
||||||
|
const int left = inlen & 7;
|
||||||
|
const U8 *end = in + inlen - left;
|
||||||
|
@@ -269,7 +269,7 @@ S_perl_hash_siphash_2_4(const unsigned char * const seed, const unsigned char *i
|
||||||
|
|
||||||
|
PERL_STATIC_INLINE U32
|
||||||
|
S_perl_hash_superfast(const unsigned char * const seed, const unsigned char *str, STRLEN len) {
|
||||||
|
- U32 hash = *((U32*)seed) + (U32)len;
|
||||||
|
+ U32 hash = *((const U32*)seed) + (U32)len;
|
||||||
|
U32 tmp;
|
||||||
|
int rem= len & 3;
|
||||||
|
len >>= 2;
|
||||||
|
@@ -373,7 +373,7 @@ S_perl_hash_superfast(const unsigned char * const seed, const unsigned char *str
|
||||||
|
/* now we create the hash function */
|
||||||
|
PERL_STATIC_INLINE U32
|
||||||
|
S_perl_hash_murmur3(const unsigned char * const seed, const unsigned char *ptr, STRLEN len) {
|
||||||
|
- U32 h1 = *((U32*)seed);
|
||||||
|
+ U32 h1 = *((const U32*)seed);
|
||||||
|
U32 k1;
|
||||||
|
U32 carry = 0;
|
||||||
|
|
||||||
|
@@ -467,7 +467,7 @@ S_perl_hash_murmur3(const unsigned char * const seed, const unsigned char *ptr,
|
||||||
|
PERL_STATIC_INLINE U32
|
||||||
|
S_perl_hash_djb2(const unsigned char * const seed, const unsigned char *str, const STRLEN len) {
|
||||||
|
const unsigned char * const end = (const unsigned char *)str + len;
|
||||||
|
- U32 hash = *((U32*)seed) + (U32)len;
|
||||||
|
+ U32 hash = *((const U32*)seed) + (U32)len;
|
||||||
|
while (str < end) {
|
||||||
|
hash = ((hash << 5) + hash) + *str++;
|
||||||
|
}
|
||||||
|
@@ -477,7 +477,7 @@ S_perl_hash_djb2(const unsigned char * const seed, const unsigned char *str, con
|
||||||
|
PERL_STATIC_INLINE U32
|
||||||
|
S_perl_hash_sdbm(const unsigned char * const seed, const unsigned char *str, const STRLEN len) {
|
||||||
|
const unsigned char * const end = (const unsigned char *)str + len;
|
||||||
|
- U32 hash = *((U32*)seed) + (U32)len;
|
||||||
|
+ U32 hash = *((const U32*)seed) + (U32)len;
|
||||||
|
while (str < end) {
|
||||||
|
hash = (hash << 6) + (hash << 16) - hash + *str++;
|
||||||
|
}
|
||||||
|
@@ -503,7 +503,7 @@ S_perl_hash_sdbm(const unsigned char * const seed, const unsigned char *str, con
|
||||||
|
PERL_STATIC_INLINE U32
|
||||||
|
S_perl_hash_one_at_a_time(const unsigned char * const seed, const unsigned char *str, const STRLEN len) {
|
||||||
|
const unsigned char * const end = (const unsigned char *)str + len;
|
||||||
|
- U32 hash = *((U32*)seed) + (U32)len;
|
||||||
|
+ U32 hash = *((const U32*)seed) + (U32)len;
|
||||||
|
while (str < end) {
|
||||||
|
hash += *str++;
|
||||||
|
hash += (hash << 10);
|
||||||
|
@@ -518,7 +518,7 @@ S_perl_hash_one_at_a_time(const unsigned char * const seed, const unsigned char
|
||||||
|
PERL_STATIC_INLINE U32
|
||||||
|
S_perl_hash_one_at_a_time_hard(const unsigned char * const seed, const unsigned char *str, const STRLEN len) {
|
||||||
|
const unsigned char * const end = (const unsigned char *)str + len;
|
||||||
|
- U32 hash = *((U32*)seed) + (U32)len;
|
||||||
|
+ U32 hash = *((const U32*)seed) + (U32)len;
|
||||||
|
|
||||||
|
while (str < end) {
|
||||||
|
hash += (hash << 10);
|
||||||
|
@@ -553,7 +553,7 @@ S_perl_hash_one_at_a_time_hard(const unsigned char * const seed, const unsigned
|
||||||
|
PERL_STATIC_INLINE U32
|
||||||
|
S_perl_hash_old_one_at_a_time(const unsigned char * const seed, const unsigned char *str, const STRLEN len) {
|
||||||
|
const unsigned char * const end = (const unsigned char *)str + len;
|
||||||
|
- U32 hash = *((U32*)seed);
|
||||||
|
+ U32 hash = *((const U32*)seed);
|
||||||
|
while (str < end) {
|
||||||
|
hash += *str++;
|
||||||
|
hash += (hash << 10);
|
||||||
|
@@ -581,7 +581,7 @@ S_perl_hash_murmur_hash_64a (const unsigned char * const seed, const unsigned ch
|
||||||
|
{
|
||||||
|
const U64 m = UINT64_C(0xc6a4a7935bd1e995);
|
||||||
|
const int r = 47;
|
||||||
|
- U64 h = *((U64*)seed) ^ len;
|
||||||
|
+ U64 h = *((const U64*)seed) ^ len;
|
||||||
|
const U64 * data = (const U64 *)str;
|
||||||
|
const U64 * end = data + (len/8);
|
||||||
|
const unsigned char * data2;
|
||||||
|
--
|
||||||
|
2.7.4
|
||||||
|
|
|
@ -230,6 +230,10 @@ Patch60: perl-5.24.0-crash-on-explicit-return-from-s-e.patch
|
||||||
# Fix assigning split() return values to an array, in upstream after 5.25.7
|
# Fix assigning split() return values to an array, in upstream after 5.25.7
|
||||||
Patch61: perl-5.24.0-split-was-leaving-PL_sv_undef-in-unused-ary-slots.patch
|
Patch61: perl-5.24.0-split-was-leaving-PL_sv_undef-in-unused-ary-slots.patch
|
||||||
|
|
||||||
|
# Fix const correctness in hv_func.h, bug #1242980, RT#130169,
|
||||||
|
# in upstream after 5.25.7
|
||||||
|
Patch62: perl-5.25.7-Fix-const-correctness-in-hv_func.h.patch
|
||||||
|
|
||||||
# Link XS modules to libperl.so with EU::CBuilder on Linux, bug #960048
|
# Link XS modules to libperl.so with EU::CBuilder on Linux, bug #960048
|
||||||
Patch200: perl-5.16.3-Link-XS-modules-to-libperl.so-with-EU-CBuilder-on-Li.patch
|
Patch200: perl-5.16.3-Link-XS-modules-to-libperl.so-with-EU-CBuilder-on-Li.patch
|
||||||
|
|
||||||
|
@ -2917,6 +2921,7 @@ Perl extension for Version Objects
|
||||||
%patch59 -p1
|
%patch59 -p1
|
||||||
%patch60 -p1
|
%patch60 -p1
|
||||||
%patch61 -p1
|
%patch61 -p1
|
||||||
|
%patch62 -p1
|
||||||
%patch200 -p1
|
%patch200 -p1
|
||||||
%patch201 -p1
|
%patch201 -p1
|
||||||
|
|
||||||
|
@ -2969,6 +2974,7 @@ perl -x patchlevel.h \
|
||||||
'Fedora Patch59: Fix crash in Storable when deserializing malformed code reference (RT#68348, RT#130098)' \
|
'Fedora Patch59: Fix crash in Storable when deserializing malformed code reference (RT#68348, RT#130098)' \
|
||||||
'Fedora Patch60: Fix crash on explicit return from regular expression substitution (RT#130188)' \
|
'Fedora Patch60: Fix crash on explicit return from regular expression substitution (RT#130188)' \
|
||||||
'Fedora Patch61: Fix assigning split() return values to an array' \
|
'Fedora Patch61: Fix assigning split() return values to an array' \
|
||||||
|
'Fedora Patch62: Fix const correctness in hv_func.h (RT#130169)' \
|
||||||
'Fedora Patch200: Link XS modules to libperl.so with EU::CBuilder on Linux' \
|
'Fedora Patch200: Link XS modules to libperl.so with EU::CBuilder on Linux' \
|
||||||
'Fedora Patch201: Link XS modules to libperl.so with EU::MM on Linux' \
|
'Fedora Patch201: Link XS modules to libperl.so with EU::MM on Linux' \
|
||||||
%{nil}
|
%{nil}
|
||||||
|
@ -5253,6 +5259,7 @@ popd
|
||||||
- Fix crash on explicit return from regular expression substitution (RT#130188)
|
- Fix crash on explicit return from regular expression substitution (RT#130188)
|
||||||
- Tighten dependencies between architecture specific sub-packages to ISA
|
- Tighten dependencies between architecture specific sub-packages to ISA
|
||||||
- Fix assigning split() return values to an array
|
- Fix assigning split() return values to an array
|
||||||
|
- Fix const correctness in hv_func.h (bug #1242980)
|
||||||
|
|
||||||
* Wed Nov 09 2016 Petr Pisar <ppisar@redhat.com> - 4:5.24.0-380
|
* Wed Nov 09 2016 Petr Pisar <ppisar@redhat.com> - 4:5.24.0-380
|
||||||
- Tie perl-Errno release to interpreter build because of kernel version check
|
- Tie perl-Errno release to interpreter build because of kernel version check
|
||||||
|
|
Loading…
Reference in New Issue