Skip to content

Commit

Permalink
[disk][process][openbsd] Cast int8 arrays to uint8 arrays to handle d…
Browse files Browse the repository at this point in the history
…ifferent x86/arm (un)signed char types

Ref shirou#993 (comment)
  • Loading branch information
Lomanic committed Feb 23, 2021
1 parent 4b6acd9 commit 85862be
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 4 deletions.
6 changes: 5 additions & 1 deletion disk/disk_openbsd.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,11 @@ func IOCountersWithContext(ctx context.Context, names ...string) (map[string]IOC
if err != nil {
continue
}
name := common.IntToString(d.Name[:])
uint8Name := make([]uint8, len(d.Name))
for i, v := range d.Name {
uint8Name[i] = uint8(v)
}
name := common.UintToString(uint8Name)

if len(names) > 0 && !common.StringsHas(names, name) {
continue
Expand Down
6 changes: 5 additions & 1 deletion process/process_openbsd.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,11 @@ func (p *Process) NameWithContext(ctx context.Context) (string, error) {
if err != nil {
return "", err
}
name := common.IntToString(k.Comm[:])
uint8Name := make([]uint8, len(k.Comm))
for i, v := range k.Comm {
uint8Name[i] = uint8(v)
}
name := common.UintToString(uint8Name)

if len(name) >= 15 {
cmdlineSlice, err := p.CmdlineSliceWithContext(ctx)
Expand Down
6 changes: 5 additions & 1 deletion v3/disk/disk_openbsd.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,11 @@ func IOCountersWithContext(ctx context.Context, names ...string) (map[string]IOC
if err != nil {
continue
}
name := common.IntToString(d.Name[:])
uint8Name := make([]uint8, len(d.Name))
for i, v := range d.Name {
uint8Name[i] = uint8(v)
}
name := common.UintToString(uint8Name)

if len(names) > 0 && !common.StringsHas(names, name) {
continue
Expand Down
6 changes: 5 additions & 1 deletion v3/process/process_openbsd.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,11 @@ func (p *Process) NameWithContext(ctx context.Context) (string, error) {
if err != nil {
return "", err
}
name := common.IntToString(k.Comm[:])
uint8Name := make([]uint8, len(k.Comm))
for i, v := range k.Comm {
uint8Name[i] = uint8(v)
}
name := common.UintToString(uint8Name)

if len(name) >= 15 {
cmdlineSlice, err := p.CmdlineSliceWithContext(ctx)
Expand Down

0 comments on commit 85862be

Please sign in to comment.