From 31a5ebcf4b4ecd02f37a0c67edae5ed04e949e44 Mon Sep 17 00:00:00 2001 From: HuKeping Date: Tue, 10 May 2016 09:47:33 +0800 Subject: [PATCH] From riyazdf's review Prior to this patch, if we provide a value to the output flag, we write both to the file as well as stdout which is not consistent with the flag description and also not the intended. Signed-off-by: Hu Keping --- cmd/notary/util.go | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/cmd/notary/util.go b/cmd/notary/util.go index 1a71f14b69..887204f088 100644 --- a/cmd/notary/util.go +++ b/cmd/notary/util.go @@ -12,7 +12,7 @@ func getPayload(t *tufCommander) ([]byte, error) { // Reads from the given file if t.input != "" { - // Please be noticed that ReadFile will cut off the size if it was over 1e9. + // Please note that ReadFile will cut off the size if it was over 1e9. // Thus, if the size of the file exceeds 1GB, the over part will not be // loaded into the buffer. payload, err := ioutil.ReadFile(t.input) @@ -33,7 +33,7 @@ func getPayload(t *tufCommander) ([]byte, error) { // feedback is a helper function to print the payload to a file or STDOUT or keep quiet // due to the value of flag "quiet" and "output". func feedback(t *tufCommander, payload []byte) error { - // We only get here when everythings goes well, since the flag "quiet" was + // We only get here when everything goes well, since the flag "quiet" was // provided, we output nothing but just return. if t.quiet { return nil @@ -41,9 +41,7 @@ func feedback(t *tufCommander, payload []byte) error { // Flag "quiet" was not "true", that's why we get here. if t.output != "" { - if err := ioutil.WriteFile(t.output, payload, 0644); err != nil { - return err - } + return ioutil.WriteFile(t.output, payload, 0644) } os.Stdout.Write(payload)