Commit a94e906c authored by Todd Neal's avatar Todd Neal Committed by Ian Lance Taylor

runtime: remove always false comparison in sigsend

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 #11282

Change-Id: I8eec9c7df8eb8682433616462fe51b264c092475
Reviewed-on: https://go-review.googlesource.com/13940Reviewed-by: default avatarIan Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
parent af78482d
...@@ -49,7 +49,7 @@ const ( ...@@ -49,7 +49,7 @@ const (
// Reports whether the signal was sent. If not, the caller typically crashes the program. // Reports whether the signal was sent. If not, the caller typically crashes the program.
func sigsend(s uint32) bool { func sigsend(s uint32) bool {
bit := uint32(1) << uint(s&31) 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 return false
} }
...@@ -137,7 +137,7 @@ func signal_enable(s uint32) { ...@@ -137,7 +137,7 @@ func signal_enable(s uint32) {
return return
} }
if int(s) >= len(sig.wanted)*32 { if s >= uint32(len(sig.wanted)*32) {
return return
} }
sig.wanted[s/32] |= 1 << (s & 31) sig.wanted[s/32] |= 1 << (s & 31)
...@@ -146,7 +146,7 @@ func signal_enable(s uint32) { ...@@ -146,7 +146,7 @@ func signal_enable(s uint32) {
// Must only be called from a single goroutine at a time. // Must only be called from a single goroutine at a time.
func signal_disable(s uint32) { func signal_disable(s uint32) {
if int(s) >= len(sig.wanted)*32 { if s >= uint32(len(sig.wanted)*32) {
return return
} }
sig.wanted[s/32] &^= 1 << (s & 31) sig.wanted[s/32] &^= 1 << (s & 31)
...@@ -155,7 +155,7 @@ func signal_disable(s uint32) { ...@@ -155,7 +155,7 @@ func signal_disable(s uint32) {
// Must only be called from a single goroutine at a time. // Must only be called from a single goroutine at a time.
func signal_ignore(s uint32) { func signal_ignore(s uint32) {
if int(s) >= len(sig.wanted)*32 { if s >= uint32(len(sig.wanted)*32) {
return return
} }
sig.wanted[s/32] &^= 1 << (s & 31) sig.wanted[s/32] &^= 1 << (s & 31)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment