Skip to content

Commit 68fb85d

Browse files
authored
Fix integer overflow error when building for 386 (#1541)
The untyped const causes conversion to int, for which the value is too large. Use a typed const instead that is large enough to store value.
1 parent feb98a8 commit 68fb85d

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

badger/cmd/backup.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ func doBackup(cmd *cobra.Command, args []string) error {
5555
opt := badger.DefaultOptions(sstDir).
5656
WithValueDir(vlogDir).
5757
WithTruncate(truncate).
58-
WithNumVersionsToKeep(math.MaxUint32)
58+
WithNumVersionsToKeep(math.MaxInt32)
5959

6060
if numVersions > 0 {
6161
opt.NumVersionsToKeep = numVersions

badger/cmd/restore.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ func doRestore(cmd *cobra.Command, args []string) error {
6868
// Open DB
6969
db, err := badger.Open(badger.DefaultOptions(sstDir).
7070
WithValueDir(vlogDir).
71-
WithNumVersionsToKeep(math.MaxUint32))
71+
WithNumVersionsToKeep(math.MaxInt32))
7272
if err != nil {
7373
return err
7474
}

value.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ import (
4848

4949
// maxVlogFileSize is the maximum size of the vlog file which can be created. Vlog Offset is of
5050
// uint32, so limiting at max uint32.
51-
var maxVlogFileSize = math.MaxUint32
51+
var maxVlogFileSize uint32 = math.MaxUint32
5252

5353
// Values have their first byte being byteData or byteDelete. This helps us distinguish between
5454
// a key that has never been seen and a key that has been explicitly deleted.

0 commit comments

Comments
 (0)