Skip to content

Commit

Permalink
Clean-up lint warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
foxcpp committed Jan 24, 2025
1 parent 120c5c9 commit dbc030c
Show file tree
Hide file tree
Showing 17 changed files with 9 additions and 28 deletions.
2 changes: 1 addition & 1 deletion framework/buffer/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
package buffer

import (
"crypto/rand"
"encoding/hex"
"fmt"
"io"
"math/rand"
"os"
"path/filepath"
)
Expand Down
2 changes: 1 addition & 1 deletion framework/cfgparser/imports.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func (ctx *parseContext) resolveImport(node Node, name string, expansionDepth in
src, err = os.Open(file + ".conf")
if err != nil {
if os.IsNotExist(err) {
return nil, NodeErr(node, "unknown import: "+name)
return nil, NodeErr(node, "unknown import: %s", name)
}
return nil, err
}
Expand Down
1 change: 0 additions & 1 deletion framework/cfgparser/parse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,6 @@ func TestRead(t *testing.T) {
os.Setenv("TESTING_VARIABLE2", "ABC2 DEF2")

for _, case_ := range cases {
case_ := case_
t.Run(case_.name, func(t *testing.T) {
tree, err := Read(strings.NewReader(case_.cfg), "test")
if !case_.fail && err != nil {
Expand Down
4 changes: 0 additions & 4 deletions framework/config/tls/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,6 @@ func readTLSBlock(globals map[string]interface{}, blockNode config.Node) (*TLSCo
return nil, err
}

if len(baseCfg.CipherSuites) != 0 {
baseCfg.PreferServerCipherSuites = true
}

baseCfg.MinVersion = tlsVersions[0]
baseCfg.MaxVersion = tlsVersions[1]
log.Debugf("tls: min version: %x, max version: %x", tlsVersions[0], tlsVersions[1])
Expand Down
7 changes: 5 additions & 2 deletions framework/log/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ func (l Logger) Println(val ...interface{}) {

// Msg writes an event log message in a machine-readable format (currently
// JSON).
// name: msg\t{"key":"value","key2":"value2"}
//
// name: msg\t{"key":"value","key2":"value2"}
//
// Key-value pairs are built from fields slice which should contain key strings
// followed by corresponding values. That is, for example, []interface{"key",
Expand All @@ -102,7 +103,9 @@ func (l Logger) Msg(msg string, fields ...interface{}) {
// JSON) containing information about the error. If err does have a Fields
// method that returns map[string]interface{}, its result will be added to the
// message.
// name: msg\t{"key":"value","key2":"value2"}
//
// name: msg\t{"key":"value","key2":"value2"}
//
// Additionally, values from fields will be added to it, as handled by
// Logger.Msg.
//
Expand Down
1 change: 0 additions & 1 deletion internal/check/dnsbl/dnsbl.go
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,6 @@ func (bl *DNSBL) checkLists(ctx context.Context, ip net.IP, ehlo, mailFrom strin
)

for _, list := range bl.bls {
list := list
eg.Go(func() error {
err := bl.checkList(ctx, list, ip, ehlo, mailFrom)
if err != nil {
Expand Down
1 change: 0 additions & 1 deletion internal/endpoint/dovecot_sasld/dovecot_sasl.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ func (endp *Endpoint) Init(cfg *config.Map) error {
endp.srv.Log = stdlog.New(endp.log, "", 0)

for _, mech := range endp.saslAuth.SASLMechanisms() {
mech := mech
endp.srv.AddMechanism(mech, mechInfo[mech], func(req *dovecotsasl.AuthReq) sasl.Server {
var remoteAddr net.Addr
if req.RemoteIP != nil && req.RemotePort != 0 {
Expand Down
2 changes: 0 additions & 2 deletions internal/endpoint/imap/imap.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,6 @@ func (endp *Endpoint) Init(cfg *config.Map) error {
}

for _, mech := range endp.saslAuth.SASLMechanisms() {
mech := mech
endp.serv.EnableAuth(mech, func(c imapserver.Conn) sasl.Server {
return endp.saslAuth.CreateSASL(mech, c.Info().RemoteAddr, func(identity string, data auth.ContextData) error {
return endp.openAccount(c, identity)
Expand Down Expand Up @@ -174,7 +173,6 @@ func (endp *Endpoint) setupListeners(addresses []config.Endpoint) error {
endp.listeners = append(endp.listeners, l)

endp.listenersWg.Add(1)
addr := addr
go func() {
if err := endp.serv.Serve(l); err != nil && !strings.HasSuffix(err.Error(), "use of closed network connection") {
endp.Log.Printf("imap: failed to serve %s: %s", addr, err)
Expand Down
1 change: 0 additions & 1 deletion internal/endpoint/openmetrics/om.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ func (e *Endpoint) Init(cfg *config.Map) error {
e.serv.Handler = e.mux

for _, a := range e.addrs {
a := a
endp, err := config.ParseEndpoint(a)
if err != nil {
return fmt.Errorf("%s: malformed endpoint: %v", modName, err)
Expand Down
4 changes: 0 additions & 4 deletions internal/endpoint/smtp/smtp.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import (
"crypto/tls"
"fmt"
"io"
"math/rand"
"net"
"os"
"path/filepath"
Expand Down Expand Up @@ -346,7 +345,6 @@ func (endp *Endpoint) setupListeners(addresses []config.Endpoint) error {
endp.listeners = append(endp.listeners, l)

endp.listenersWg.Add(1)
addr := addr
go func() {
if err := endp.serv.Serve(l); err != nil {
endp.Log.Printf("failed to serve %s: %s", addr, err)
Expand Down Expand Up @@ -431,6 +429,4 @@ func init() {
module.RegisterEndpoint("smtp", New)
module.RegisterEndpoint("submission", New)
module.RegisterEndpoint("lmtp", New)

rand.Seed(time.Now().UnixNano())
}
1 change: 0 additions & 1 deletion internal/endpoint/smtp/smtp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,6 @@ func TestMain(m *testing.M) {
flag.Parse()

if *remoteSmtpPort == "random" {
rand.Seed(time.Now().UnixNano())
*remoteSmtpPort = strconv.Itoa(rand.Intn(65536-10000) + 10000)
}

Expand Down
2 changes: 0 additions & 2 deletions internal/msgpipeline/check_runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ func (cr *checkRunner) checkStates(ctx context.Context, checks []module.Check) (

if len(cr.checkedRcpts) != 0 {
for _, rcpt := range cr.checkedRcpts {
rcpt := rcpt
err := cr.runAndMergeResults(states, func(s module.CheckState) module.CheckResult {
// Avoid calling CheckRcpt for the same recipient for the same check
// multiple times, even if requested.
Expand Down Expand Up @@ -176,7 +175,6 @@ func (cr *checkRunner) runAndMergeResults(states []module.CheckState, runner fun
}{}

for _, state := range states {
state := state
data.wg.Add(1)
go func() {
defer func() {
Expand Down
1 change: 0 additions & 1 deletion internal/msgpipeline/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,6 @@ func TestMsgPipelineCfg(t *testing.T) {
}

for _, case_ := range cases {
case_ := case_
t.Run(case_.name, func(t *testing.T) {
cfg, _ := parser.Read(strings.NewReader(case_.str), "literal")
parsed, err := parseMsgPipelineRootCfg(nil, cfg)
Expand Down
2 changes: 0 additions & 2 deletions internal/smtpconn/smtpconn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import (
"os"
"strconv"
"testing"
"time"
)

var testPort string
Expand All @@ -34,7 +33,6 @@ func TestMain(m *testing.M) {
flag.Parse()

if *remoteSmtpPort == "random" {
rand.Seed(time.Now().UnixNano())
*remoteSmtpPort = strconv.Itoa(rand.Intn(65536-10000) + 10000)
}

Expand Down
2 changes: 0 additions & 2 deletions internal/target/remote/remote.go
Original file line number Diff line number Diff line change
Expand Up @@ -406,8 +406,6 @@ func (rd *remoteDelivery) BodyNonAtomic(ctx context.Context, c module.StatusColl
var wg sync.WaitGroup

for i, conn := range rd.connections {
i := i
conn := conn
wg.Add(1)
go func() {
defer wg.Done()
Expand Down
3 changes: 2 additions & 1 deletion internal/updatepipe/unix_pipe.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ import (
// Listen goroutine can be running.
//
// The socket is stream-oriented and consists of the following messages:
// SENDER_ID;JSON_SERIALIZED_INTERNAL_OBJECT\n
//
// SENDER_ID;JSON_SERIALIZED_INTERNAL_OBJECT\n
//
// And SENDER_ID is Process ID and UnixSockPipe address concated as a string.
// It is used to deduplicate updates sent to Push and recevied via Listen.
Expand Down
1 change: 0 additions & 1 deletion maddy.go
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,6 @@ func RegisterModules(globals map[string]interface{}, nodes []config.Node) (endpo
return nil, nil, err
}

block := block
module.RegisterInstance(inst, config.NewMap(globals, block))
for _, alias := range modAliases {
if module.HasInstance(alias) {
Expand Down

0 comments on commit dbc030c

Please sign in to comment.