diff options
| author | Joseph Richey <joerichey94@gmail.com> | 2018-02-11 23:56:49 -0800 |
|---|---|---|
| committer | Joseph Richey <joerichey94@gmail.com> | 2018-02-11 23:56:49 -0800 |
| commit | 69630f37fcebe894b15872148bd8b2496806b60c (patch) | |
| tree | 1ae1ed02acba2c9beef4a81652d5594c67cf60e6 | |
| parent | 1f508cc30f3c1caadea5c648158880eacfe9b113 (diff) | |
vet: eliminate unnecessary shadowing
Running "go vet -shadow ./..." finds all places where a variable might
be incorrectly or unnecessarily shadowed. This fixes some of them.
| -rw-r--r-- | actions/protector.go | 4 | ||||
| -rw-r--r-- | cmd/fscrypt/commands.go | 8 | ||||
| -rw-r--r-- | crypto/key.go | 2 | ||||
| -rw-r--r-- | metadata/policy.go | 4 | ||||
| -rw-r--r-- | pam/pam.go | 2 | ||||
| -rw-r--r-- | pam_fscrypt/run_fscrypt.go | 2 |
6 files changed, 11 insertions, 11 deletions
diff --git a/actions/protector.go b/actions/protector.go index ffc3c43..fe5d694 100644 --- a/actions/protector.go +++ b/actions/protector.go @@ -123,7 +123,7 @@ func CreateProtector(ctx *Context, name string, keyFn KeyFunc) (*Protector, erro // UID for this kind of source. protector.data.Uid = int64(util.AtoiOrPanic(ctx.TargetUser.Uid)) // Make sure we aren't duplicating protectors - if err := checkIfUserHasLoginProtector(ctx, protector.data.Uid); err != nil { + if err = checkIfUserHasLoginProtector(ctx, protector.data.Uid); err != nil { return nil, err } fallthrough @@ -142,7 +142,7 @@ func CreateProtector(ctx *Context, name string, keyFn KeyFunc) (*Protector, erro } protector.data.ProtectorDescriptor = crypto.ComputeDescriptor(protector.key) - if err := protector.Rewrap(keyFn); err != nil { + if err = protector.Rewrap(keyFn); err != nil { protector.Lock() return nil, err } diff --git a/cmd/fscrypt/commands.go b/cmd/fscrypt/commands.go index 2f23a0f..66450c7 100644 --- a/cmd/fscrypt/commands.go +++ b/cmd/fscrypt/commands.go @@ -519,7 +519,7 @@ func createProtectorAction(c *cli.Context) error { } prompt := fmt.Sprintf("Create new protector on %q", ctx.Mount.Path) - if err := askConfirmation(prompt, true, ""); err != nil { + if err = askConfirmation(prompt, true, ""); err != nil { return newExitError(c, err) } @@ -561,20 +561,20 @@ func createPolicyAction(c *cli.Context) error { return newExitError(c, err) } - if err := checkRequiredFlags(c, []*stringFlag{protectorFlag}); err != nil { + if err = checkRequiredFlags(c, []*stringFlag{protectorFlag}); err != nil { return err } protector, err := getProtectorFromFlag(protectorFlag.Value, ctx.TargetUser) if err != nil { return newExitError(c, err) } - if err := protector.Unlock(existingKeyFn); err != nil { + if err = protector.Unlock(existingKeyFn); err != nil { return newExitError(c, err) } defer protector.Lock() prompt := fmt.Sprintf("Create new policy on %q", ctx.Mount.Path) - if err := askConfirmation(prompt, true, ""); err != nil { + if err = askConfirmation(prompt, true, ""); err != nil { return newExitError(c, err) } diff --git a/crypto/key.go b/crypto/key.go index 9bf9098..027d46d 100644 --- a/crypto/key.go +++ b/crypto/key.go @@ -333,7 +333,7 @@ func ReadRecoveryCode(reader io.Reader) (*Key, error) { for blockStart := blockSize; blockStart < encodedLength; blockStart += blockSize { r.Read(inputSeparator) if r.Err() == nil && !bytes.Equal(separator, inputSeparator) { - err := errors.Wrapf(ErrRecoveryCode, "invalid separator %q", inputSeparator) + err = errors.Wrapf(ErrRecoveryCode, "invalid separator %q", inputSeparator) return nil, err } diff --git a/metadata/policy.go b/metadata/policy.go index 533d48a..ce40f9c 100644 --- a/metadata/policy.go +++ b/metadata/policy.go @@ -86,7 +86,7 @@ func GetPolicy(path string) (*PolicyData, error) { defer file.Close() var policy unix.FscryptPolicy - if err := policyIoctl(file, unix.FS_IOC_GET_ENCRYPTION_POLICY, &policy); err != nil { + if err = policyIoctl(file, unix.FS_IOC_GET_ENCRYPTION_POLICY, &policy); err != nil { return nil, errors.Wrapf(err, "get encryption policy %s", path) } @@ -119,7 +119,7 @@ func SetPolicy(path string, data *PolicyData) error { } defer file.Close() - if err := data.CheckValidity(); err != nil { + if err = data.CheckValidity(); err != nil { return errors.Wrap(err, "invalid policy") } @@ -58,7 +58,7 @@ func NewHandle(pamh unsafe.Pointer) (*Handle, error) { var pamUsername *C.char h.status = C.pam_get_user(h.handle, &pamUsername, nil) - if err := h.err(); err != nil { + if err = h.err(); err != nil { return nil, err } diff --git a/pam_fscrypt/run_fscrypt.go b/pam_fscrypt/run_fscrypt.go index 6414d99..da336df 100644 --- a/pam_fscrypt/run_fscrypt.go +++ b/pam_fscrypt/run_fscrypt.go @@ -199,7 +199,7 @@ func AdjustCount(handle *pam.Handle, delta int) (int, error) { if err != nil { return 0, err } - if err := unix.Flock(int(file.Fd()), unix.LOCK_EX); err != nil { + if err = unix.Flock(int(file.Fd()), unix.LOCK_EX); err != nil { return 0, err } defer file.Close() |