mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[gardening] Remove accidental trailing whitespace (" " and "\t")
This commit is contained in:
@@ -82,7 +82,7 @@ public struct DispatchData : RandomAccessCollection, _ObjectiveCBridgeable {
|
||||
}
|
||||
|
||||
public func enumerateBytes(
|
||||
block: (_ buffer: UnsafeBufferPointer<UInt8>, _ byteIndex: Int, _ stop: inout Bool) -> Void)
|
||||
block: (_ buffer: UnsafeBufferPointer<UInt8>, _ byteIndex: Int, _ stop: inout Bool) -> Void)
|
||||
{
|
||||
_swift_dispatch_data_apply(__wrapped) { (_, offset: Int, ptr: UnsafeRawPointer, size: Int) in
|
||||
let bytePtr = ptr.bindMemory(to: UInt8.self, capacity: size)
|
||||
@@ -137,7 +137,7 @@ public struct DispatchData : RandomAccessCollection, _ObjectiveCBridgeable {
|
||||
public func copyBytes(to pointer: UnsafeMutablePointer<UInt8>, count: Int) {
|
||||
_copyBytesHelper(to: pointer, from: 0..<count)
|
||||
}
|
||||
|
||||
|
||||
/// Copy a subset of the contents of the data to a pointer.
|
||||
///
|
||||
/// - parameter pointer: A pointer to the buffer you wish to copy the bytes into.
|
||||
@@ -146,7 +146,7 @@ public struct DispatchData : RandomAccessCollection, _ObjectiveCBridgeable {
|
||||
public func copyBytes(to pointer: UnsafeMutablePointer<UInt8>, from range: CountableRange<Index>) {
|
||||
_copyBytesHelper(to: pointer, from: range)
|
||||
}
|
||||
|
||||
|
||||
/// Copy the contents of the data into a buffer.
|
||||
///
|
||||
/// This function copies the bytes in `range` from the data into the buffer. If the count of the `range` is greater than `MemoryLayout<DestinationType>.stride * buffer.count` then the first N bytes will be copied into the buffer.
|
||||
@@ -157,23 +157,23 @@ public struct DispatchData : RandomAccessCollection, _ObjectiveCBridgeable {
|
||||
public func copyBytes<DestinationType>(to buffer: UnsafeMutableBufferPointer<DestinationType>, from range: CountableRange<Index>? = nil) -> Int {
|
||||
let cnt = count
|
||||
guard cnt > 0 else { return 0 }
|
||||
|
||||
|
||||
let copyRange : CountableRange<Index>
|
||||
if let r = range {
|
||||
guard !r.isEmpty else { return 0 }
|
||||
precondition(r.startIndex >= 0)
|
||||
precondition(r.startIndex < cnt, "The range is outside the bounds of the data")
|
||||
|
||||
|
||||
precondition(r.endIndex >= 0)
|
||||
precondition(r.endIndex <= cnt, "The range is outside the bounds of the data")
|
||||
|
||||
|
||||
copyRange = r.startIndex..<(r.startIndex + Swift.min(buffer.count * MemoryLayout<DestinationType>.stride, r.count))
|
||||
} else {
|
||||
copyRange = 0..<Swift.min(buffer.count * MemoryLayout<DestinationType>.stride, cnt)
|
||||
}
|
||||
|
||||
|
||||
guard !copyRange.isEmpty else { return 0 }
|
||||
|
||||
|
||||
_copyBytesHelper(to: buffer.baseAddress!, from: copyRange)
|
||||
return copyRange.count
|
||||
}
|
||||
|
||||
@@ -95,7 +95,7 @@ public extension DispatchQueue {
|
||||
internal func _attr(attr: __OS_dispatch_queue_attr?) -> __OS_dispatch_queue_attr? {
|
||||
if #available(OSX 10.12, iOS 10.0, tvOS 10.0, watchOS 3.0, *) {
|
||||
switch self {
|
||||
case .inherit:
|
||||
case .inherit:
|
||||
// DISPATCH_AUTORELEASE_FREQUENCY_INHERIT
|
||||
return __dispatch_queue_attr_make_with_autorelease_frequency(attr, __dispatch_autorelease_frequency_t(0))
|
||||
case .workItem:
|
||||
@@ -142,7 +142,7 @@ public extension DispatchQueue {
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
public convenience init(
|
||||
label: String,
|
||||
qos: DispatchQoS = .unspecified,
|
||||
@@ -151,8 +151,8 @@ public extension DispatchQueue {
|
||||
target: DispatchQueue? = nil)
|
||||
{
|
||||
var attr = attributes._attr()
|
||||
if autoreleaseFrequency != .inherit {
|
||||
attr = autoreleaseFrequency._attr(attr: attr)
|
||||
if autoreleaseFrequency != .inherit {
|
||||
attr = autoreleaseFrequency._attr(attr: attr)
|
||||
}
|
||||
if #available(OSX 10.10, iOS 8.0, *), qos != .unspecified {
|
||||
attr = __dispatch_queue_attr_make_with_qos_class(attr, qos.qosClass.rawValue, Int32(qos.relativePriority))
|
||||
@@ -179,23 +179,23 @@ public extension DispatchQueue {
|
||||
|
||||
@available(OSX 10.10, iOS 8.0, *)
|
||||
public func async(execute workItem: DispatchWorkItem) {
|
||||
// _swift_dispatch_async preserves the @convention(block)
|
||||
// _swift_dispatch_async preserves the @convention(block)
|
||||
// for work item blocks.
|
||||
_swift_dispatch_async(self, workItem._block)
|
||||
}
|
||||
|
||||
@available(OSX 10.10, iOS 8.0, *)
|
||||
public func async(group: DispatchGroup, execute workItem: DispatchWorkItem) {
|
||||
// _swift_dispatch_group_async preserves the @convention(block)
|
||||
// _swift_dispatch_group_async preserves the @convention(block)
|
||||
// for work item blocks.
|
||||
_swift_dispatch_group_async(group, self, workItem._block)
|
||||
}
|
||||
|
||||
public func async(
|
||||
group: DispatchGroup? = nil,
|
||||
qos: DispatchQoS = .unspecified,
|
||||
flags: DispatchWorkItemFlags = [],
|
||||
execute work: @escaping @convention(block) () -> Void)
|
||||
group: DispatchGroup? = nil,
|
||||
qos: DispatchQoS = .unspecified,
|
||||
flags: DispatchWorkItemFlags = [],
|
||||
execute work: @escaping @convention(block) () -> Void)
|
||||
{
|
||||
if group == nil && qos == .unspecified {
|
||||
// Fast-path route for the most common API usage
|
||||
@@ -226,9 +226,9 @@ public extension DispatchQueue {
|
||||
}
|
||||
|
||||
private func _syncHelper<T>(
|
||||
fn: (() -> ()) -> (),
|
||||
execute work: () throws -> T,
|
||||
rescue: ((Error) throws -> (T))) rethrows -> T
|
||||
fn: (() -> ()) -> (),
|
||||
execute work: () throws -> T,
|
||||
rescue: ((Error) throws -> (T))) rethrows -> T
|
||||
{
|
||||
var result: T?
|
||||
var error: Error?
|
||||
@@ -248,10 +248,10 @@ public extension DispatchQueue {
|
||||
|
||||
@available(OSX 10.10, iOS 8.0, *)
|
||||
private func _syncHelper<T>(
|
||||
fn: (DispatchWorkItem) -> (),
|
||||
fn: (DispatchWorkItem) -> (),
|
||||
flags: DispatchWorkItemFlags,
|
||||
execute work: () throws -> T,
|
||||
rescue: ((Error) throws -> (T))) rethrows -> T
|
||||
rescue: ((Error) throws -> (T))) rethrows -> T
|
||||
{
|
||||
var result: T?
|
||||
var error: Error?
|
||||
@@ -259,7 +259,7 @@ public extension DispatchQueue {
|
||||
do {
|
||||
result = try work()
|
||||
} catch let e {
|
||||
error = e
|
||||
error = e
|
||||
}
|
||||
})
|
||||
fn(workItem)
|
||||
@@ -285,10 +285,10 @@ public extension DispatchQueue {
|
||||
}
|
||||
|
||||
public func asyncAfter(
|
||||
deadline: DispatchTime,
|
||||
qos: DispatchQoS = .unspecified,
|
||||
flags: DispatchWorkItemFlags = [],
|
||||
execute work: @escaping @convention(block) () -> Void)
|
||||
deadline: DispatchTime,
|
||||
qos: DispatchQoS = .unspecified,
|
||||
flags: DispatchWorkItemFlags = [],
|
||||
execute work: @escaping @convention(block) () -> Void)
|
||||
{
|
||||
if #available(OSX 10.10, iOS 8.0, *), qos != .unspecified || !flags.isEmpty {
|
||||
let item = DispatchWorkItem(qos: qos, flags: flags, block: work)
|
||||
@@ -300,9 +300,9 @@ public extension DispatchQueue {
|
||||
|
||||
public func asyncAfter(
|
||||
wallDeadline: DispatchWallTime,
|
||||
qos: DispatchQoS = .unspecified,
|
||||
flags: DispatchWorkItemFlags = [],
|
||||
execute work: @escaping @convention(block) () -> Void)
|
||||
qos: DispatchQoS = .unspecified,
|
||||
flags: DispatchWorkItemFlags = [],
|
||||
execute work: @escaping @convention(block) () -> Void)
|
||||
{
|
||||
if #available(OSX 10.10, iOS 8.0, *), qos != .unspecified || !flags.isEmpty {
|
||||
let item = DispatchWorkItem(qos: qos, flags: flags, block: work)
|
||||
|
||||
@@ -7,9 +7,9 @@
|
||||
|
||||
func foo() -> Int {
|
||||
let x = 1
|
||||
var y = 2
|
||||
// DEFAULT: warning: variable 'y' was never mutated; consider changing to 'let' constant
|
||||
// WERR: error: variable 'y' was never mutated; consider changing to 'let' constant
|
||||
var y = 2
|
||||
// DEFAULT: warning: variable 'y' was never mutated; consider changing to 'let' constant
|
||||
// WERR: error: variable 'y' was never mutated; consider changing to 'let' constant
|
||||
// NOWARN-NOT: variable 'y' was never mutated
|
||||
return x + y
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ func foo() -> Int {
|
||||
}
|
||||
}
|
||||
func goo(_ e: Error) {
|
||||
|
||||
|
||||
}
|
||||
|
||||
@warn_unused_result(message="test message")
|
||||
|
||||
@@ -15,7 +15,7 @@ func foo() -> Int {
|
||||
}
|
||||
}
|
||||
func goo(_ e: Error) {
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// RUN: %target-swift-frontend -assume-parsing-unqualified-ownership-sil -primary-file %s -O -emit-ir | %FileCheck %s
|
||||
// RUN: %target-swift-frontend -assume-parsing-unqualified-ownership-sil -primary-file %s -O -emit-ir | %FileCheck %s
|
||||
|
||||
sil_stage canonical
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// RUN: %target-swift-frontend -assume-parsing-unqualified-ownership-sil -emit-ir %s
|
||||
// RUN: %target-swift-frontend -assume-parsing-unqualified-ownership-sil -emit-ir %s
|
||||
sil_stage canonical
|
||||
|
||||
import Swift
|
||||
|
||||
@@ -14,7 +14,7 @@ class ObservedValue: NSObject {
|
||||
class ValueObserver: NSObject {
|
||||
private var observeContext = 0
|
||||
let observedValue: ObservedValue
|
||||
|
||||
|
||||
init(value: ObservedValue) {
|
||||
observedValue = value
|
||||
super.init()
|
||||
@@ -24,7 +24,7 @@ class ValueObserver: NSObject {
|
||||
deinit {
|
||||
observedValue.removeObserver(self, forKeyPath: "amount")
|
||||
}
|
||||
|
||||
|
||||
override func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey : Any]?, context: UnsafeMutableRawPointer?) {
|
||||
if context == &observeContext {
|
||||
if let change_ = change {
|
||||
|
||||
@@ -8,7 +8,7 @@ import CoreGraphics
|
||||
var roomName : String?
|
||||
|
||||
if let realRoomName = roomName as! NSString { // expected-error {{initializer for conditional binding must have Optional type, not 'NSString'}} expected-warning {{cast from 'String?' to unrelated type 'NSString' always fails}}
|
||||
|
||||
|
||||
}
|
||||
|
||||
var pi = 3.14159265358979
|
||||
|
||||
@@ -222,7 +222,7 @@ sil @read_p : $@convention(thin) (@in P) -> ()
|
||||
sil @foo_witness : $@convention(witness_method) (@in_guaranteed X) -> Int64
|
||||
|
||||
sil_witness_table hidden X: P module nix {
|
||||
method #P.foo!1: @foo_witness
|
||||
method #P.foo!1: @foo_witness
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ bb0(%0 : $Optional<Int32>, %1 : $Int32):
|
||||
bb1(%3 : $Int32):
|
||||
debug_value %3 : $Int32
|
||||
|
||||
// The operand is not %3 (= the argument of this block).
|
||||
// The operand is not %3 (= the argument of this block).
|
||||
%5 = enum $Optional<Int32>, #Optional.some!enumelt.1, %1 : $Int32
|
||||
br bb3(%5 : $Optional<Int32>)
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// RUN: %target-sil-opt -assume-parsing-unqualified-ownership-sil -enable-sil-verify-all %s -external-func-definition-elim | %FileCheck %s
|
||||
// RUN: %target-sil-opt -assume-parsing-unqualified-ownership-sil -enable-sil-verify-all %s -external-func-definition-elim | %FileCheck %s
|
||||
|
||||
sil_stage canonical
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// RUN: %target-sil-opt -assume-parsing-unqualified-ownership-sil -enable-sil-verify-all %s -redundant-load-elim | %FileCheck %s
|
||||
// RUN: %target-sil-opt -assume-parsing-unqualified-ownership-sil -enable-sil-verify-all %s -redundant-load-elim | %FileCheck %s
|
||||
|
||||
import Builtin
|
||||
import Swift
|
||||
|
||||
@@ -18,7 +18,7 @@ _ = q.label
|
||||
if #available(OSX 10.10, iOS 8.0, *) {
|
||||
_ = DispatchQueue.global(qos: .userInteractive)
|
||||
_ = DispatchQueue.global(qos: .background)
|
||||
_ = DispatchQueue.global(qos: .default)
|
||||
_ = DispatchQueue.global(qos: .default)
|
||||
}
|
||||
|
||||
// dispatch/source.h
|
||||
|
||||
@@ -93,11 +93,11 @@ POSIXTests.test("ioctl(CInt, UInt, CInt): fail") {
|
||||
let fd = open(fn, 0)
|
||||
expectEqual(-1, fd)
|
||||
expectEqual(ENOENT, errno)
|
||||
|
||||
|
||||
// A simple check to verify that ioctl is available
|
||||
let _ = ioctl(fd, 0, 0)
|
||||
expectEqual(EBADF, errno)
|
||||
}
|
||||
}
|
||||
|
||||
#if os(Linux)
|
||||
// Successful creation of a socket and listing interfaces
|
||||
@@ -122,7 +122,7 @@ POSIXTests.test("fcntl(CInt, CInt): fail") {
|
||||
let fd = open(fn, 0)
|
||||
expectEqual(-1, fd)
|
||||
expectEqual(ENOENT, errno)
|
||||
|
||||
|
||||
let _ = fcntl(fd, F_GETFL)
|
||||
expectEqual(EBADF, errno)
|
||||
}
|
||||
@@ -132,28 +132,28 @@ POSIXTests.test("fcntl(CInt, CInt): F_GETFL/F_SETFL success with file") {
|
||||
// Create and open file.
|
||||
let fd = open(fn, O_CREAT, 0o666)
|
||||
expectGT(Int(fd), 0)
|
||||
|
||||
|
||||
var flags = fcntl(fd, F_GETFL)
|
||||
expectGE(Int(flags), 0)
|
||||
|
||||
|
||||
// Change to APPEND mode...
|
||||
var rc = fcntl(fd, F_SETFL, O_APPEND)
|
||||
expectEqual(0, rc)
|
||||
|
||||
|
||||
flags = fcntl(fd, F_GETFL)
|
||||
expectEqual(flags | O_APPEND, flags)
|
||||
|
||||
|
||||
// Change back...
|
||||
rc = fcntl(fd, F_SETFL, 0)
|
||||
expectEqual(0, rc)
|
||||
|
||||
flags = fcntl(fd, F_GETFL)
|
||||
expectGE(Int(flags), 0)
|
||||
|
||||
|
||||
// Clean up...
|
||||
rc = close(fd)
|
||||
expectEqual(0, rc)
|
||||
|
||||
|
||||
rc = unlink(fn)
|
||||
expectEqual(0, rc)
|
||||
}
|
||||
@@ -162,24 +162,24 @@ POSIXTests.test("fcntl(CInt, CInt, CInt): block and unblocking sockets success")
|
||||
// Create socket, note: socket created by default in blocking mode...
|
||||
let sock = socket(PF_INET, 1, 0)
|
||||
expectGT(Int(sock), 0)
|
||||
|
||||
|
||||
var flags = fcntl(sock, F_GETFL)
|
||||
expectGE(Int(flags), 0)
|
||||
|
||||
|
||||
// Change mode of socket to non-blocking...
|
||||
var rc = fcntl(sock, F_SETFL, flags | O_NONBLOCK)
|
||||
expectEqual(0, rc)
|
||||
|
||||
|
||||
flags = fcntl(sock, F_GETFL)
|
||||
expectEqual((flags | O_NONBLOCK), flags)
|
||||
|
||||
|
||||
// Change back to blocking...
|
||||
rc = fcntl(sock, F_SETFL, flags & ~O_NONBLOCK)
|
||||
expectEqual(0, rc)
|
||||
|
||||
|
||||
flags = fcntl(sock, F_GETFL)
|
||||
expectGE(Int(flags), 0)
|
||||
|
||||
|
||||
// Clean up...
|
||||
rc = close(sock)
|
||||
expectEqual(0, rc)
|
||||
@@ -189,35 +189,35 @@ POSIXTests.test("fcntl(CInt, CInt, UnsafeMutableRawPointer): locking and unlocki
|
||||
// Create the file and add data to it...
|
||||
var fd = open(fn, O_CREAT | O_WRONLY, 0o666)
|
||||
expectGT(Int(fd), 0)
|
||||
|
||||
|
||||
let data = "Testing 1 2 3"
|
||||
let bytesWritten = write(fd, data, data.utf8.count)
|
||||
expectEqual(data.utf8.count, bytesWritten)
|
||||
|
||||
|
||||
var rc = close(fd)
|
||||
expectEqual(0, rc)
|
||||
|
||||
|
||||
// Re-open the file...
|
||||
fd = open(fn, 0)
|
||||
expectGT(Int(fd), 0)
|
||||
|
||||
|
||||
// Lock for reading...
|
||||
var flck = flock()
|
||||
flck.l_type = Int16(F_RDLCK)
|
||||
flck.l_len = off_t(data.utf8.count)
|
||||
rc = fcntl(fd, F_SETLK, &flck)
|
||||
expectEqual(0, rc)
|
||||
|
||||
|
||||
// Unlock for reading...
|
||||
flck = flock()
|
||||
flck.l_type = Int16(F_UNLCK)
|
||||
rc = fcntl(fd, F_SETLK, &flck)
|
||||
expectEqual(0, rc)
|
||||
|
||||
|
||||
// Clean up...
|
||||
rc = close(fd)
|
||||
expectEqual(0, rc)
|
||||
|
||||
|
||||
rc = unlink(fn)
|
||||
expectEqual(0, rc)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user