[PATCH] D60477: [TSan][libdispatch] Replace usage of NSMutableData with stack array
Julian Lettner via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 9 11:22:38 PDT 2019
yln created this revision.
Herald added subscribers: llvm-commits, Sanitizers, kubamracek.
Herald added projects: Sanitizers, LLVM.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D60477
Files:
compiler-rt/test/tsan/Darwin/gcd-fd.mm
compiler-rt/test/tsan/Darwin/gcd-io-barrier-race.mm
compiler-rt/test/tsan/Darwin/gcd-io-barrier.mm
compiler-rt/test/tsan/Darwin/gcd-io-race.mm
compiler-rt/test/tsan/Darwin/gcd-io.mm
Index: compiler-rt/test/tsan/Darwin/gcd-io.mm
===================================================================
--- compiler-rt/test/tsan/Darwin/gcd-io.mm
+++ compiler-rt/test/tsan/Darwin/gcd-io.mm
@@ -100,8 +100,8 @@
sem = dispatch_semaphore_create(0);
NSString *ns_path = [NSTemporaryDirectory() stringByAppendingPathComponent:[NSString stringWithFormat:@"temp-gcd-io.%d", getpid()]];
path = ns_path.fileSystemRepresentation;
- NSData *ns_data = [NSMutableData dataWithLength:1000];
- data = dispatch_data_create(ns_data.bytes, ns_data.length, NULL, DISPATCH_DATA_DESTRUCTOR_DEFAULT);
+ char buf[1000];
+ data = dispatch_data_create(buf, sizeof(buf), NULL, DISPATCH_DATA_DESTRUCTOR_DEFAULT);
test_dispatch_io_write();
test_dispatch_write();
Index: compiler-rt/test/tsan/Darwin/gcd-io-race.mm
===================================================================
--- compiler-rt/test/tsan/Darwin/gcd-io-race.mm
+++ compiler-rt/test/tsan/Darwin/gcd-io-race.mm
@@ -23,8 +23,8 @@
sem = dispatch_semaphore_create(0);
NSString *ns_path = [NSTemporaryDirectory() stringByAppendingPathComponent:[NSString stringWithFormat:@"temp-gcd-io.%d", getpid()]];
path = ns_path.fileSystemRepresentation;
- NSData *ns_data = [NSMutableData dataWithLength:1000];
- data = dispatch_data_create(ns_data.bytes, ns_data.length, NULL, DISPATCH_DATA_DESTRUCTOR_DEFAULT);
+ char buf[1000];
+ data = dispatch_data_create(buf, sizeof(buf), NULL, DISPATCH_DATA_DESTRUCTOR_DEFAULT);
dispatch_io_t channel = dispatch_io_create_with_path(DISPATCH_IO_STREAM, path, O_CREAT | O_WRONLY, 0666, queue, ^(int error) { });
if (! channel) abort();
Index: compiler-rt/test/tsan/Darwin/gcd-io-barrier.mm
===================================================================
--- compiler-rt/test/tsan/Darwin/gcd-io-barrier.mm
+++ compiler-rt/test/tsan/Darwin/gcd-io-barrier.mm
@@ -17,8 +17,8 @@
sem = dispatch_semaphore_create(0);
NSString *ns_path = [NSTemporaryDirectory() stringByAppendingPathComponent:[NSString stringWithFormat:@"temp-gcd-io.%d", getpid()]];
path = ns_path.fileSystemRepresentation;
- NSData *ns_data = [NSMutableData dataWithLength:1000];
- data = dispatch_data_create(ns_data.bytes, ns_data.length, NULL, DISPATCH_DATA_DESTRUCTOR_DEFAULT);
+ char buf[1000];
+ data = dispatch_data_create(buf, sizeof(buf), NULL, DISPATCH_DATA_DESTRUCTOR_DEFAULT);
dispatch_io_t channel = dispatch_io_create_with_path(DISPATCH_IO_STREAM, path, O_CREAT | O_WRONLY, 0666, queue, ^(int error) { });
if (! channel) abort();
Index: compiler-rt/test/tsan/Darwin/gcd-io-barrier-race.mm
===================================================================
--- compiler-rt/test/tsan/Darwin/gcd-io-barrier-race.mm
+++ compiler-rt/test/tsan/Darwin/gcd-io-barrier-race.mm
@@ -21,8 +21,8 @@
sem = dispatch_semaphore_create(0);
NSString *ns_path = [NSTemporaryDirectory() stringByAppendingPathComponent:[NSString stringWithFormat:@"temp-gcd-io.%d", getpid()]];
path = ns_path.fileSystemRepresentation;
- NSData *ns_data = [NSMutableData dataWithLength:1000];
- data = dispatch_data_create(ns_data.bytes, ns_data.length, NULL, DISPATCH_DATA_DESTRUCTOR_DEFAULT);
+ char buf[1000];
+ data = dispatch_data_create(buf, sizeof(buf), NULL, DISPATCH_DATA_DESTRUCTOR_DEFAULT);
dispatch_io_t channel = dispatch_io_create_with_path(DISPATCH_IO_STREAM, path, O_CREAT | O_WRONLY, 0666, queue, ^(int error) { });
if (! channel) abort();
Index: compiler-rt/test/tsan/Darwin/gcd-fd.mm
===================================================================
--- compiler-rt/test/tsan/Darwin/gcd-fd.mm
+++ compiler-rt/test/tsan/Darwin/gcd-fd.mm
@@ -17,8 +17,8 @@
0666, queue, ^(int error) { });
dispatch_io_set_high_water(channel, 1);
- NSData *ns_data = [NSMutableData dataWithLength:1000];
- dispatch_data_t data = dispatch_data_create(ns_data.bytes, ns_data.length, NULL, DISPATCH_DATA_DESTRUCTOR_DEFAULT);
+ char buf[1000];
+ dispatch_data_t data = dispatch_data_create(buf, sizeof(buf), NULL, DISPATCH_DATA_DESTRUCTOR_DEFAULT);
my_global++;
dispatch_io_write(channel, 0, data, queue, ^(bool done, dispatch_data_t remainingData, int error) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D60477.194369.patch
Type: text/x-patch
Size: 4187 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190409/b4786f16/attachment.bin>
More information about the llvm-commits
mailing list