1From 99127676dba8f5d607757428bc14a6b7ab52d5ed Mon Sep 17 00:00:00 2001
2From: =?UTF-8?q?Andreas=20M=C3=BCller?= <schnitzeltony@googlemail.com>
3Date: Fri, 16 Dec 2016 12:42:06 +0100
4Subject: [PATCH 1/3] fix negative shift constants
5MIME-Version: 1.0
6Content-Type: text/plain; charset=UTF-8
7Content-Transfer-Encoding: 8bit
8
9Stolen from [1]
10
11[1] http://pkgs.fedoraproject.org/cgit/rpms/audiofile.git/tree/audiofile-0.3.6-left-shift-neg.patch
12
13Upstrem-Status: Pending
14
15Signed-off-by: Andreas Müller <schnitzeltony@googlemail.com>
16---
17Upstream-Status: Pending
18
19 libaudiofile/modules/SimpleModule.h | 2 +-
20 test/FloatToInt.cpp                 | 2 +-
21 test/IntToFloat.cpp                 | 2 +-
22 test/Sign.cpp                       | 2 +-
23 4 files changed, 4 insertions(+), 4 deletions(-)
24
25diff --git a/libaudiofile/modules/SimpleModule.h b/libaudiofile/modules/SimpleModule.h
26index 03c6c69..e4cc138 100644
27--- a/libaudiofile/modules/SimpleModule.h
28+++ b/libaudiofile/modules/SimpleModule.h
29@@ -123,7 +123,7 @@ struct signConverter
30 	typedef typename IntTypes<Format>::UnsignedType UnsignedType;
31
32 	static const int kScaleBits = (Format + 1) * CHAR_BIT - 1;
33-	static const int kMinSignedValue = -1 << kScaleBits;
34+	static const int kMinSignedValue = 0-(1U<<kScaleBits);
35
36 	struct signedToUnsigned : public std::unary_function<SignedType, UnsignedType>
37 	{
38diff --git a/test/FloatToInt.cpp b/test/FloatToInt.cpp
39index 0d179a8..bf491b2 100644
40--- a/test/FloatToInt.cpp
41+++ b/test/FloatToInt.cpp
42@@ -115,7 +115,7 @@ TEST_F(FloatToIntTest, Int16)
43 		EXPECT_EQ(readData[i], expectedData[i]);
44 }
45
46-static const int32_t kMinInt24 = -1<<23;
47+static const int32_t kMinInt24 = 0-(1U<<23);
48 static const int32_t kMaxInt24 = (1<<23) - 1;
49
50 TEST_F(FloatToIntTest, Int24)
51diff --git a/test/IntToFloat.cpp b/test/IntToFloat.cpp
52index b716635..1d91b58 100644
53--- a/test/IntToFloat.cpp
54+++ b/test/IntToFloat.cpp
55@@ -117,7 +117,7 @@ TEST_F(IntToFloatTest, Int16)
56 		EXPECT_EQ(readData[i], expectedData[i]);
57 }
58
59-static const int32_t kMinInt24 = -1<<23;
60+static const int32_t kMinInt24 = 0-(1U<<23);
61 static const int32_t kMaxInt24 = (1<<23) - 1;
62
63 TEST_F(IntToFloatTest, Int24)
64diff --git a/test/Sign.cpp b/test/Sign.cpp
65index 7275399..c339514 100644
66--- a/test/Sign.cpp
67+++ b/test/Sign.cpp
68@@ -116,7 +116,7 @@ TEST_F(SignConversionTest, Int16)
69 		EXPECT_EQ(readData[i], expectedData[i]);
70 }
71
72-static const int32_t kMinInt24 = -1<<23;
73+static const int32_t kMinInt24 = 0-(1U<<23);
74 static const int32_t kMaxInt24 = (1<<23) - 1;
75 static const uint32_t kMaxUInt24 = (1<<24) - 1;
76
77--
782.7.4
79
80