зеркало из https://github.com/microsoft/docker.git
Move charsToString to architecture dependent source to fix casting problem
Signed-off-by: Stefan Scherer <scherer_stefan@icloud.com>
This commit is contained in:
Родитель
877fe61f75
Коммит
7c1d49d90c
|
@ -14,15 +14,3 @@ func GetRuntimeArchitecture() (string, error) {
|
|||
}
|
||||
return charsToString(utsname.Machine), nil
|
||||
}
|
||||
|
||||
func charsToString(ca [65]int8) string {
|
||||
s := make([]byte, len(ca))
|
||||
var lens int
|
||||
for ; lens < len(ca); lens++ {
|
||||
if ca[lens] == 0 {
|
||||
break
|
||||
}
|
||||
s[lens] = uint8(ca[lens])
|
||||
}
|
||||
return string(s[0:lens])
|
||||
}
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
// +build linux,386 linux,amd64 linux,arm64
|
||||
// see golang's sources src/syscall/ztypes_linux_*.go that use int8
|
||||
|
||||
package platform
|
||||
|
||||
// Convert the OS/ARCH-specific utsname.Machine to string
|
||||
// given as an array of signed int8
|
||||
func charsToString(ca [65]int8) string {
|
||||
s := make([]byte, len(ca))
|
||||
var lens int
|
||||
for ; lens < len(ca); lens++ {
|
||||
if ca[lens] == 0 {
|
||||
break
|
||||
}
|
||||
s[lens] = uint8(ca[lens])
|
||||
}
|
||||
return string(s[0:lens])
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
// +build linux,arm linux,ppc64 linux,ppc64le s390x
|
||||
// see golang's sources src/syscall/ztypes_linux_*.go that use uint8
|
||||
|
||||
package platform
|
||||
|
||||
// Convert the OS/ARCH-specific utsname.Machine to string
|
||||
// given as an array of unsigned uint8
|
||||
func charsToString(ca [65]uint8) string {
|
||||
s := make([]byte, len(ca))
|
||||
var lens int
|
||||
for ; lens < len(ca); lens++ {
|
||||
if ca[lens] == 0 {
|
||||
break
|
||||
}
|
||||
s[lens] = ca[lens]
|
||||
}
|
||||
return string(s[0:lens])
|
||||
}
|
Загрузка…
Ссылка в новой задаче