Skip to content

Commit

Permalink
yetus: Remove calls to rand.Seed()
Browse files Browse the repository at this point in the history
Fixes: golangcilint: SA1019: rand.Seed has been deprecated since Go 1.20
and an alternative has been available since Go 1.0: As of Go 1.20 there
is no reason to call Seed with a random value. Programs that call Seed
with a known value to get a specific sequence of results should use
New(NewSource(seed)) to obtain a local random generator. (staticcheck)

Signed-off-by: eriknordmark <erik@zededa.com>
  • Loading branch information
eriknordmark committed Feb 7, 2024
1 parent ad3318a commit 7c282b8
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 10 deletions.
7 changes: 1 addition & 6 deletions pkg/pillar/execlib/execlib.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,7 @@ func New(ps *pubsub.PubSub, log *base.LogObject, agentName string, executor stri
})
pubExecConfig.Unpublish(agentName)

// Start with a random number in case the process as run before
// and used some sequence
now := time.Now()
_, _, seed := now.Clock()
seed += now.Nanosecond()
rand.Seed(int64(seed))
// No need to use rand.Seed() any more
sequence := rand.Int()

handle := ExecuteHandle{
Expand Down
4 changes: 0 additions & 4 deletions pkg/pillar/tgt/tgt.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,6 @@ const (
naaPrefix = "5001405" // from rtslib-fb
)

func init() {
rand.Seed(time.Now().UnixNano())
}

func waitForFile(fileName string) error {
maxDelay := time.Second * 5
delay := time.Millisecond * 500
Expand Down

0 comments on commit 7c282b8

Please sign in to comment.