Skip to content

redundant-atomic-result-assignment

Detect non-atomic operations on atomic values.

Updated View as Markdown

Default severity: error

Reports an atomic update whose returned value is assigned back to the same variable. The assignment performs a second, non-atomic write and defeats the purpose of the atomic operation.

Bad

counter = atomic.AddInt64(&counter, 1)

Good

atomic.AddInt64(&counter, 1)
Navigation

Type to search…

↑↓ navigate↵ selectEsc close