blob: ecb3108050d9c8c8acd9be1064834a9cc6e7604e [file] [log] [blame]
Brad Bishop6e60e8b2018-02-01 10:27:11 -05001From 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---
17 libaudiofile/modules/SimpleModule.h | 2 +-
18 test/FloatToInt.cpp | 2 +-
19 test/IntToFloat.cpp | 2 +-
20 test/Sign.cpp | 2 +-
21 4 files changed, 4 insertions(+), 4 deletions(-)
22
23diff --git a/libaudiofile/modules/SimpleModule.h b/libaudiofile/modules/SimpleModule.h
24index 03c6c69..e4cc138 100644
25--- a/libaudiofile/modules/SimpleModule.h
26+++ b/libaudiofile/modules/SimpleModule.h
27@@ -123,7 +123,7 @@ struct signConverter
28 typedef typename IntTypes<Format>::UnsignedType UnsignedType;
29
30 static const int kScaleBits = (Format + 1) * CHAR_BIT - 1;
31- static const int kMinSignedValue = -1 << kScaleBits;
32+ static const int kMinSignedValue = 0-(1U<<kScaleBits);
33
34 struct signedToUnsigned : public std::unary_function<SignedType, UnsignedType>
35 {
36diff --git a/test/FloatToInt.cpp b/test/FloatToInt.cpp
37index 0d179a8..bf491b2 100644
38--- a/test/FloatToInt.cpp
39+++ b/test/FloatToInt.cpp
40@@ -115,7 +115,7 @@ TEST_F(FloatToIntTest, Int16)
41 EXPECT_EQ(readData[i], expectedData[i]);
42 }
43
44-static const int32_t kMinInt24 = -1<<23;
45+static const int32_t kMinInt24 = 0-(1U<<23);
46 static const int32_t kMaxInt24 = (1<<23) - 1;
47
48 TEST_F(FloatToIntTest, Int24)
49diff --git a/test/IntToFloat.cpp b/test/IntToFloat.cpp
50index b716635..1d91b58 100644
51--- a/test/IntToFloat.cpp
52+++ b/test/IntToFloat.cpp
53@@ -117,7 +117,7 @@ TEST_F(IntToFloatTest, Int16)
54 EXPECT_EQ(readData[i], expectedData[i]);
55 }
56
57-static const int32_t kMinInt24 = -1<<23;
58+static const int32_t kMinInt24 = 0-(1U<<23);
59 static const int32_t kMaxInt24 = (1<<23) - 1;
60
61 TEST_F(IntToFloatTest, Int24)
62diff --git a/test/Sign.cpp b/test/Sign.cpp
63index 7275399..c339514 100644
64--- a/test/Sign.cpp
65+++ b/test/Sign.cpp
66@@ -116,7 +116,7 @@ TEST_F(SignConversionTest, Int16)
67 EXPECT_EQ(readData[i], expectedData[i]);
68 }
69
70-static const int32_t kMinInt24 = -1<<23;
71+static const int32_t kMinInt24 = 0-(1U<<23);
72 static const int32_t kMaxInt24 = (1<<23) - 1;
73 static const uint32_t kMaxUInt24 = (1<<24) - 1;
74
75--
762.7.4
77