mirror of
https://github.com/mjl-/mox.git
synced 2025-06-28 01:48:15 +03:00
fix warnings by ineffassign, with a one actual issue
In store/search.go, we would make a copy of a byte array, but then still use the original instead of the copy. Could result in search operations not finding messages that do have the content, but under very unlikely conditions only. We'll keep running ineffassign with "make check", useful enough.
This commit is contained in:
parent
04b1f030b7
commit
15a8ce8c0b
4
Makefile
4
Makefile
@ -42,6 +42,9 @@ test-upgrade: build
|
|||||||
install-staticcheck:
|
install-staticcheck:
|
||||||
CGO_ENABLED=0 go install honnef.co/go/tools/cmd/staticcheck@latest
|
CGO_ENABLED=0 go install honnef.co/go/tools/cmd/staticcheck@latest
|
||||||
|
|
||||||
|
install-ineffassign:
|
||||||
|
CGO_ENABLED=0 go install github.com/gordonklaus/ineffassign@v0.1.0
|
||||||
|
|
||||||
check:
|
check:
|
||||||
CGO_ENABLED=0 go vet -tags integration
|
CGO_ENABLED=0 go vet -tags integration
|
||||||
CGO_ENABLED=0 go vet -tags website website/website.go
|
CGO_ENABLED=0 go vet -tags website website/website.go
|
||||||
@ -55,6 +58,7 @@ check:
|
|||||||
CGO_ENABLED=0 staticcheck -tags link rfc/link.go
|
CGO_ENABLED=0 staticcheck -tags link rfc/link.go
|
||||||
CGO_ENABLED=0 staticcheck -tags errata rfc/errata.go
|
CGO_ENABLED=0 staticcheck -tags errata rfc/errata.go
|
||||||
CGO_ENABLED=0 staticcheck -tags xr rfc/xr.go
|
CGO_ENABLED=0 staticcheck -tags xr rfc/xr.go
|
||||||
|
CGO_ENABLED=0 ineffassign ./...
|
||||||
|
|
||||||
# needed for check-shadow
|
# needed for check-shadow
|
||||||
install-shadow:
|
install-shadow:
|
||||||
|
@ -512,7 +512,6 @@ func backupctl(ctx context.Context, ctl *ctl) {
|
|||||||
backupDB(db, jfpath)
|
backupDB(db, jfpath)
|
||||||
bloompath := filepath.Join("accounts", acc.Name, "junkfilter.bloom")
|
bloompath := filepath.Join("accounts", acc.Name, "junkfilter.bloom")
|
||||||
backupFile(bloompath)
|
backupFile(bloompath)
|
||||||
db = nil
|
|
||||||
err := jf.Close()
|
err := jf.Close()
|
||||||
ctl.log.Check(err, "closing junkfilter")
|
ctl.log.Check(err, "closing junkfilter")
|
||||||
}
|
}
|
||||||
|
11
develop.txt
11
develop.txt
@ -13,11 +13,12 @@ code paths are reachable/testable with mox localserve, but some use cases will
|
|||||||
require a full setup.
|
require a full setup.
|
||||||
|
|
||||||
Before committing, run at least "make fmt" and "make check" (which requires
|
Before committing, run at least "make fmt" and "make check" (which requires
|
||||||
staticcheck, run "make install-staticcheck" once). Also run "make check-shadow"
|
staticcheck and ineffassign, run "make install-staticcheck install-ineffassign"
|
||||||
and fix any shadowed variables other than "err" (which are filtered out, but
|
once). Also run "make check-shadow" and fix any shadowed variables other than
|
||||||
causes the command to always exit with an error code; run "make install-shadow"
|
"err" (which are filtered out, but causes the command to always exit with an
|
||||||
once to install the shadow command). If you've updated RFC references, run
|
error code; run "make install-shadow" once to install the shadow command). If
|
||||||
"make" in rfc/, it verifies the referenced files exist.
|
you've updated RFC references, run "make" in rfc/, it verifies the referenced
|
||||||
|
files exist.
|
||||||
|
|
||||||
When making changes to the public API of a package listed in
|
When making changes to the public API of a package listed in
|
||||||
apidiff/packages.txt, run "make genapidiff" to update the list of changes in
|
apidiff/packages.txt, run "make genapidiff" to update the list of changes in
|
||||||
|
4
main.go
4
main.go
@ -1960,11 +1960,12 @@ sharing most of its code.
|
|||||||
|
|
||||||
resolver := dns.StrictResolver{}
|
resolver := dns.StrictResolver{}
|
||||||
var haveMX bool
|
var haveMX bool
|
||||||
var origNextHopAuthentic, expandedNextHopAuthentic bool
|
var expandedNextHopAuthentic bool
|
||||||
var expandedNextHop dns.Domain
|
var expandedNextHop dns.Domain
|
||||||
var hosts []dns.IPDomain
|
var hosts []dns.IPDomain
|
||||||
if len(args) == 1 {
|
if len(args) == 1 {
|
||||||
var permanent bool
|
var permanent bool
|
||||||
|
var origNextHopAuthentic bool
|
||||||
var err error
|
var err error
|
||||||
haveMX, origNextHopAuthentic, expandedNextHopAuthentic, expandedNextHop, hosts, permanent, err = smtpclient.GatherDestinations(ctxbg, c.log.Logger, resolver, dns.IPDomain{Domain: origNextHop})
|
haveMX, origNextHopAuthentic, expandedNextHopAuthentic, expandedNextHop, hosts, permanent, err = smtpclient.GatherDestinations(ctxbg, c.log.Logger, resolver, dns.IPDomain{Domain: origNextHop})
|
||||||
status := "temporary"
|
status := "temporary"
|
||||||
@ -1998,7 +1999,6 @@ sharing most of its code.
|
|||||||
d := xparseDomain(args[1], "destination host")
|
d := xparseDomain(args[1], "destination host")
|
||||||
log.Printf("skipping domain mx/cname lookups, assuming domain is dnssec-protected")
|
log.Printf("skipping domain mx/cname lookups, assuming domain is dnssec-protected")
|
||||||
|
|
||||||
origNextHopAuthentic = true
|
|
||||||
expandedNextHopAuthentic = true
|
expandedNextHopAuthentic = true
|
||||||
expandedNextHop = d
|
expandedNextHop = d
|
||||||
hosts = []dns.IPDomain{{Domain: d}}
|
hosts = []dns.IPDomain{{Domain: d}}
|
||||||
|
@ -656,7 +656,6 @@ func TestHookListFilterSort(t *testing.T) {
|
|||||||
var lr []HookRetired
|
var lr []HookRetired
|
||||||
lastID = 0
|
lastID = 0
|
||||||
last = ""
|
last = ""
|
||||||
l = nil
|
|
||||||
for {
|
for {
|
||||||
nl, err := HookRetiredList(ctxbg, HookRetiredFilter{Max: 1}, HookRetiredSort{LastID: lastID, Last: last})
|
nl, err := HookRetiredList(ctxbg, HookRetiredFilter{Max: 1}, HookRetiredSort{LastID: lastID, Last: last})
|
||||||
tcheck(t, err, "list paginated")
|
tcheck(t, err, "list paginated")
|
||||||
|
@ -1435,7 +1435,6 @@ func TestListFilterSort(t *testing.T) {
|
|||||||
var lr []MsgRetired
|
var lr []MsgRetired
|
||||||
lastID = 0
|
lastID = 0
|
||||||
last = ""
|
last = ""
|
||||||
l = nil
|
|
||||||
for {
|
for {
|
||||||
nl, err := RetiredList(ctxbg, RetiredFilter{Max: 1}, RetiredSort{LastID: lastID, Last: last})
|
nl, err := RetiredList(ctxbg, RetiredFilter{Max: 1}, RetiredSort{LastID: lastID, Last: last})
|
||||||
tcheck(t, err, "list paginated")
|
tcheck(t, err, "list paginated")
|
||||||
|
@ -3424,18 +3424,16 @@ func (c *conn) deliver(ctx context.Context, recvHdrFor func(string) string, msgW
|
|||||||
return fmt.Errorf("finding rejects mailbox: %v", err)
|
return fmt.Errorf("finding rejects mailbox: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
hasSpace := true
|
|
||||||
if !conf.KeepRejects && mbrej != nil {
|
if !conf.KeepRejects && mbrej != nil {
|
||||||
var chl []store.Change
|
chl, hasSpace, err := a.d.acc.TidyRejectsMailbox(c.log, tx, mbrej)
|
||||||
chl, hasSpace, err = a.d.acc.TidyRejectsMailbox(c.log, tx, mbrej)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("tidying rejects mailbox: %v", err)
|
return fmt.Errorf("tidying rejects mailbox: %v", err)
|
||||||
}
|
}
|
||||||
|
changes = append(changes, chl...)
|
||||||
if !hasSpace {
|
if !hasSpace {
|
||||||
log.Info("not storing spammy mail to full rejects mailbox")
|
log.Info("not storing spammy mail to full rejects mailbox")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
changes = append(changes, chl...)
|
|
||||||
}
|
}
|
||||||
if mbrej == nil {
|
if mbrej == nil {
|
||||||
nmb, chl, _, _, err := a.d.acc.MailboxCreate(tx, conf.RejectsMailbox, store.SpecialUse{})
|
nmb, chl, _, _, err := a.d.acc.MailboxCreate(tx, conf.RejectsMailbox, store.SpecialUse{})
|
||||||
|
@ -187,7 +187,7 @@ func toLower(buf []byte) []byte {
|
|||||||
copied = true
|
copied = true
|
||||||
nr := make([]byte, len(r), len(r)+nsize+len(buf)-i)
|
nr := make([]byte, len(r), len(r)+nsize+len(buf)-i)
|
||||||
copy(nr, r)
|
copy(nr, r)
|
||||||
nr = r
|
r = nr
|
||||||
}
|
}
|
||||||
r = utf8.AppendRune(r, nc)
|
r = utf8.AppendRune(r, nc)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user