Commit 83801418 authored by Tobias Klauser's avatar Tobias Klauser Committed by Tobias Klauser

unix: simplify error handling in *listxattr on FreeBSD

The var e error declaration is shadowed inside the for loop, so the
outer e always stays nil. Also, there is no need to reset the inner e in
case of EPERM, as it is reset by ExattrList* on the next iteration
anyhow.

Change-Id: Ib395e34b5a390a5d37bee334c44f6f87d3add2a0
Reviewed-on: https://go-review.googlesource.com/85295
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: 's avatarIan Lance Taylor <iant@golang.org>
parent df29b912
......@@ -293,7 +293,6 @@ func Listxattr(file string, dest []byte) (sz int, err error) {
// FreeBSD won't allow you to list xattrs from multiple namespaces
s := 0
var e error
for _, nsid := range [...]int{EXTATTR_NAMESPACE_USER, EXTATTR_NAMESPACE_SYSTEM} {
stmp, e := ExtattrListFile(file, nsid, uintptr(d), destsiz)
......@@ -305,7 +304,6 @@ func Listxattr(file string, dest []byte) (sz int, err error) {
* we don't have read permissions on, so don't ignore those errors
*/
if e != nil && e == EPERM && nsid != EXTATTR_NAMESPACE_USER {
e = nil
continue
} else if e != nil {
return s, e
......@@ -319,7 +317,7 @@ func Listxattr(file string, dest []byte) (sz int, err error) {
d = initxattrdest(dest, s)
}
return s, e
return s, nil
}
func Flistxattr(fd int, dest []byte) (sz int, err error) {
......@@ -327,11 +325,9 @@ func Flistxattr(fd int, dest []byte) (sz int, err error) {
destsiz := len(dest)
s := 0
var e error
for _, nsid := range [...]int{EXTATTR_NAMESPACE_USER, EXTATTR_NAMESPACE_SYSTEM} {
stmp, e := ExtattrListFd(fd, nsid, uintptr(d), destsiz)
if e != nil && e == EPERM && nsid != EXTATTR_NAMESPACE_USER {
e = nil
continue
} else if e != nil {
return s, e
......@@ -345,7 +341,7 @@ func Flistxattr(fd int, dest []byte) (sz int, err error) {
d = initxattrdest(dest, s)
}
return s, e
return s, nil
}
func Llistxattr(link string, dest []byte) (sz int, err error) {
......@@ -353,11 +349,9 @@ func Llistxattr(link string, dest []byte) (sz int, err error) {
destsiz := len(dest)
s := 0
var e error
for _, nsid := range [...]int{EXTATTR_NAMESPACE_USER, EXTATTR_NAMESPACE_SYSTEM} {
stmp, e := ExtattrListLink(link, nsid, uintptr(d), destsiz)
if e != nil && e == EPERM && nsid != EXTATTR_NAMESPACE_USER {
e = nil
continue
} else if e != nil {
return s, e
......@@ -371,7 +365,7 @@ func Llistxattr(link string, dest []byte) (sz int, err error) {
d = initxattrdest(dest, s)
}
return s, e
return s, nil
}
//sys ioctl(fd int, req uint, arg uintptr) (err error)
......
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