[gardening] Remove accidental trailing whitespace (" " and "\t")

This commit is contained in:
practicalswift
2016-10-30 10:59:02 +01:00
parent f5ed77a032
commit 2024316e38
15 changed files with 68 additions and 68 deletions

View File

@@ -82,7 +82,7 @@ public struct DispatchData : RandomAccessCollection, _ObjectiveCBridgeable {
} }
public func enumerateBytes( 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 _swift_dispatch_data_apply(__wrapped) { (_, offset: Int, ptr: UnsafeRawPointer, size: Int) in
let bytePtr = ptr.bindMemory(to: UInt8.self, capacity: size) 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) { public func copyBytes(to pointer: UnsafeMutablePointer<UInt8>, count: Int) {
_copyBytesHelper(to: pointer, from: 0..<count) _copyBytesHelper(to: pointer, from: 0..<count)
} }
/// Copy a subset of the contents of the data to a pointer. /// 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. /// - 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>) { public func copyBytes(to pointer: UnsafeMutablePointer<UInt8>, from range: CountableRange<Index>) {
_copyBytesHelper(to: pointer, from: range) _copyBytesHelper(to: pointer, from: range)
} }
/// Copy the contents of the data into a buffer. /// 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. /// 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 { public func copyBytes<DestinationType>(to buffer: UnsafeMutableBufferPointer<DestinationType>, from range: CountableRange<Index>? = nil) -> Int {
let cnt = count let cnt = count
guard cnt > 0 else { return 0 } guard cnt > 0 else { return 0 }
let copyRange : CountableRange<Index> let copyRange : CountableRange<Index>
if let r = range { if let r = range {
guard !r.isEmpty else { return 0 } guard !r.isEmpty else { return 0 }
precondition(r.startIndex >= 0) precondition(r.startIndex >= 0)
precondition(r.startIndex < cnt, "The range is outside the bounds of the data") precondition(r.startIndex < cnt, "The range is outside the bounds of the data")
precondition(r.endIndex >= 0) precondition(r.endIndex >= 0)
precondition(r.endIndex <= cnt, "The range is outside the bounds of the data") 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)) copyRange = r.startIndex..<(r.startIndex + Swift.min(buffer.count * MemoryLayout<DestinationType>.stride, r.count))
} else { } else {
copyRange = 0..<Swift.min(buffer.count * MemoryLayout<DestinationType>.stride, cnt) copyRange = 0..<Swift.min(buffer.count * MemoryLayout<DestinationType>.stride, cnt)
} }
guard !copyRange.isEmpty else { return 0 } guard !copyRange.isEmpty else { return 0 }
_copyBytesHelper(to: buffer.baseAddress!, from: copyRange) _copyBytesHelper(to: buffer.baseAddress!, from: copyRange)
return copyRange.count return copyRange.count
} }

View File

