Commit 06f138a6 authored by xialong.lee's avatar xialong.lee

mention overflows when mistakenly call function FromInt

parent 68a7c2c6
...@@ -21,6 +21,7 @@ go_library( ...@@ -21,6 +21,7 @@ go_library(
"//pkg/genericapiserver/openapi/common:go_default_library", "//pkg/genericapiserver/openapi/common:go_default_library",
"//vendor:github.com/go-openapi/spec", "//vendor:github.com/go-openapi/spec",
"//vendor:github.com/gogo/protobuf/proto", "//vendor:github.com/gogo/protobuf/proto",
"//vendor:github.com/golang/glog",
"//vendor:github.com/google/gofuzz", "//vendor:github.com/google/gofuzz",
], ],
) )
......
...@@ -20,12 +20,14 @@ import ( ...@@ -20,12 +20,14 @@ import (
"encoding/json" "encoding/json"
"fmt" "fmt"
"math" "math"
"runtime/debug"
"strconv" "strconv"
"strings" "strings"
"k8s.io/kubernetes/pkg/genericapiserver/openapi/common" "k8s.io/kubernetes/pkg/genericapiserver/openapi/common"
"github.com/go-openapi/spec" "github.com/go-openapi/spec"
"github.com/golang/glog"
"github.com/google/gofuzz" "github.com/google/gofuzz"
) )
...@@ -57,6 +59,9 @@ const ( ...@@ -57,6 +59,9 @@ const (
// than int32. // than int32.
// TODO: convert to (val int32) // TODO: convert to (val int32)
func FromInt(val int) IntOrString { func FromInt(val int) IntOrString {
if val > math.MaxInt32 || val < math.MinInt32 {
glog.Errorf("value: %d overflows int32\n%s\n", val, debug.Stack())
}
return IntOrString{Type: Int, IntVal: int32(val)} return IntOrString{Type: Int, IntVal: int32(val)}
} }
......
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