             var data: Data = Data(count: length)
 
             // Retrieve attribute
-                getxattr(fileSystemPath, name, $0, length, 0, 0)
-            let result: Int = data.withUnsafeMutableBytes {
+            let result: Int = data.withUnsafeMutableBytes { [count = data.count] (body: UnsafeMutableRawBufferPointer) -> Int in
+                getxattr(fileSystemPath, name, body.baseAddress, count, 0, 0)
             }
             guard result >= 0 else { throw URL.posixError(errno) }
             return data

            var data: Data = Data(count: length)

            // Retrieve attribute list
                listxattr(fileSystemPath, $0, length, 0)
            let result: Int = data.withUnsafeMutableBytes {
            }
            guard result >= 0 else { throw URL.posixError(errno) }


    /// Set extended attribute.
    func setExtendedAttribute(data: Data, forName name: String) throws {
        try self.withUnsafeFileSystemRepresentation { fileSystemPath in
            let result: Int32 = data.withUnsafeBytes { [count = data.count] (body: UnsafeRawBufferPointer) -> Int32 in
                setxattr(fileSystemPath, name, body.baseAddress, count, 0, 0)
            }
            guard result >= 0 else { throw URL.posixError(errno) }
        }
