Skip to content

Commit a3b5733

Browse files
committed
avoid overflow in dispatch_io test
Test was failing because number of bytes read overflows int32_t. Changing to a uint32_t is sufficient to avoid overflow. Changing to int64_t would also work, but is a larger change (since we then need to provide an OSAtomicAdd64 function on Linux).
1 parent 129ac99 commit a3b5733

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

tests/dispatch_io.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@ test_async_read(char *path, size_t size, int option, dispatch_queue_t queue,
448448

449449
static int
450450
test_read_dirs(char **paths, dispatch_queue_t queue, dispatch_group_t g,
451-
dispatch_semaphore_t s, volatile int32_t *bytes, int option)
451+
dispatch_semaphore_t s, volatile uint32_t *bytes, int option)
452452
{
453453
FTS *tree = fts_open(paths, FTS_PHYSICAL|FTS_XDEV, NULL);
454454
if (!tree) {
@@ -505,7 +505,7 @@ test_read_many_files(void)
505505
dispatch_group_t g = dispatch_group_create();
506506
dispatch_semaphore_t s = dispatch_semaphore_create(maxopenfiles);
507507
uint64_t start;
508-
volatile int32_t bytes;
508+
volatile uint32_t bytes;
509509
unsigned int files_read, i;
510510

511511
const dispatch_queue_t queues[] = {

0 commit comments

Comments
 (0)