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 {
|