Skip to content

Commit

Permalink
runtime: remove always false comparison in sigsend
Browse files Browse the repository at this point in the history
s is a uint32 and can never be zero. It's max value is already tested
against sig.wanted, whose size is derived from _NSIG.  This also
matches the test in signal_enable.

Fixes golang#11282

Change-Id: I8eec9c7df8eb8682433616462fe51b264c092475
Reviewed-on: https://go-review.googlesource.com/13940
Reviewed-by: Ian Lance Taylor <[email protected]>
Run-TryBot: Ian Lance Taylor <[email protected]>
TryBot-Result: Gobot Gobot <[email protected]>
  • Loading branch information
tzneal authored and ianlancetaylor committed Aug 26, 2015
1 parent af78482 commit a94e906
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/runtime/sigqueue.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ const (
// Reports whether the signal was sent. If not, the caller typically crashes the program.
func sigsend(s uint32) bool {
bit := uint32(1) << uint(s&31)
if !sig.inuse || s < 0 || int(s) >= 32*len(sig.wanted) || sig.wanted[s/32]&bit == 0 {
if !sig.inuse || s >= uint32(32*len(sig.wanted)) || sig.wanted[s/32]&bit == 0 {
return false
}

Expand Down Expand Up @@ -137,7 +137,7 @@ func signal_enable(s uint32) {
return
}

if int(s) >= len(sig.wanted)*32 {
if s >= uint32(len(sig.wanted)*32) {
return
}
sig.wanted[s/32] |= 1 << (s & 31)
Expand All @@ -146,7 +146,7 @@ func signal_enable(s uint32) {

// Must only be called from a single goroutine at a time.
func signal_disable(s uint32) {
if int(s) >= len(sig.wanted)*32 {
if s >= uint32(len(sig.wanted)*32) {
return
}
sig.wanted[s/32] &^= 1 << (s & 31)
Expand All @@ -155,7 +155,7 @@ func signal_disable(s uint32) {

// Must only be called from a single goroutine at a time.
func signal_ignore(s uint32) {
if int(s) >= len(sig.wanted)*32 {
if s >= uint32(len(sig.wanted)*32) {
return
}
sig.wanted[s/32] &^= 1 << (s & 31)
Expand Down

0 comments on commit a94e906

Please sign in to comment.