"sync/atomic"
"unsafe"
- "git.fd.io/govpp.git/adapter"
+ "go.fd.io/govpp/adapter"
)
type statSegmentV2 struct {
return ss.adjust(dirVector(&header.dirVector))
}
-func (ss *statSegmentV2) GetStatDirOnIndex(v dirVector, index uint32) (dirSegment, dirName, dirType) {
+func (ss *statSegmentV2) GetStatDirOnIndex(v dirVector, index uint32) (dirSegment, dirName, adapter.StatType) {
statSegDir := dirSegment(uintptr(v) + uintptr(index)*unsafe.Sizeof(statSegDirectoryEntryV2{}))
dir := (*statSegDirectoryEntryV2)(statSegDir)
var name []byte
break
}
}
- return statSegDir, name, dir.directoryType
+ return statSegDir, name, getStatType(dir.directoryType, ss.getErrorVector() != nil)
}
func (ss *statSegmentV2) GetEpoch() (int64, bool) {
func (ss *statSegmentV2) CopyEntryData(segment dirSegment, index uint32) adapter.Stat {
dirEntry := (*statSegDirectoryEntryV2)(segment)
- if dirEntry.unionData == 0 {
- debugf("data value or pointer not defined for %s", dirEntry.name)
+ typ := getStatType(dirEntry.directoryType, ss.getErrorVector() != nil)
+ // skip zero pointer value
+ if typ != adapter.ScalarIndex && typ != adapter.Empty && typ != adapter.ErrorIndex && dirEntry.unionData == 0 {
+ debugf("data pointer not defined for %s", dirEntry.name)
return nil
}
- switch adapter.StatType(dirEntry.directoryType) {
- case statDirScalarIndex:
+ switch typ {
+ case adapter.ScalarIndex:
return adapter.ScalarStat(dirEntry.unionData)
- case statDirErrorIndex:
+ case adapter.ErrorIndex:
dirVector := ss.getErrorVector()
if dirVector == nil {
debugf("error vector pointer is out of range for %s", dirEntry.name)
}
return adapter.ErrorStat(errData)
- case statDirCounterVectorSimple:
+ case adapter.SimpleCounterVector:
dirVector := ss.adjust(dirVector(&dirEntry.unionData))
if dirVector == nil {
debugf("data vector pointer is out of range for %s", dirEntry.name)
}
return adapter.SimpleCounterStat(data)
- case statDirCounterVectorCombined:
+ case adapter.CombinedCounterVector:
dirVector := ss.adjust(dirVector(&dirEntry.unionData))
if dirVector == nil {
debugf("data vector pointer is out of range for %s", dirEntry.name)
}
return adapter.CombinedCounterStat(data)
- case statDirNameVector:
+ case adapter.NameVector:
dirVector := ss.adjust(dirVector(&dirEntry.unionData))
if dirVector == nil {
debugf("data vector pointer is out of range for %s", dirEntry.name)
}
return adapter.NameStat(data)
- case statDirEmpty:
+ case adapter.Empty:
return adapter.EmptyStat("<none>")
// no-op
- case statDirSymlink:
+ case adapter.Symlink:
// prevent recursion loops
if index != ^uint32(0) {
debugf("received symlink with defined item index")