Skip to content

Commit

Permalink
Fix integer overflow error when building for 386 (#1541)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
gammazero authored Oct 2, 2020
1 parent feb98a8 commit 68fb85d
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion badger/cmd/backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func doBackup(cmd *cobra.Command, args []string) error {
opt := badger.DefaultOptions(sstDir).
WithValueDir(vlogDir).
WithTruncate(truncate).
WithNumVersionsToKeep(math.MaxUint32)
WithNumVersionsToKeep(math.MaxInt32)

if numVersions > 0 {
opt.NumVersionsToKeep = numVersions
Expand Down
2 changes: 1 addition & 1 deletion badger/cmd/restore.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func doRestore(cmd *cobra.Command, args []string) error {
// Open DB
db, err := badger.Open(badger.DefaultOptions(sstDir).
WithValueDir(vlogDir).
WithNumVersionsToKeep(math.MaxUint32))
WithNumVersionsToKeep(math.MaxInt32))
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion value.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ import (

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

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

0 comments on commit 68fb85d

Please sign in to comment.