From d044f177c36d300840efc5c28c435b35b701280e Mon Sep 17 00:00:00 2001 From: John Mulligan Date: Fri, 24 Jul 2020 09:59:36 -0400 Subject: [PATCH] cephfs: use new SplitSparseBuffer call in ListXattr function Use the newly added SplitSparseBuffer cutil function to break the buffer cephfs returns into a slice of strings with xattr names. Signed-off-by: John Mulligan --- cephfs/file_xattr.go | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/cephfs/file_xattr.go b/cephfs/file_xattr.go index 528f4bf..5509e58 100644 --- a/cephfs/file_xattr.go +++ b/cephfs/file_xattr.go @@ -12,9 +12,9 @@ package cephfs import "C" import ( - "bytes" "unsafe" + "github.com/ceph/go-ceph/internal/cutil" "github.com/ceph/go-ceph/internal/retry" ) @@ -132,13 +132,7 @@ func (f *File) ListXattr() ([]string, error) { return nil, err } - names := make([]string, 0) - for _, s := range bytes.Split(buf[:ret], []byte{0}) { - if len(s) > 0 { - name := C.GoString((*C.char)(unsafe.Pointer(&s[0]))) - names = append(names, name) - } - } + names := cutil.SplitSparseBuffer(buf[:ret]) return names, nil }