aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/runtime1.go
diff options
context:
space:
mode:
authorMartin Möhrmann <martisch@uos.de>2016-10-30 01:54:19 +0200
committerBrad Fitzpatrick <bradfitz@golang.org>2016-11-01 14:04:39 +0000
commitd7b34d5f29324d77fad572676f0ea139556235e0 (patch)
tree25897e07f5b4624487d4384691ab758571faebff /src/runtime/runtime1.go
parent40aaf283124de44d513ca086976194f0133faa82 (diff)
downloadgo-d7b34d5f29324d77fad572676f0ea139556235e0.tar.xz
runtime: improve atoi implementation
- Adds overflow checks - Adds parsing of negative integers - Adds boolean return value to signal parsing errors - Adds atoi32 for parsing of integers that fit in an int32 - Adds tests Handling of errors to provide error messages at the call sites is left to future CLs. Updates #17718 Change-Id: I3cacd0ab1230b9efc5404c68edae7304d39bcbc0 Reviewed-on: https://go-review.googlesource.com/32390 Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Diffstat (limited to 'src/runtime/runtime1.go')
-rw-r--r--src/runtime/runtime1.go13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/runtime/runtime1.go b/src/runtime/runtime1.go
index 0acb37212e..780e1d907a 100644
--- a/src/runtime/runtime1.go
+++ b/src/runtime/runtime1.go
@@ -375,11 +375,15 @@ func parsedebugvars() {
// is int, not int32, and should only be updated
// if specified in GODEBUG.
if key == "memprofilerate" {
- MemProfileRate = atoi(value)
+ if n, ok := atoi(value); ok {
+ MemProfileRate = n
+ }
} else {
for _, v := range dbgvars {
if v.name == key {
- *v.value = int32(atoi(value))
+ if n, ok := atoi32(value); ok {
+ *v.value = n
+ }
}
}
}
@@ -422,7 +426,10 @@ func setTraceback(level string) {
case "crash":
t = 2<<tracebackShift | tracebackAll | tracebackCrash
default:
- t = uint32(atoi(level))<<tracebackShift | tracebackAll
+ t = tracebackAll
+ if n, ok := atoi(level); ok && n == int(uint32(n)) {
+ t |= uint32(n) << tracebackShift
+ }
}
// when C owns the process, simply exit'ing the process on fatal errors
// and panics is surprising. Be louder and abort instead.