Skip to content

Commit

Permalink
Do not overflow int for 32bit builds
Browse files Browse the repository at this point in the history
This was causing build issues for GOARCH=arm GOARM=7.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
  • Loading branch information
cpuguy83 committed Mar 24, 2021
1 parent 0e92c22 commit 53fd78a
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions zfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ const (
// active := filepath.Join(dataset.Name, id)
// committed := active + "@" + snapshotSuffix
snapshotSuffix = "snapshot"

// Using this typed MaxInt64 to prevent integer overlow on 32bit
maxSnapshotSize int64 = math.MaxInt64
)

type snapshotter struct {
Expand Down Expand Up @@ -140,8 +143,8 @@ func (z *snapshotter) usage(ctx context.Context, key string) (snapshots.Usage, e
return snapshots.Usage{}, err
}

if sDataset.Used > math.MaxInt64 {
return snapshots.Usage{}, errors.Errorf("Dataset size exceeds maximum snapshot size of %v bytes", math.MaxInt64)
if int64(sDataset.Used) > maxSnapshotSize {
return snapshots.Usage{}, errors.Errorf("Dataset size exceeds maximum snapshot size of %d bytes", maxSnapshotSize)
}

usage = snapshots.Usage{
Expand Down

0 comments on commit 53fd78a

Please sign in to comment.