@@ -95,7 +95,7 @@ public extension DispatchQueue {
internal func _attr(attr: __OS_dispatch_queue_attr?) -> __OS_dispatch_queue_attr? { 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, *) { if #available(OSX 10.12, iOS 10.0, tvOS 10.0, watchOS 3.0, *) {
switch self { switch self {
case .inherit: case .inherit:
// DISPATCH_AUTORELEASE_FREQUENCY_INHERIT // DISPATCH_AUTORELEASE_FREQUENCY_INHERIT
return __dispatch_queue_attr_make_with_autorelease_frequency(attr, __dispatch_autorelease_frequency_t(0)) return __dispatch_queue_attr_make_with_autorelease_frequency(attr, __dispatch_autorelease_frequency_t(0))
case .workItem: case .workItem:
@@ -142,7 +142,7 @@ public extension DispatchQueue {
} }
return nil return nil
} }
public convenience init( public convenience init(
label: String, label: String,
qos: DispatchQoS = .unspecified, qos: DispatchQoS = .unspecified,
@@ -151,8 +151,8 @@ public extension DispatchQueue {
target: DispatchQueue? = nil) target: DispatchQueue? = nil)
{ {
var attr = attributes._attr() var attr = attributes._attr()
if autoreleaseFrequency != .inherit { if autoreleaseFrequency != .inherit {
attr = autoreleaseFrequency._attr(attr: attr) attr = autoreleaseFrequency._attr(attr: attr)
} }
if #available(OSX 10.10, iOS 8.0, *), qos != .unspecified { 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)) 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, *) @available(OSX 10.10, iOS 8.0, *)
public func async(execute workItem: DispatchWorkItem) { public func async(execute workItem: DispatchWorkItem) {
// _swift_dispatch_async preserves the @convention(block) // _swift_dispatch_async preserves the @convention(block)
// for work item blocks. // for work item blocks.
_swift_dispatch_async(self, workItem._block) _swift_dispatch_async(self, workItem._block)
} }
@available(OSX 10.10, iOS 8.0, *) @available(OSX 10.10, iOS 8.0, *)
public func async(group: DispatchGroup, execute workItem: DispatchWorkItem) { 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. // for work item blocks.
_swift_dispatch_group_async(group, self, workItem._block) _swift_dispatch_group_async(group, self, workItem._block)
} }
public func async( public func async(
group: DispatchGroup? = nil, group: DispatchGroup? = nil,
qos: DispatchQoS = .unspecified, qos: DispatchQoS = .unspecified,
flags: DispatchWorkItemFlags = [], flags: DispatchWorkItemFlags = [],
execute work: @escaping @convention(block) () -> Void) execute work: @escaping @convention(block) () -> Void)
{ {
if group == nil && qos == .unspecified { if group == nil && qos == .unspecified {
// Fast-path route for the most common API usage // Fast-path route for the most common API usage
@@ -226,9 +226,9 @@ public extension DispatchQueue {
} }
private func _syncHelper<T>( private func _syncHelper<T>(
fn: (() -> ()) -> (), fn: (() -> ()) -> (),
execute work: () throws -> T, execute work: () throws -> T,
rescue: ((Error) throws -> (T))) rethrows -> T rescue: ((Error) throws -> (T))) rethrows -> T
{ {
var result: T? var result: T?
var error: Error? var error: Error?
@@ -248,10 +248,10 @@ public extension DispatchQueue {
@available(OSX 10.10, iOS 8.0, *) @available(OSX 10.10, iOS 8.0, *)
private func _syncHelper<T>( private func _syncHelper<T>(
fn: (DispatchWorkItem) -> (), fn: (DispatchWorkItem) -> (),
flags: DispatchWorkItemFlags, flags: DispatchWorkItemFlags,
execute work: () throws -> T, execute work: () throws -> T,
rescue: ((Error) throws -> (T))) rethrows -> T rescue: ((Error) throws -> (T))) rethrows -> T
{ {
var result: T? var result: T?
var error: Error? var error: Error?
@@ -259,7 +259,7 @@ public extension DispatchQueue {
do { do {
result = try work() result = try work()
} catch let e { } catch let e {
error = e error = e
} }
}) })
fn(workItem) fn(workItem)
@@ -285,10 +285,10 @@ public extension DispatchQueue {
} }
public func asyncAfter( public func asyncAfter(
deadline: DispatchTime, deadline: DispatchTime,
qos: DispatchQoS = .unspecified, qos: DispatchQoS = .unspecified,
flags: DispatchWorkItemFlags = [], flags: DispatchWorkItemFlags = [],
execute work: @escaping @convention(block) () -> Void) execute work: @escaping @convention(block) () -> Void)
{ {
if #available(OSX 10.10, iOS 8.0, *), qos != .unspecified || !flags.isEmpty { if #available(OSX 10.10, iOS 8.0, *), qos != .unspecified || !flags.isEmpty {
let item = DispatchWorkItem(qos: qos, flags: flags, block: work) let item = DispatchWorkItem(qos: qos, flags: flags, block: work)
@@ -300,9 +300,9 @@ public extension DispatchQueue {
public func asyncAfter( public func asyncAfter(
wallDeadline: DispatchWallTime, wallDeadline: DispatchWallTime,
qos: DispatchQoS = .unspecified, qos: DispatchQoS = .unspecified,
flags: DispatchWorkItemFlags = [], flags: DispatchWorkItemFlags = [],
execute work: @escaping @convention(block) () -> Void) execute work: @escaping @convention(block) () -> Void)
{ {
if #available(OSX 10.10, iOS 8.0, *), qos != .unspecified || !flags.isEmpty { if #available(OSX 10.10, iOS 8.0, *), qos != .unspecified || !flags.isEmpty {
let item = DispatchWorkItem(qos: qos, flags: flags, block: work) let item = DispatchWorkItem(qos: qos, flags: flags, block: work)

View File

@@ -7,9 +7,9 @@
func foo() -> Int { func foo() -> Int {
let x = 1 let x = 1
var y = 2 var y = 2
// DEFAULT: warning: variable 'y' was never mutated; consider changing to 'let' constant // DEFAULT: warning: variable 'y' was never mutated; consider changing to 'let' constant
// WERR: error: 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 // NOWARN-NOT: variable 'y' was never mutated
return x + y return x + y
} }

View File

@@ -15,7 +15,7 @@ func foo() -> Int {
} }
} }
func goo(_ e: Error) { func goo(_ e: Error) {
} }
@warn_unused_result(message="test message") @warn_unused_result(message="test message")

View File

@@ -15,7 +15,7 @@ func foo() -> Int {
} }
} }
func goo(_ e: Error) { func goo(_ e: Error) {
} }

View File

@@ -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 sil_stage canonical

View File

@@ -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 sil_stage canonical
import Swift import Swift

View File

@@ -14,7 +14,7 @@ class ObservedValue: NSObject {
class ValueObserver: NSObject { class ValueObserver: NSObject {
private var observeContext = 0 private var observeContext = 0
let observedValue: ObservedValue let observedValue: ObservedValue
init(value: ObservedValue) { init(value: ObservedValue) {
observedValue = value observedValue = value
super.init() super.init()
@@ -24,7 +24,7 @@ class ValueObserver: NSObject {
deinit { deinit {
observedValue.removeObserver(self, forKeyPath: "amount") observedValue.removeObserver(self, forKeyPath: "amount")
} }
override func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey : Any]?, context: UnsafeMutableRawPointer?) { override func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey : Any]?, context: UnsafeMutableRawPointer?) {
if context == &observeContext { if context == &observeContext {
if let change_ = change { if let change_ = change {

View File

@@ -8,7 +8,7 @@ import CoreGraphics
var roomName : String? 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}} 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 var pi = 3.14159265358979

View File

@@ -222,7 +222,7 @@ sil @read_p : $@convention(thin) (@in P) -> ()
sil @foo_witness : $@convention(witness_method) (@in_guaranteed X) -> Int64 sil @foo_witness : $@convention(witness_method) (@in_guaranteed X) -> Int64
sil_witness_table hidden X: P module nix { sil_witness_table hidden X: P module nix {
method #P.foo!1: @foo_witness method #P.foo!1: @foo_witness
} }

View File

@@ -54,7 +54,7 @@ bb0(%0 : $Optional<Int32>, %1 : $Int32):
bb1(%3 : $Int32): bb1(%3 : $Int32):
debug_value %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 %5 = enum $Optional<Int32>, #Optional.some!enumelt.1, %1 : $Int32
br bb3(%5 : $Optional<Int32>) br bb3(%5 : $Optional<Int32>)

View File

@@ -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 sil_stage canonical

View File

@@ -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 Builtin
import Swift import Swift

View File

@@ -18,7 +18,7 @@ _ = q.label
if #available(OSX 10.10, iOS 8.0, *) { if #available(OSX 10.10, iOS 8.0, *) {
_ = DispatchQueue.global(qos: .userInteractive) _ = DispatchQueue.global(qos: .userInteractive)
_ = DispatchQueue.global(qos: .background) _ = DispatchQueue.global(qos: .background)
_ = DispatchQueue.global(qos: .default) _ = DispatchQueue.global(qos: .default)
} }
// dispatch/source.h // dispatch/source.h

View File

@@ -93,11 +93,11 @@ POSIXTests.test("ioctl(CInt, UInt, CInt): fail") {
let fd = open(fn, 0) let fd = open(fn, 0)
expectEqual(-1, fd) expectEqual(-1, fd)
expectEqual(ENOENT, errno) expectEqual(ENOENT, errno)
// A simple check to verify that ioctl is available // A simple check to verify that ioctl is available
let _ = ioctl(fd, 0, 0) let _ = ioctl(fd, 0, 0)
expectEqual(EBADF, errno) expectEqual(EBADF, errno)
} }
#if os(Linux) #if os(Linux)
// Successful creation of a socket and listing interfaces // Successful creation of a socket and listing interfaces
@@ -122,7 +122,7 @@ POSIXTests.test("fcntl(CInt, CInt): fail") {
let fd = open(fn, 0) let fd = open(fn, 0)
expectEqual(-1, fd) expectEqual(-1, fd)
expectEqual(ENOENT, errno) expectEqual(ENOENT, errno)
let _ = fcntl(fd, F_GETFL) let _ = fcntl(fd, F_GETFL)
expectEqual(EBADF, errno) expectEqual(EBADF, errno)
} }
@@ -132,28 +132,28 @@ POSIXTests.test("fcntl(CInt, CInt): F_GETFL/F_SETFL success with file") {
// Create and open file. // Create and open file.
let fd = open(fn, O_CREAT, 0o666) let fd = open(fn, O_CREAT, 0o666)
expectGT(Int(fd), 0) expectGT(Int(fd), 0)
var flags = fcntl(fd, F_GETFL) var flags = fcntl(fd, F_GETFL)
expectGE(Int(flags), 0) expectGE(Int(flags), 0)
// Change to APPEND mode... // Change to APPEND mode...
var rc = fcntl(fd, F_SETFL, O_APPEND) var rc = fcntl(fd, F_SETFL, O_APPEND)
expectEqual(0, rc) expectEqual(0, rc)
flags = fcntl(fd, F_GETFL) flags = fcntl(fd, F_GETFL)
expectEqual(flags | O_APPEND, flags) expectEqual(flags | O_APPEND, flags)
// Change back... // Change back...
rc = fcntl(fd, F_SETFL, 0) rc = fcntl(fd, F_SETFL, 0)
expectEqual(0, rc) expectEqual(0, rc)
flags = fcntl(fd, F_GETFL) flags = fcntl(fd, F_GETFL)
expectGE(Int(flags), 0) expectGE(Int(flags), 0)
// Clean up... // Clean up...
rc = close(fd) rc = close(fd)
expectEqual(0, rc) expectEqual(0, rc)
rc = unlink(fn) rc = unlink(fn)
expectEqual(0, rc) 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... // Create socket, note: socket created by default in blocking mode...
let sock = socket(PF_INET, 1, 0) let sock = socket(PF_INET, 1, 0)
expectGT(Int(sock), 0) expectGT(Int(sock), 0)
var flags = fcntl(sock, F_GETFL) var flags = fcntl(sock, F_GETFL)
expectGE(Int(flags), 0) expectGE(Int(flags), 0)
// Change mode of socket to non-blocking... // Change mode of socket to non-blocking...
var rc = fcntl(sock, F_SETFL, flags | O_NONBLOCK) var rc = fcntl(sock, F_SETFL, flags | O_NONBLOCK)
expectEqual(0, rc) expectEqual(0, rc)
flags = fcntl(sock, F_GETFL) flags = fcntl(sock, F_GETFL)
expectEqual((flags | O_NONBLOCK), flags) expectEqual((flags | O_NONBLOCK), flags)
// Change back to blocking... // Change back to blocking...
rc = fcntl(sock, F_SETFL, flags & ~O_NONBLOCK) rc = fcntl(sock, F_SETFL, flags & ~O_NONBLOCK)
expectEqual(0, rc) expectEqual(0, rc)
flags = fcntl(sock, F_GETFL) flags = fcntl(sock, F_GETFL)
expectGE(Int(flags), 0) expectGE(Int(flags), 0)
// Clean up... // Clean up...
rc = close(sock) rc = close(sock)
expectEqual(0, rc) expectEqual(0, rc)
@@ -189,35 +189,35 @@ POSIXTests.test("fcntl(CInt, CInt, UnsafeMutableRawPointer): locking and unlocki
// Create the file and add data to it... // Create the file and add data to it...
var fd = open(fn, O_CREAT | O_WRONLY, 0o666) var fd = open(fn, O_CREAT | O_WRONLY, 0o666)
expectGT(Int(fd), 0) expectGT(Int(fd), 0)
let data = "Testing 1 2 3" let data = "Testing 1 2 3"
let bytesWritten = write(fd, data, data.utf8.count) let bytesWritten = write(fd, data, data.utf8.count)
expectEqual(data.utf8.count, bytesWritten) expectEqual(data.utf8.count, bytesWritten)
var rc = close(fd) var rc = close(fd)
expectEqual(0, rc) expectEqual(0, rc)
// Re-open the file... // Re-open the file...
fd = open(fn, 0) fd = open(fn, 0)
expectGT(Int(fd), 0) expectGT(Int(fd), 0)
// Lock for reading... // Lock for reading...
var flck = flock() var flck = flock()
flck.l_type = Int16(F_RDLCK) flck.l_type = Int16(F_RDLCK)
flck.l_len = off_t(data.utf8.count) flck.l_len = off_t(data.utf8.count)
rc = fcntl(fd, F_SETLK, &flck) rc = fcntl(fd, F_SETLK, &flck)
expectEqual(0, rc) expectEqual(0, rc)
// Unlock for reading... // Unlock for reading...
flck = flock() flck = flock()
flck.l_type = Int16(F_UNLCK) flck.l_type = Int16(F_UNLCK)
rc = fcntl(fd, F_SETLK, &flck) rc = fcntl(fd, F_SETLK, &flck)
expectEqual(0, rc) expectEqual(0, rc)
// Clean up... // Clean up...
rc = close(fd) rc = close(fd)
expectEqual(0, rc) expectEqual(0, rc)
rc = unlink(fn) rc = unlink(fn)
expectEqual(0, rc) expectEqual(0, rc)
} }