| 1 |
From: Andrej Shadura <[email protected]> |
| 2 |
Date: Sat, 28 Jan 2023 11:22:35 +0100 |
| 3 |
Subject: Prevent integer constant overflow on 32-bit systems |
| 4 |
|
| 5 |
10 gig doesn’t fit into a 32-bit int. This workaround makes it compile, |
| 6 |
but this is effectively dead code as such huge values aren’t going to |
| 7 |
fit into the function argument anyway. |
| 8 |
|
| 9 |
src/github.com/google/kati/golang/kati/serialize.go:585:29: error: integer constant overflow |
| 10 |
585 | if n >= 10*1000*1000*1000 { |
| 11 |
| ^ |
| 12 |
--- |
| 13 |
golang/kati/serialize.go | 4 +++- |
| 14 |
1 file changed, 3 insertions(+), 1 deletion(-) |
| 15 |
|
| 16 |
diff --git a/golang/kati/serialize.go b/golang/kati/serialize.go |
| 17 |
index 3ccb469..490e93d 100644 |
| 18 |
--- a/golang/kati/serialize.go |
| 19 |
+++ b/golang/kati/serialize.go |
| 20 |
@@ -582,7 +582,9 @@ func deserializeNodes(g serializableGraph) (r []*DepNode, err error) { |
| 21 |
} |
| 22 |
|
| 23 |
func human(n int) string { |
| 24 |
- if n >= 10*1000*1000*1000 { |
| 25 |
+ // int is 32-bit on 32-bit systems, so this will never work anyway |
| 26 |
+ tengiga := 10 * int64(1000) * 1000 * 1000 |
| 27 |
+ if int64(n) >= tengiga { |
| 28 |
return fmt.Sprintf("%.2fGB", float32(n)/1000/1000/1000) |
| 29 |
} |
| 30 |
if n >= 10*1000*1000 { |