]> git.apps.os.sepia.ceph.com Git - fscrypt.git/commitdiff
vet: eliminate unnecessary shadowing
authorJoseph Richey <joerichey94@gmail.com>
Mon, 12 Feb 2018 07:56:49 +0000 (23:56 -0800)
committerJoseph Richey <joerichey94@gmail.com>
Mon, 12 Feb 2018 07:56:49 +0000 (23:56 -0800)
Running "go vet -shadow ./..." finds all places where a variable might
be incorrectly or unnecessarily shadowed. This fixes some of them.

actions/protector.go
cmd/fscrypt/commands.go
crypto/key.go
metadata/policy.go
pam/pam.go
pam_fscrypt/run_fscrypt.go

index ffc3c433d142fadd318f858389b42503cc1f5833..fe5d6946c40979efa0a8ab935f16696b9baf992b 100644 (file)
@@ -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
        }
index 2f23a0fc211cdf83cc6c22d431f6d775a340fb52..66450c7c7773f6a699dee5facbbc10101d6bfd9a 100644 (file)
@@ -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)
        }
 
index 9bf90989f5aa8cfedb56e018f293fc5498da7aa9..027d46d4c87091c4ceb6f0257d1f31543554383c 100644 (file)
@@ -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
                }
 
index 533d48a6bdf080d2f0c9d859cb4404137bc48fc8..ce40f9c679fb80857efcd5f19dbc110499687aec 100644 (file)
@@ -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")
        }
 
index 0f20f302e7f621618d91ff4ef28aaaba2042514f..bd15c38a06c543e9c8beda72d75098869f877c2c 100644 (file)
@@ -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
        }
 
index 6414d99ca542efea494a694867afd6c5b9d64933..da336df514b46581af75812fa955a99974366a05 100644 (file)
@@ -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()