Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🧹 🐛 fix some warnings, go-ole on mac os #2280

Merged
merged 2 commits into from Jan 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -1,5 +1,5 @@
//go:build 386
// +build 386
//go:build 386 || arm
// +build 386 arm

package ole

Expand Down
@@ -1,5 +1,5 @@
//go:build amd64
// +build amd64
//go:build amd64 || arm64 || ppc64le || s390x
// +build amd64 arm64 ppc64le s390x

package ole

Expand Down
13 changes: 0 additions & 13 deletions internal/go-ole/variant_ppc64le.go

This file was deleted.

13 changes: 0 additions & 13 deletions internal/go-ole/variant_s390x.go

This file was deleted.

3 changes: 1 addition & 2 deletions internal/gopsutil/common/common_unix.go
Expand Up @@ -42,8 +42,7 @@ func CallLsofWithContext(ctx context.Context, invoke Invoker, pid int32, args ..
}

func CallPgrepWithContext(ctx context.Context, invoke Invoker, pid int32) ([]int32, error) {
var cmd []string
cmd = []string{"-P", strconv.Itoa(int(pid))}
cmd := []string{"-P", strconv.Itoa(int(pid))}
pgrep, err := exec.LookPath("pgrep")
if err != nil {
return []int32{}, err
Expand Down
2 changes: 1 addition & 1 deletion internal/gopsutil/mem/mem.go
Expand Up @@ -6,7 +6,7 @@ import (
"github.com/gofiber/fiber/v2/internal/gopsutil/common"
)

var invoke common.Invoker = common.Invoke{}
var _ common.Invoke

// Memory usage statistics. Total, Available and Used contain numbers of bytes
// for human consumption.
Expand Down
2 changes: 1 addition & 1 deletion internal/gopsutil/net/net.go
Expand Up @@ -125,7 +125,7 @@ func (l *ConntrackStatList) Append(c *ConntrackStat) {
}

func (l *ConntrackStatList) Items() []ConntrackStat {
items := make([]ConntrackStat, len(l.items), len(l.items))
items := make([]ConntrackStat, len(l.items))
for i, el := range l.items {
items[i] = *el
}
Expand Down
2 changes: 1 addition & 1 deletion internal/gopsutil/net/net_darwin.go
Expand Up @@ -251,7 +251,7 @@ func IOCountersWithContext(ctx context.Context, pernic bool) ([]IOCountersStat,
}
}

if pernic == false {
if !pernic {
return getIOCountersAll(ret)
}
return ret, nil
Expand Down
4 changes: 2 additions & 2 deletions internal/gopsutil/process/process.go
Expand Up @@ -164,8 +164,8 @@ func NewProcess(pid int32) (*Process, error) {
if !exists {
return p, ErrorProcessNotRunning
}
p.CreateTime()
return p, nil
_, err = p.CreateTime()
return p, err
}

func PidExists(pid int32) (bool, error) {
Expand Down
7 changes: 3 additions & 4 deletions internal/gopsutil/process/process_darwin.go
Expand Up @@ -417,9 +417,9 @@ func convertCPUTimes(s string) (ret float64, err error) {
if err != nil {
return ret, err
}
h, err := strconv.Atoi(_t[0])
h, _ := strconv.Atoi(_t[0])
t += h * ClockTicks
h, err = strconv.Atoi(_t[1])
h, _ = strconv.Atoi(_t[1])
t += h
return float64(t) / ClockTicks, nil
}
Expand Down Expand Up @@ -608,8 +608,7 @@ func (p *Process) getKProc() (*KinfoProc, error) {

func (p *Process) getKProcWithContext(ctx context.Context) (*KinfoProc, error) {
mib := []int32{CTLKern, KernProc, KernProcPID, p.Pid}
procK := KinfoProc{}
length := uint64(unsafe.Sizeof(procK))
length := uint64(unsafe.Sizeof(KinfoProc{}))
buf := make([]byte, length)
_, _, syserr := unix.Syscall6(
202, // unix.SYS___SYSCTL https://github.com/golang/sys/blob/76b94024e4b621e672466e8db3d7f084e7ddcad2/unix/zsysnum_darwin_amd64.go#L146
Expand Down
37 changes: 17 additions & 20 deletions internal/memory/memory.go
Expand Up @@ -73,28 +73,25 @@ func (s *Storage) gc(sleep time.Duration) {
defer ticker.Stop()
var expired []string

for {
select {
case <-ticker.C:
ts := atomic.LoadUint32(&utils.Timestamp)
expired = expired[:0]
s.RLock()
for key, v := range s.data {
if v.e != 0 && v.e <= ts {
expired = append(expired, key)
}
for range ticker.C {
ts := atomic.LoadUint32(&utils.Timestamp)
expired = expired[:0]
s.RLock()
for key, v := range s.data {
if v.e != 0 && v.e <= ts {
expired = append(expired, key)
}
s.RUnlock()
s.Lock()
// Double-checked locking.
// We might have replaced the item in the meantime.
for i := range expired {
v := s.data[expired[i]]
if v.e != 0 && v.e <= ts {
delete(s.data, expired[i])
}
}
s.RUnlock()
s.Lock()
// Double-checked locking.
// We might have replaced the item in the meantime.
for i := range expired {
v := s.data[expired[i]]
if v.e != 0 && v.e <= ts {
delete(s.data, expired[i])
}
s.Unlock()
}
s.Unlock()
}
}
16 changes: 8 additions & 8 deletions internal/msgp/elsize.go
Expand Up @@ -83,14 +83,14 @@ type bytespec struct {
type varmode int8

const (
constsize varmode = 0 // constant size (size bytes + uint8(varmode) objects)
extra8 = -1 // has uint8(p[1]) extra bytes
extra16 = -2 // has be16(p[1:]) extra bytes
extra32 = -3 // has be32(p[1:]) extra bytes
map16v = -4 // use map16
map32v = -5 // use map32
array16v = -6 // use array16
array32v = -7 // use array32
constsize varmode = -iota // constant size (size bytes + uint8(varmode) objects)
extra8 // has uint8(p[1]) extra bytes
extra16 // has be16(p[1:]) extra bytes
extra32 // has be32(p[1:]) extra bytes
map16v // use map16
map32v // use map32
array16v // use array16
array32v // use array32
)

func getType(v byte) Type {
Expand Down
4 changes: 3 additions & 1 deletion internal/msgp/write.go
Expand Up @@ -778,7 +778,9 @@ func (mw *Writer) writeVal(v reflect.Value) error {

case reflect.Interface, reflect.Ptr:
if v.IsNil() {
mw.WriteNil()
if err := mw.WriteNil(); err != nil {
return err
}
}
return mw.writeVal(v.Elem())

Expand Down
4 changes: 2 additions & 2 deletions internal/schema/encoder.go
Expand Up @@ -94,7 +94,7 @@ func (e *Encoder) encode(v reflect.Value, dst map[string][]string) error {

// Encode struct pointer types if the field is a valid pointer and a struct.
if isValidStructPointer(v.Field(i)) {
e.encode(v.Field(i).Elem(), dst)
_ = e.encode(v.Field(i).Elem(), dst)
continue
}

Expand All @@ -112,7 +112,7 @@ func (e *Encoder) encode(v reflect.Value, dst map[string][]string) error {
}

if v.Field(i).Type().Kind() == reflect.Struct {
e.encode(v.Field(i), dst)
_ = e.encode(v.Field(i), dst)
continue
}

Expand Down