diff options
author | maya <maya@pkgsrc.org> | 2016-12-19 00:14:43 +0000 |
---|---|---|
committer | maya <maya@pkgsrc.org> | 2016-12-19 00:14:43 +0000 |
commit | a090cac3ae7d95232f8bd9668b0edd8c4ef0cc59 (patch) | |
tree | 832fc27f47e15caccde91a17990c7d5f1a4dc183 /audio/libaudiofile | |
parent | 1cb8673c79091fdad81a773b1afbbb5cdb94847a (diff) | |
download | pkgsrc-a090cac3ae7d95232f8bd9668b0edd8c4ef0cc59.tar.gz |
libaudiofile: fix the second UB in the same line of code, cstatic which
isn't actually a cstatic. switch to just defining it in the accessor.
GCC optimized this UB away leading to an undefined reference in the builds.
Also use a function which is right for int32 too (same as upstream)
Thanks joerg for the help
Diffstat (limited to 'audio/libaudiofile')
-rw-r--r-- | audio/libaudiofile/distinfo | 4 | ||||
-rw-r--r-- | audio/libaudiofile/patches/patch-libaudiofile_modules_SimpleModule.h | 35 |
2 files changed, 32 insertions, 7 deletions
diff --git a/audio/libaudiofile/distinfo b/audio/libaudiofile/distinfo index 3ea54c9c7b7..8d4b7be16f6 100644 --- a/audio/libaudiofile/distinfo +++ b/audio/libaudiofile/distinfo @@ -1,8 +1,8 @@ -$NetBSD: distinfo,v 1.28 2016/12/18 23:40:22 maya Exp $ +$NetBSD: distinfo,v 1.29 2016/12/19 00:14:43 maya Exp $ SHA1 (audiofile-0.3.6.tar.gz) = 3aba3ef724b1b5f88cfc20ab9f8ce098e6c35a0e RMD160 (audiofile-0.3.6.tar.gz) = d0666dbf98cb4b41304b01e1b4f8ca15fe9288d8 SHA512 (audiofile-0.3.6.tar.gz) = f9a1182d93e405c21eba79c5cc40962347bff13f1b3b732d9a396e3d1675297515188bd6eb43033aaa00e9bde74ff4628c1614462456529cabba464f03c1d5fa Size (audiofile-0.3.6.tar.gz) = 811733 bytes SHA1 (patch-libaudiofile_CAF.cpp) = ddea79105f9b1e7222f91649815668d3a8ee6e98 -SHA1 (patch-libaudiofile_modules_SimpleModule.h) = f1e3842d3d9ddcea6b547bbeb5991769855ab2fc +SHA1 (patch-libaudiofile_modules_SimpleModule.h) = 356869de2119e868e84cc9d39f370270678a778c diff --git a/audio/libaudiofile/patches/patch-libaudiofile_modules_SimpleModule.h b/audio/libaudiofile/patches/patch-libaudiofile_modules_SimpleModule.h index 53e1cd38771..0340729e6f0 100644 --- a/audio/libaudiofile/patches/patch-libaudiofile_modules_SimpleModule.h +++ b/audio/libaudiofile/patches/patch-libaudiofile_modules_SimpleModule.h @@ -1,16 +1,41 @@ -$NetBSD: patch-libaudiofile_modules_SimpleModule.h,v 1.2 2016/12/18 23:40:23 maya Exp $ +$NetBSD: patch-libaudiofile_modules_SimpleModule.h,v 1.3 2016/12/19 00:14:43 maya Exp $ Left shift of a negative number is UB and doesn't build (-fpermissive) Switch with functionally identical but well-defined operation. +(same function used upstream) + +Just define it in the accessor rather than a cstatic global (which isn't +actually cstatic, which is UB and optimized away at least by GCC) --- libaudiofile/modules/SimpleModule.h.orig 2013-03-06 05:30:03.000000000 +0000 +++ libaudiofile/modules/SimpleModule.h -@@ -123,7 +123,7 @@ struct signConverter +@@ -122,17 +122,24 @@ struct signConverter + typedef typename IntTypes<Format>::SignedType SignedType; typedef typename IntTypes<Format>::UnsignedType UnsignedType; - static const int kScaleBits = (Format + 1) * CHAR_BIT - 1; +- static const int kScaleBits = (Format + 1) * CHAR_BIT - 1; - static const int kMinSignedValue = -1 << kScaleBits; -+ static const int kMinSignedValue = -(1 << kScaleBits); - +- struct signedToUnsigned : public std::unary_function<SignedType, UnsignedType> { +- UnsignedType operator()(SignedType x) { return x - kMinSignedValue; } ++ UnsignedType operator()(SignedType x) { ++ int kScaleBits = (Format + 1) * CHAR_BIT - 1; ++ int kMaxSignedValue = (((1 << (kScaleBits - 1)) - 1) << 1) + 1; ++ int kMinSignedValue = -kMaxSignedValue - 1; ++ return x - kMinSignedValue; ++ } + }; + + struct unsignedToSigned : public std::unary_function<SignedType, UnsignedType> + { +- SignedType operator()(UnsignedType x) { return x + kMinSignedValue; } ++ SignedType operator()(UnsignedType x) { ++ int kScaleBits = (Format + 1) * CHAR_BIT - 1; ++ int kMaxSignedValue = (((1 << (kScaleBits - 1)) - 1) << 1) + 1; ++ int kMinSignedValue = -kMaxSignedValue - 1; ++ return x + kMinSignedValue; ++ } + }; + }; + |