From 9d2a156453eeb8bb3c530244016740d5c2794427 Mon Sep 17 00:00:00 2001 From: Gustav Simonsson Date: Thu, 23 Apr 2015 05:52:41 +0200 Subject: [PATCH 1/3] Fix ignore of unexpected files in key dir --- crypto/key_store_plain.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/crypto/key_store_plain.go b/crypto/key_store_plain.go index 338a4a2c34..99e0fa4403 100644 --- a/crypto/key_store_plain.go +++ b/crypto/key_store_plain.go @@ -117,13 +117,13 @@ func GetKeyAddresses(keysDirPath string) (addresses [][]byte, err error) { if err != nil { return nil, err } - addresses = make([][]byte, len(fileInfos)) - for i, fileInfo := range fileInfos { + addresses = *new([][]byte) + for _, fileInfo := range fileInfos { address, err := hex.DecodeString(fileInfo.Name()) if err != nil { continue } - addresses[i] = address + addresses = append(addresses, address) } return addresses, err } From 4d1887093df1fd07a680eaaff31351d921ce9c4d Mon Sep 17 00:00:00 2001 From: Gustav Simonsson Date: Fri, 24 Apr 2015 17:41:38 +0200 Subject: [PATCH 2/3] Use make instead of new for allocation --- crypto/key_store_plain.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crypto/key_store_plain.go b/crypto/key_store_plain.go index 99e0fa4403..a7ad385c51 100644 --- a/crypto/key_store_plain.go +++ b/crypto/key_store_plain.go @@ -117,7 +117,7 @@ func GetKeyAddresses(keysDirPath string) (addresses [][]byte, err error) { if err != nil { return nil, err } - addresses = *new([][]byte) + addresses = make([][]byte, 0) for _, fileInfo := range fileInfos { address, err := hex.DecodeString(fileInfo.Name()) if err != nil { From b0bf12ec872587d56b974430efc85c55ce9fe5a9 Mon Sep 17 00:00:00 2001 From: Gustav Simonsson Date: Fri, 24 Apr 2015 19:40:28 +0200 Subject: [PATCH 3/3] Remove unneeded allocation --- crypto/key_store_plain.go | 1 - 1 file changed, 1 deletion(-) diff --git a/crypto/key_store_plain.go b/crypto/key_store_plain.go index a7ad385c51..9bbaf1c15a 100644 --- a/crypto/key_store_plain.go +++ b/crypto/key_store_plain.go @@ -117,7 +117,6 @@ func GetKeyAddresses(keysDirPath string) (addresses [][]byte, err error) { if err != nil { return nil, err } - addresses = make([][]byte, 0) for _, fileInfo := range fileInfos { address, err := hex.DecodeString(fileInfo.Name()) if err != nil {