summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakob Unterwurzacher2016-09-25 19:48:21 +0200
committerJakob Unterwurzacher2016-09-25 19:48:21 +0200
commit5f4b16c00f2475a8efd0ae0d4d4e26f92b563dc0 (patch)
tree5b9a65d94c3cc58c032e731ea4cb776947b30ebd
parent166ba74a053898a52ff2e48125c1df97f35a85fd (diff)
Implement changes proposed by gosimple.
Also delete the unused "dirIVNameStruct", found by deadcode.
-rw-r--r--internal/configfile/config_file.go6
-rw-r--r--internal/fusefrontend/file_holes.go5
-rw-r--r--internal/fusefrontend_reverse/reverse_longnames.go5
-rw-r--r--internal/prefer_openssl/prefer_test.go4
-rw-r--r--internal/stupidgcm/stupidgcm_test.go6
-rw-r--r--main.go2
-rw-r--r--tests/matrix/matrix_test.go12
7 files changed, 14 insertions, 26 deletions
diff --git a/internal/configfile/config_file.go b/internal/configfile/config_file.go
index 74f506f..fab74a6 100644
--- a/internal/configfile/config_file.go
+++ b/internal/configfile/config_file.go
@@ -198,9 +198,5 @@ func (cf *ConfFile) WriteFile() error {
return err
}
err = os.Rename(tmp, cf.filename)
- if err != nil {
- return err
- }
-
- return nil
+ return err
}
diff --git a/internal/fusefrontend/file_holes.go b/internal/fusefrontend/file_holes.go
index 1d9a5fb..34f702f 100644
--- a/internal/fusefrontend/file_holes.go
+++ b/internal/fusefrontend/file_holes.go
@@ -12,10 +12,7 @@ import (
func (f *file) createsHole(plainSize uint64, off int64) bool {
nextBlock := f.contentEnc.PlainOffToBlockNo(plainSize)
targetBlock := f.contentEnc.PlainOffToBlockNo(uint64(off))
- if targetBlock > nextBlock {
- return true
- }
- return false
+ return targetBlock > nextBlock
}
// Zero-pad the file of size plainSize to the next block boundary
diff --git a/internal/fusefrontend_reverse/reverse_longnames.go b/internal/fusefrontend_reverse/reverse_longnames.go
index 9c45fe8..6409d95 100644
--- a/internal/fusefrontend_reverse/reverse_longnames.go
+++ b/internal/fusefrontend_reverse/reverse_longnames.go
@@ -17,11 +17,6 @@ const (
shortNameMax = 176
)
-type dirIVNameStruct struct {
- dirIV [nametransform.DirIVLen]byte
- name string
-}
-
var longnameParentCache map[string]string
var longnameCacheLock sync.Mutex
diff --git a/internal/prefer_openssl/prefer_test.go b/internal/prefer_openssl/prefer_test.go
index a2ed737..289a0a9 100644
--- a/internal/prefer_openssl/prefer_test.go
+++ b/internal/prefer_openssl/prefer_test.go
@@ -10,14 +10,14 @@ func TestCurrentCPU(t *testing.T) {
// Has AES instructions
func TestXeonE312xx(t *testing.T) {
- if filePreferOpenSSL("cpuinfo.xeon_e312xx.txt") == true {
+ if filePreferOpenSSL("cpuinfo.xeon_e312xx.txt") {
t.Fail()
}
}
// Pentium G do not have AES instructions
func TestPentiumG630(t *testing.T) {
- if filePreferOpenSSL("cpuinfo.pentium_g630.txt") == false {
+ if !filePreferOpenSSL("cpuinfo.pentium_g630.txt") {
t.Fail()
}
}
diff --git a/internal/stupidgcm/stupidgcm_test.go b/internal/stupidgcm/stupidgcm_test.go
index 82516b3..b0e25ab 100644
--- a/internal/stupidgcm/stupidgcm_test.go
+++ b/internal/stupidgcm/stupidgcm_test.go
@@ -52,7 +52,7 @@ func TestEncryptDecrypt(t *testing.T) {
gOut := gGCM.Seal(dst, iv, in, authData)
// Ciphertext must be identical to Go GCM
- if bytes.Compare(sOut, gOut) != 0 {
+ if !bytes.Equal(sOut, gOut) {
t.Fatalf("Compare failed for encryption, size %d", i)
t.Log("sOut:")
t.Log("\n" + hex.Dump(sOut))
@@ -70,7 +70,7 @@ func TestEncryptDecrypt(t *testing.T) {
}
// Plaintext must be identical to Go GCM
- if bytes.Compare(sOut2, gOut2) != 0 {
+ if !bytes.Equal(sOut2, gOut2) {
t.Fatalf("Compare failed for decryption, size %d", i)
}
}
@@ -90,7 +90,7 @@ func TestCorruption(t *testing.T) {
if sErr != nil {
t.Fatal(sErr)
}
- if bytes.Compare(in, sOut2) != 0 {
+ if !bytes.Equal(in, sOut2) {
t.Fatalf("Compare failed")
}
diff --git a/main.go b/main.go
index e2777b0..c2da1f0 100644
--- a/main.go
+++ b/main.go
@@ -198,7 +198,7 @@ func main() {
tlog.Info.Printf("Note: You must unmount gracefully, otherwise the profile file(s) will stay empty!\n")
}
// "-openssl"
- if args.openssl == false {
+ if !args.openssl {
tlog.Debug.Printf("OpenSSL disabled, using Go GCM")
} else {
tlog.Debug.Printf("OpenSSL enabled")
diff --git a/tests/matrix/matrix_test.go b/tests/matrix/matrix_test.go
index 46ffbcb..663482e 100644
--- a/tests/matrix/matrix_test.go
+++ b/tests/matrix/matrix_test.go
@@ -414,17 +414,17 @@ func TestRmwRace(t *testing.T) {
func TestFiltered(t *testing.T) {
filteredFile := test_helpers.DefaultPlainDir + "/gocryptfs.conf"
file, err := os.Create(filteredFile)
- if plaintextnames == true && err == nil {
+ if plaintextnames && err == nil {
t.Errorf("should have failed but didn't")
- } else if plaintextnames == false && err != nil {
+ } else if !plaintextnames && err != nil {
t.Error(err)
}
file.Close()
err = os.Remove(filteredFile)
- if plaintextnames == true && err == nil {
+ if plaintextnames && err == nil {
t.Errorf("should have failed but didn't")
- } else if plaintextnames == false && err != nil {
+ } else if !plaintextnames && err != nil {
t.Error(err)
}
}
@@ -436,9 +436,9 @@ func TestFilenameEncryption(t *testing.T) {
t.Fatal(err)
}
_, err = os.Stat(test_helpers.DefaultCipherDir + "/TestFilenameEncryption.txt")
- if plaintextnames == true && err != nil {
+ if plaintextnames && err != nil {
t.Errorf("plaintextnames not working: %v", err)
- } else if plaintextnames == false && err == nil {
+ } else if !plaintextnames && err == nil {
t.Errorf("file name encryption not working")
}
}