From 384f012f9aef3d8d2e4054058c919f46d57e8087 Mon Sep 17 00:00:00 2001 From: Julien Robert Date: Thu, 11 May 2023 17:11:05 +0200 Subject: [PATCH] fix(orm): int overflows on arm build (#16108) --- orm/encoding/ormfield/duration.go | 10 +++++----- orm/encoding/ormfield/timestamp.go | 12 ++++++------ 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/orm/encoding/ormfield/duration.go b/orm/encoding/ormfield/duration.go index 6b4b42fabe..078d0ca614 100644 --- a/orm/encoding/ormfield/duration.go +++ b/orm/encoding/ormfield/duration.go @@ -8,10 +8,10 @@ import ( ) const ( - DurationSecondsMin = -315576000000 - DurationSecondsMax = 315576000000 - DurationNanosMin = -999999999 - DurationNanosMax = 999999999 + DurationSecondsMin int64 = -315576000000 + DurationSecondsMax int64 = 315576000000 + DurationNanosMin = -999999999 + DurationNanosMax = 999999999 ) // DurationCodec encodes google.protobuf.Duration values with the following @@ -41,7 +41,7 @@ func (d DurationCodec) Encode(value protoreflect.Value, w io.Writer) error { return fmt.Errorf("duration seconds is out of range %d, must be between %d and %d", secondsInt, DurationSecondsMin, DurationSecondsMax) } negative := secondsInt < 0 - // we subtract the min duration value to make sure secondsInt is always non-negative and starts at 0 + // we subtract the min duration value to make sure secondsInt is always non-negative and starts at 0. secondsInt -= DurationSecondsMin err := encodeSeconds(secondsInt, w) if err != nil { diff --git a/orm/encoding/ormfield/timestamp.go b/orm/encoding/ormfield/timestamp.go index ab3c5049cb..0049b13f15 100644 --- a/orm/encoding/ormfield/timestamp.go +++ b/orm/encoding/ormfield/timestamp.go @@ -21,12 +21,12 @@ import ( type TimestampCodec struct{} const ( - timestampDurationNilValue = 0xFF - timestampDurationZeroNanosValue = 0x0 - timestampDurationBufferSize = 9 - TimestampSecondsMin = -62135596800 - TimestampSecondsMax = 253402300799 - TimestampNanosMax = 999999999 + timestampDurationNilValue = 0xFF + timestampDurationZeroNanosValue = 0x0 + timestampDurationBufferSize = 9 + TimestampSecondsMin int64 = -62135596800 + TimestampSecondsMax int64 = 253402300799 + TimestampNanosMax = 999999999 ) var (