File: 0006-Prevent-integer-constant-overflow-on-32-bit-systems.patch

package info (click to toggle)
android-platform-build-kati 10.0.0%2Br32%2Bgit20220314.09dfa26c4e59-7
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 2,596 kB
  • sloc: cpp: 10,339; sh: 1,087; python: 85; makefile: 46
file content (30 lines) | stat: -rw-r--r-- 1,142 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
From: Andrej Shadura <andrew.shadura@collabora.co.uk>
Date: Sat, 28 Jan 2023 11:22:35 +0100
Subject: Prevent integer constant overflow on 32-bit systems

10 gig doesn’t fit into a 32-bit int. This workaround makes it compile,
but this is effectively dead code as such huge values aren’t going to
fit into the function argument anyway.

src/github.com/google/kati/golang/kati/serialize.go:585:29: error: integer constant overflow
  585 |         if n >= 10*1000*1000*1000 {
      |                             ^
---
 golang/kati/serialize.go | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/golang/kati/serialize.go b/golang/kati/serialize.go
index 3ccb469..490e93d 100644
--- a/golang/kati/serialize.go
+++ b/golang/kati/serialize.go
@@ -582,7 +582,9 @@ func deserializeNodes(g serializableGraph) (r []*DepNode, err error) {
 }
 
 func human(n int) string {
-	if n >= 10*1000*1000*1000 {
+	// int is 32-bit on 32-bit systems, so this will never work anyway
+	tengiga := 10 * int64(1000) * 1000 * 1000
+	if int64(n) >= tengiga {
 		return fmt.Sprintf("%.2fGB", float32(n)/1000/1000/1000)
 	}
 	if n >= 10*1000*1000 {