Skip to content

Commit

Permalink
GODRIVER-2156 Enable nakedret linter. (mongodb#798)
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewdale authored Nov 16, 2021
1 parent 49fed90 commit c2cbeca
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ linters:
- govet
- ineffassign
# - misspell
# - nakedret
- nakedret
- revive
- staticcheck
# - structcheck
Expand Down
7 changes: 4 additions & 3 deletions bson/primitive/decimal.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ Loop:
}

// BigInt returns significand as big.Int and exponent, bi * 10 ^ exp.
func (d Decimal128) BigInt() (bi *big.Int, exp int, err error) {
func (d Decimal128) BigInt() (*big.Int, int, error) {
high, low := d.GetBytes()
posSign := high>>63&1 == 0 // positive sign

Expand All @@ -147,6 +147,7 @@ func (d Decimal128) BigInt() (bi *big.Int, exp int, err error) {
return nil, 0, ErrParseNegInf
}

var exp int
if high>>61&3 == 3 {
// Bits: 1*sign 2*ignored 14*exponent 111*significand.
// Implicit 0b100 prefix in significand.
Expand All @@ -169,7 +170,7 @@ func (d Decimal128) BigInt() (bi *big.Int, exp int, err error) {
return new(big.Int), 0, nil
}

bi = big.NewInt(0)
bi := big.NewInt(0)
const host32bit = ^uint(0)>>32 == 0
if host32bit {
bi.SetBits([]big.Word{big.Word(low), big.Word(low >> 32), big.Word(high), big.Word(high >> 32)})
Expand All @@ -180,7 +181,7 @@ func (d Decimal128) BigInt() (bi *big.Int, exp int, err error) {
if !posSign {
return bi.Neg(bi), exp, nil
}
return
return bi, exp, nil
}

// IsNaN returns whether d is NaN.
Expand Down

0 comments on commit c2cbeca

Please sign in to comment.