Skip to content

Commit

Permalink
fixed lint warnings
Browse files Browse the repository at this point in the history
2nd attempt to remove useless lint warnings

fix make check
  • Loading branch information
jbsv committed Sep 20, 2022
1 parent 68d6262 commit 4dbe2ec
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/go_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
with:
args: >
-Dsonar.organization=dedis
-Dsonar.projectKey=dedis_debugsync
-Dsonar.projectKey=debugsync
-Dsonar.go.tests.reportPaths=report.json
-Dsonar.go.coverage.reportPaths=profile.cov
env:
Expand Down
4 changes: 1 addition & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ lint:

vet:
@echo "⚠️ Warning: the following only works with go >= 1.14" && \
go get go.dedis.ch/dela/internal/mcheck && \
go install go.dedis.ch/dela/internal/mcheck && \
go vet -vettool=`go env GOPATH`/bin/mcheck -commentLen -ifInit ./...
go vet ./...

# target to run all the possible checks; it's a good habit to run it before
# pushing code
Expand Down
2 changes: 2 additions & 0 deletions mutex_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

// GOMAXPROCS=10 go test

//lint:file-ignore SA2001 Empty critical section is acceptable in the context of a test

package debugsync

import (
Expand Down
18 changes: 9 additions & 9 deletions rwmutex_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ func TestParallelReaders(t *testing.T) {
doTestParallelReaders(4, 2)
}

func reader(rwm *RWMutex, num_iterations int, activity *int32, cdone chan bool) {
for i := 0; i < num_iterations; i++ {
func reader(rwm *RWMutex, numIterations int, activity *int32, cdone chan bool) {
for i := 0; i < numIterations; i++ {
rwm.RLock()
n := atomic.AddInt32(activity, 1)
if n < 1 || n >= 10000 {
Expand All @@ -69,8 +69,8 @@ func reader(rwm *RWMutex, num_iterations int, activity *int32, cdone chan bool)
cdone <- true
}

func writer(rwm *RWMutex, num_iterations int, activity *int32, cdone chan bool) {
for i := 0; i < num_iterations; i++ {
func writer(rwm *RWMutex, numIterations int, activity *int32, cdone chan bool) {
for i := 0; i < numIterations; i++ {
rwm.Lock()
n := atomic.AddInt32(activity, 10000)
if n != 10000 {
Expand All @@ -85,20 +85,20 @@ func writer(rwm *RWMutex, num_iterations int, activity *int32, cdone chan bool)
cdone <- true
}

func HammerRWMutex(gomaxprocs, numReaders, num_iterations int) {
func HammerRWMutex(gomaxprocs, numReaders, numIterations int) {
runtime.GOMAXPROCS(gomaxprocs)
// Number of active readers + 10000 * number of active writers.
var activity int32
var rwm RWMutex
cdone := make(chan bool)
go writer(&rwm, num_iterations, &activity, cdone)
go writer(&rwm, numIterations, &activity, cdone)
var i int
for i = 0; i < numReaders/2; i++ {
go reader(&rwm, num_iterations, &activity, cdone)
go reader(&rwm, numIterations, &activity, cdone)
}
go writer(&rwm, num_iterations, &activity, cdone)
go writer(&rwm, numIterations, &activity, cdone)
for ; i < numReaders; i++ {
go reader(&rwm, num_iterations, &activity, cdone)
go reader(&rwm, numIterations, &activity, cdone)
}
// Wait for the 2 writers and all readers to finish.
for i := 0; i < 2+numReaders; i++ {
Expand Down
4 changes: 1 addition & 3 deletions waitgroup.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package debugsync

import (
"fmt"
"runtime/debug"
"sync"
)
Expand Down Expand Up @@ -35,8 +34,7 @@ func (wg *WaitGroup) Done() {
// Wait blocks until the WaitGroup counter is zero.
func (wg *WaitGroup) Wait() {
if DebugIsOn {
msg := fmt.Sprintf("WaitGroup %v timed out", wg.wg)
waiting := startLockTimer(msg, debug.Stack())
waiting := startLockTimer("WaitGroup timed out", debug.Stack())
wg.wg.Wait()
close(waiting)
} else {
Expand Down
1 change: 0 additions & 1 deletion waitgroup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ func TestWaitGroupRace(t *testing.T) {

func TestWaitGroupAlign(t *testing.T) {
type X struct {
x byte
wg WaitGroup
}
var x X
Expand Down

0 comments on commit 4dbe2ec

Please sign in to comment.