1
0
mirror of https://blitiri.com.ar/repos/chasquid synced 2025-12-17 14:37:02 +00:00

Make it explicit when we are intentionally not checking errors

The linter complains that we're not checking for errors, but on some
cases it's on code paths were it is reasonable to do so (e.g. we're
closing the connection and it's a best-effort write).

This patch adjusts the code to make those cases explicit.
This commit is contained in:
Alberto Bertogli
2020-04-13 14:24:17 +01:00
parent aed0156579
commit d6b512166b
5 changed files with 10 additions and 10 deletions

View File

@@ -209,7 +209,7 @@ func initMailLog(path string) {
if path == "<syslog>" { if path == "<syslog>" {
maillog.Default, err = maillog.NewSyslog() maillog.Default, err = maillog.NewSyslog()
} else { } else {
os.MkdirAll(filepath.Dir(path), 0775) _ = os.MkdirAll(filepath.Dir(path), 0775)
var f *os.File var f *os.File
f, err = os.OpenFile(path, os.O_WRONLY|os.O_APPEND|os.O_CREATE, 0664) f, err = os.OpenFile(path, os.O_WRONLY|os.O_APPEND|os.O_CREATE, 0664)
maillog.Default = maillog.New(f) maillog.Default = maillog.New(f)
@@ -309,7 +309,7 @@ func launchMonitoringServer(addr string) {
flags := dumpFlags() flags := dumpFlags()
http.HandleFunc("/debug/flags", func(w http.ResponseWriter, r *http.Request) { http.HandleFunc("/debug/flags", func(w http.ResponseWriter, r *http.Request) {
w.Write([]byte(flags)) _, _ = w.Write([]byte(flags))
}) })
go http.ListenAndServe(addr, nil) go http.ListenAndServe(addr, nil)

View File

@@ -208,7 +208,7 @@ func aliasesResolve() {
if err != nil { if err != nil {
Fatalf("Error reading config") Fatalf("Error reading config")
} }
os.Chdir(configDir) _ = os.Chdir(configDir)
r := aliases.NewResolver() r := aliases.NewResolver()
r.SuffixSep = conf.SuffixSeparators r.SuffixSep = conf.SuffixSeparators
@@ -294,7 +294,7 @@ func aliasesAdd() {
if err != nil { if err != nil {
Fatalf("Error reading config") Fatalf("Error reading config")
} }
os.Chdir(configDir) _ = os.Chdir(configDir)
// Setup alias resolver. // Setup alias resolver.
r := aliases.NewResolver() r := aliases.NewResolver()

View File

@@ -220,7 +220,7 @@ retry:
return a.tr.Errorf("DATA closing %v", err), smtp.IsPermanent(err) return a.tr.Errorf("DATA closing %v", err), smtp.IsPermanent(err)
} }
c.Quit() _ = c.Quit()
a.tr.Debugf("done") a.tr.Debugf("done")
return nil, false return nil, false

View File

@@ -250,7 +250,7 @@ loop:
case "AUTH": case "AUTH":
code, msg = c.AUTH(params) code, msg = c.AUTH(params)
case "QUIT": case "QUIT":
c.writeResponse(221, "2.0.0 Be seeing you...") _ = c.writeResponse(221, "2.0.0 Be seeing you...")
break loop break loop
default: default:
// Sanitize it a bit to avoid filling the logs and events with // Sanitize it a bit to avoid filling the logs and events with
@@ -272,7 +272,7 @@ loop:
if errCount > 10 { if errCount > 10 {
// https://tools.ietf.org/html/rfc5321#section-4.3.2 // https://tools.ietf.org/html/rfc5321#section-4.3.2
c.tr.Errorf("too many errors, breaking connection") c.tr.Errorf("too many errors, breaking connection")
c.writeResponse(421, "4.5.0 Too many errors, bye") _ = c.writeResponse(421, "4.5.0 Too many errors, bye")
break break
} }
} }
@@ -1090,9 +1090,9 @@ func (c *Conn) writeResponse(code int, msg string) error {
return writeResponse(c.writer, code, msg) return writeResponse(c.writer, code, msg)
} }
func (c *Conn) printfLine(format string, args ...interface{}) error { func (c *Conn) printfLine(format string, args ...interface{}) {
fmt.Fprintf(c.writer, format+"\r\n", args...) fmt.Fprintf(c.writer, format+"\r\n", args...)
return c.writer.Flush() c.writer.Flush()
} }
// writeResponse writes a multi-line response to the given writer. // writeResponse writes a multi-line response to the given writer.

View File

@@ -156,7 +156,7 @@ func (s *Server) InitQueue(path string, localC, remoteC courier.Courier) {
http.HandleFunc("/debug/queue", http.HandleFunc("/debug/queue",
func(w http.ResponseWriter, r *http.Request) { func(w http.ResponseWriter, r *http.Request) {
w.Write([]byte(q.DumpString())) _, _ = w.Write([]byte(q.DumpString()))
}) })
} }