libuv 2.0.1 → 2.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -119,7 +119,7 @@ static void check_permission(const char* filename, unsigned int mode) {
119
119
  uv_fs_t req;
120
120
  uv_stat_t* s;
121
121
 
122
- r = uv_fs_stat(uv_default_loop(), &req, filename, NULL);
122
+ r = uv_fs_stat(NULL, &req, filename, NULL);
123
123
  ASSERT(r == 0);
124
124
  ASSERT(req.result == 0);
125
125
 
@@ -402,7 +402,7 @@ static void check_mkdtemp_result(uv_fs_t* req) {
402
402
  check_permission(req->path, 0700);
403
403
 
404
404
  /* Check if req->path is actually a directory */
405
- r = uv_fs_stat(uv_default_loop(), &stat_req, req->path, NULL);
405
+ r = uv_fs_stat(NULL, &stat_req, req->path, NULL);
406
406
  ASSERT(r == 0);
407
407
  ASSERT(((uv_stat_t*)stat_req.ptr)->st_mode & S_IFDIR);
408
408
  uv_fs_req_cleanup(&stat_req);
@@ -521,7 +521,7 @@ TEST_IMPL(fs_file_noent) {
521
521
 
522
522
  loop = uv_default_loop();
523
523
 
524
- r = uv_fs_open(loop, &req, "does_not_exist", O_RDONLY, 0, NULL);
524
+ r = uv_fs_open(NULL, &req, "does_not_exist", O_RDONLY, 0, NULL);
525
525
  ASSERT(r == UV_ENOENT);
526
526
  ASSERT(req.result == UV_ENOENT);
527
527
  uv_fs_req_cleanup(&req);
@@ -549,7 +549,7 @@ TEST_IMPL(fs_file_nametoolong) {
549
549
  memset(name, 'a', TOO_LONG_NAME_LENGTH);
550
550
  name[TOO_LONG_NAME_LENGTH] = 0;
551
551
 
552
- r = uv_fs_open(loop, &req, name, O_RDONLY, 0, NULL);
552
+ r = uv_fs_open(NULL, &req, name, O_RDONLY, 0, NULL);
553
553
  ASSERT(r == UV_ENAMETOOLONG);
554
554
  ASSERT(req.result == UV_ENAMETOOLONG);
555
555
  uv_fs_req_cleanup(&req);
@@ -572,7 +572,7 @@ TEST_IMPL(fs_file_loop) {
572
572
  loop = uv_default_loop();
573
573
 
574
574
  unlink("test_symlink");
575
- r = uv_fs_symlink(loop, &req, "test_symlink", "test_symlink", 0, NULL);
575
+ r = uv_fs_symlink(NULL, &req, "test_symlink", "test_symlink", 0, NULL);
576
576
  #ifdef _WIN32
577
577
  /*
578
578
  * Windows XP and Server 2003 don't support symlinks; we'll get UV_ENOTSUP.
@@ -585,7 +585,7 @@ TEST_IMPL(fs_file_loop) {
585
585
  ASSERT(r == 0);
586
586
  uv_fs_req_cleanup(&req);
587
587
 
588
- r = uv_fs_open(loop, &req, "test_symlink", O_RDONLY, 0, NULL);
588
+ r = uv_fs_open(NULL, &req, "test_symlink", O_RDONLY, 0, NULL);
589
589
  ASSERT(r == UV_ELOOP);
590
590
  ASSERT(req.result == UV_ELOOP);
591
591
  uv_fs_req_cleanup(&req);
@@ -730,63 +730,62 @@ TEST_IMPL(fs_file_sync) {
730
730
  uv_fs_req_cleanup(&open_req1);
731
731
 
732
732
  iov = uv_buf_init(test_buf, sizeof(test_buf));
733
- r = uv_fs_write(loop, &write_req, open_req1.result, &iov, 1, -1, NULL);
733
+ r = uv_fs_write(NULL, &write_req, open_req1.result, &iov, 1, -1, NULL);
734
734
  ASSERT(r >= 0);
735
735
  ASSERT(write_req.result >= 0);
736
736
  uv_fs_req_cleanup(&write_req);
737
737
 
738
- r = uv_fs_close(loop, &close_req, open_req1.result, NULL);
738
+ r = uv_fs_close(NULL, &close_req, open_req1.result, NULL);
739
739
  ASSERT(r == 0);
740
740
  ASSERT(close_req.result == 0);
741
741
  uv_fs_req_cleanup(&close_req);
742
742
 
743
- r = uv_fs_open(loop, &open_req1, "test_file", O_RDWR, 0, NULL);
743
+ r = uv_fs_open(NULL, &open_req1, "test_file", O_RDWR, 0, NULL);
744
744
  ASSERT(r >= 0);
745
745
  ASSERT(open_req1.result >= 0);
746
746
  uv_fs_req_cleanup(&open_req1);
747
747
 
748
748
  iov = uv_buf_init(buf, sizeof(buf));
749
- r = uv_fs_read(loop, &read_req, open_req1.result, &iov, 1, -1, NULL);
749
+ r = uv_fs_read(NULL, &read_req, open_req1.result, &iov, 1, -1, NULL);
750
750
  ASSERT(r >= 0);
751
751
  ASSERT(read_req.result >= 0);
752
752
  ASSERT(strcmp(buf, test_buf) == 0);
753
753
  uv_fs_req_cleanup(&read_req);
754
754
 
755
- r = uv_fs_ftruncate(loop, &ftruncate_req, open_req1.result, 7, NULL);
755
+ r = uv_fs_ftruncate(NULL, &ftruncate_req, open_req1.result, 7, NULL);
756
756
  ASSERT(r == 0);
757
757
  ASSERT(ftruncate_req.result == 0);
758
758
  uv_fs_req_cleanup(&ftruncate_req);
759
759
 
760
- r = uv_fs_close(loop, &close_req, open_req1.result, NULL);
760
+ r = uv_fs_close(NULL, &close_req, open_req1.result, NULL);
761
761
  ASSERT(r == 0);
762
762
  ASSERT(close_req.result == 0);
763
763
  uv_fs_req_cleanup(&close_req);
764
764
 
765
- r = uv_fs_rename(loop, &rename_req, "test_file", "test_file2", NULL);
765
+ r = uv_fs_rename(NULL, &rename_req, "test_file", "test_file2", NULL);
766
766
  ASSERT(r == 0);
767
767
  ASSERT(rename_req.result == 0);
768
768
  uv_fs_req_cleanup(&rename_req);
769
769
 
770
- r = uv_fs_open(loop, &open_req1, "test_file2", O_RDONLY, 0, NULL);
770
+ r = uv_fs_open(NULL, &open_req1, "test_file2", O_RDONLY, 0, NULL);
771
771
  ASSERT(r >= 0);
772
772
  ASSERT(open_req1.result >= 0);
773
773
  uv_fs_req_cleanup(&open_req1);
774
774
 
775
775
  memset(buf, 0, sizeof(buf));
776
776
  iov = uv_buf_init(buf, sizeof(buf));
777
- r = uv_fs_read(loop, &read_req, open_req1.result, &iov, 1, -1,
778
- NULL);
777
+ r = uv_fs_read(NULL, &read_req, open_req1.result, &iov, 1, -1, NULL);
779
778
  ASSERT(r >= 0);
780
779
  ASSERT(read_req.result >= 0);
781
780
  ASSERT(strcmp(buf, "test-bu") == 0);
782
781
  uv_fs_req_cleanup(&read_req);
783
782
 
784
- r = uv_fs_close(loop, &close_req, open_req1.result, NULL);
783
+ r = uv_fs_close(NULL, &close_req, open_req1.result, NULL);
785
784
  ASSERT(r == 0);
786
785
  ASSERT(close_req.result == 0);
787
786
  uv_fs_req_cleanup(&close_req);
788
787
 
789
- r = uv_fs_unlink(loop, &unlink_req, "test_file2", NULL);
788
+ r = uv_fs_unlink(NULL, &unlink_req, "test_file2", NULL);
790
789
  ASSERT(r == 0);
791
790
  ASSERT(unlink_req.result == 0);
792
791
  uv_fs_req_cleanup(&unlink_req);
@@ -808,19 +807,19 @@ TEST_IMPL(fs_file_write_null_buffer) {
808
807
 
809
808
  loop = uv_default_loop();
810
809
 
811
- r = uv_fs_open(loop, &open_req1, "test_file", O_WRONLY | O_CREAT,
810
+ r = uv_fs_open(NULL, &open_req1, "test_file", O_WRONLY | O_CREAT,
812
811
  S_IWUSR | S_IRUSR, NULL);
813
812
  ASSERT(r >= 0);
814
813
  ASSERT(open_req1.result >= 0);
815
814
  uv_fs_req_cleanup(&open_req1);
816
815
 
817
816
  iov = uv_buf_init(NULL, 0);
818
- r = uv_fs_write(loop, &write_req, open_req1.result, &iov, 1, -1, NULL);
817
+ r = uv_fs_write(NULL, &write_req, open_req1.result, &iov, 1, -1, NULL);
819
818
  ASSERT(r == 0);
820
819
  ASSERT(write_req.result == 0);
821
820
  uv_fs_req_cleanup(&write_req);
822
821
 
823
- r = uv_fs_close(loop, &close_req, open_req1.result, NULL);
822
+ r = uv_fs_close(NULL, &close_req, open_req1.result, NULL);
824
823
  ASSERT(r == 0);
825
824
  ASSERT(close_req.result == 0);
826
825
  uv_fs_req_cleanup(&close_req);
@@ -850,19 +849,19 @@ TEST_IMPL(fs_async_dir) {
850
849
  ASSERT(mkdir_cb_count == 1);
851
850
 
852
851
  /* Create 2 files synchronously. */
853
- r = uv_fs_open(loop, &open_req1, "test_dir/file1", O_WRONLY | O_CREAT,
852
+ r = uv_fs_open(NULL, &open_req1, "test_dir/file1", O_WRONLY | O_CREAT,
854
853
  S_IWUSR | S_IRUSR, NULL);
855
854
  ASSERT(r >= 0);
856
855
  uv_fs_req_cleanup(&open_req1);
857
- r = uv_fs_close(loop, &close_req, open_req1.result, NULL);
856
+ r = uv_fs_close(NULL, &close_req, open_req1.result, NULL);
858
857
  ASSERT(r == 0);
859
858
  uv_fs_req_cleanup(&close_req);
860
859
 
861
- r = uv_fs_open(loop, &open_req1, "test_dir/file2", O_WRONLY | O_CREAT,
860
+ r = uv_fs_open(NULL, &open_req1, "test_dir/file2", O_WRONLY | O_CREAT,
862
861
  S_IWUSR | S_IRUSR, NULL);
863
862
  ASSERT(r >= 0);
864
863
  uv_fs_req_cleanup(&open_req1);
865
- r = uv_fs_close(loop, &close_req, open_req1.result, NULL);
864
+ r = uv_fs_close(NULL, &close_req, open_req1.result, NULL);
866
865
  ASSERT(r == 0);
867
866
  uv_fs_req_cleanup(&close_req);
868
867
 
@@ -873,7 +872,7 @@ TEST_IMPL(fs_async_dir) {
873
872
  ASSERT(scandir_cb_count == 1);
874
873
 
875
874
  /* sync uv_fs_scandir */
876
- r = uv_fs_scandir(loop, &scandir_req, "test_dir", 0, NULL);
875
+ r = uv_fs_scandir(NULL, &scandir_req, "test_dir", 0, NULL);
877
876
  ASSERT(r == 2);
878
877
  ASSERT(scandir_req.result == 2);
879
878
  ASSERT(scandir_req.ptr);
@@ -957,12 +956,12 @@ TEST_IMPL(fs_async_sendfile) {
957
956
  ASSERT(r == 0);
958
957
 
959
958
  /* Test starts here. */
960
- r = uv_fs_open(loop, &open_req1, "test_file", O_RDWR, 0, NULL);
959
+ r = uv_fs_open(NULL, &open_req1, "test_file", O_RDWR, 0, NULL);
961
960
  ASSERT(r >= 0);
962
961
  ASSERT(open_req1.result >= 0);
963
962
  uv_fs_req_cleanup(&open_req1);
964
963
 
965
- r = uv_fs_open(loop, &open_req2, "test_file2", O_WRONLY | O_CREAT,
964
+ r = uv_fs_open(NULL, &open_req2, "test_file2", O_WRONLY | O_CREAT,
966
965
  S_IWUSR | S_IRUSR, NULL);
967
966
  ASSERT(r >= 0);
968
967
  ASSERT(open_req2.result >= 0);
@@ -975,10 +974,10 @@ TEST_IMPL(fs_async_sendfile) {
975
974
 
976
975
  ASSERT(sendfile_cb_count == 1);
977
976
 
978
- r = uv_fs_close(loop, &close_req, open_req1.result, NULL);
977
+ r = uv_fs_close(NULL, &close_req, open_req1.result, NULL);
979
978
  ASSERT(r == 0);
980
979
  uv_fs_req_cleanup(&close_req);
981
- r = uv_fs_close(loop, &close_req, open_req2.result, NULL);
980
+ r = uv_fs_close(NULL, &close_req, open_req2.result, NULL);
982
981
  ASSERT(r == 0);
983
982
  uv_fs_req_cleanup(&close_req);
984
983
 
@@ -1008,7 +1007,7 @@ TEST_IMPL(fs_mkdtemp) {
1008
1007
  ASSERT(mkdtemp_cb_count == 1);
1009
1008
 
1010
1009
  /* sync mkdtemp */
1011
- r = uv_fs_mkdtemp(loop, &mkdtemp_req2, path_template, NULL);
1010
+ r = uv_fs_mkdtemp(NULL, &mkdtemp_req2, path_template, NULL);
1012
1011
  ASSERT(r == 0);
1013
1012
  check_mkdtemp_result(&mkdtemp_req2);
1014
1013
 
@@ -1040,7 +1039,7 @@ TEST_IMPL(fs_fstat) {
1040
1039
 
1041
1040
  loop = uv_default_loop();
1042
1041
 
1043
- r = uv_fs_open(loop, &req, "test_file", O_RDWR | O_CREAT,
1042
+ r = uv_fs_open(NULL, &req, "test_file", O_RDWR | O_CREAT,
1044
1043
  S_IWUSR | S_IRUSR, NULL);
1045
1044
  ASSERT(r >= 0);
1046
1045
  ASSERT(req.result >= 0);
@@ -1048,12 +1047,12 @@ TEST_IMPL(fs_fstat) {
1048
1047
  uv_fs_req_cleanup(&req);
1049
1048
 
1050
1049
  iov = uv_buf_init(test_buf, sizeof(test_buf));
1051
- r = uv_fs_write(loop, &req, file, &iov, 1, -1, NULL);
1050
+ r = uv_fs_write(NULL, &req, file, &iov, 1, -1, NULL);
1052
1051
  ASSERT(r == sizeof(test_buf));
1053
1052
  ASSERT(req.result == sizeof(test_buf));
1054
1053
  uv_fs_req_cleanup(&req);
1055
1054
 
1056
- r = uv_fs_fstat(loop, &req, file, NULL);
1055
+ r = uv_fs_fstat(NULL, &req, file, NULL);
1057
1056
  ASSERT(r == 0);
1058
1057
  ASSERT(req.result == 0);
1059
1058
  s = req.ptr;
@@ -1130,7 +1129,7 @@ TEST_IMPL(fs_fstat) {
1130
1129
  ASSERT(fstat_cb_count == 1);
1131
1130
 
1132
1131
 
1133
- r = uv_fs_close(loop, &req, file, NULL);
1132
+ r = uv_fs_close(NULL, &req, file, NULL);
1134
1133
  ASSERT(r == 0);
1135
1134
  ASSERT(req.result == 0);
1136
1135
  uv_fs_req_cleanup(&req);
@@ -1161,7 +1160,7 @@ TEST_IMPL(fs_access) {
1161
1160
  loop = uv_default_loop();
1162
1161
 
1163
1162
  /* File should not exist */
1164
- r = uv_fs_access(loop, &req, "test_file", F_OK, NULL);
1163
+ r = uv_fs_access(NULL, &req, "test_file", F_OK, NULL);
1165
1164
  ASSERT(r < 0);
1166
1165
  ASSERT(req.result < 0);
1167
1166
  uv_fs_req_cleanup(&req);
@@ -1174,7 +1173,7 @@ TEST_IMPL(fs_access) {
1174
1173
  access_cb_count = 0; /* reset for the next test */
1175
1174
 
1176
1175
  /* Create file */
1177
- r = uv_fs_open(loop, &req, "test_file", O_RDWR | O_CREAT,
1176
+ r = uv_fs_open(NULL, &req, "test_file", O_RDWR | O_CREAT,
1178
1177
  S_IWUSR | S_IRUSR, NULL);
1179
1178
  ASSERT(r >= 0);
1180
1179
  ASSERT(req.result >= 0);
@@ -1182,7 +1181,7 @@ TEST_IMPL(fs_access) {
1182
1181
  uv_fs_req_cleanup(&req);
1183
1182
 
1184
1183
  /* File should exist */
1185
- r = uv_fs_access(loop, &req, "test_file", F_OK, NULL);
1184
+ r = uv_fs_access(NULL, &req, "test_file", F_OK, NULL);
1186
1185
  ASSERT(r == 0);
1187
1186
  ASSERT(req.result == 0);
1188
1187
  uv_fs_req_cleanup(&req);
@@ -1195,17 +1194,17 @@ TEST_IMPL(fs_access) {
1195
1194
  access_cb_count = 0; /* reset for the next test */
1196
1195
 
1197
1196
  /* Close file */
1198
- r = uv_fs_close(loop, &req, file, NULL);
1197
+ r = uv_fs_close(NULL, &req, file, NULL);
1199
1198
  ASSERT(r == 0);
1200
1199
  ASSERT(req.result == 0);
1201
1200
  uv_fs_req_cleanup(&req);
1202
1201
 
1203
1202
  /* Directory access */
1204
- r = uv_fs_mkdir(loop, &req, "test_dir", 0777, NULL);
1203
+ r = uv_fs_mkdir(NULL, &req, "test_dir", 0777, NULL);
1205
1204
  ASSERT(r == 0);
1206
1205
  uv_fs_req_cleanup(&req);
1207
1206
 
1208
- r = uv_fs_access(loop, &req, "test_dir", W_OK, NULL);
1207
+ r = uv_fs_access(NULL, &req, "test_dir", W_OK, NULL);
1209
1208
  ASSERT(r == 0);
1210
1209
  ASSERT(req.result == 0);
1211
1210
  uv_fs_req_cleanup(&req);
@@ -1235,7 +1234,7 @@ TEST_IMPL(fs_chmod) {
1235
1234
 
1236
1235
  loop = uv_default_loop();
1237
1236
 
1238
- r = uv_fs_open(loop, &req, "test_file", O_RDWR | O_CREAT,
1237
+ r = uv_fs_open(NULL, &req, "test_file", O_RDWR | O_CREAT,
1239
1238
  S_IWUSR | S_IRUSR, NULL);
1240
1239
  ASSERT(r >= 0);
1241
1240
  ASSERT(req.result >= 0);
@@ -1243,14 +1242,14 @@ TEST_IMPL(fs_chmod) {
1243
1242
  uv_fs_req_cleanup(&req);
1244
1243
 
1245
1244
  iov = uv_buf_init(test_buf, sizeof(test_buf));
1246
- r = uv_fs_write(loop, &req, file, &iov, 1, -1, NULL);
1245
+ r = uv_fs_write(NULL, &req, file, &iov, 1, -1, NULL);
1247
1246
  ASSERT(r == sizeof(test_buf));
1248
1247
  ASSERT(req.result == sizeof(test_buf));
1249
1248
  uv_fs_req_cleanup(&req);
1250
1249
 
1251
1250
  #ifndef _WIN32
1252
1251
  /* Make the file write-only */
1253
- r = uv_fs_chmod(loop, &req, "test_file", 0200, NULL);
1252
+ r = uv_fs_chmod(NULL, &req, "test_file", 0200, NULL);
1254
1253
  ASSERT(r == 0);
1255
1254
  ASSERT(req.result == 0);
1256
1255
  uv_fs_req_cleanup(&req);
@@ -1259,7 +1258,7 @@ TEST_IMPL(fs_chmod) {
1259
1258
  #endif
1260
1259
 
1261
1260
  /* Make the file read-only */
1262
- r = uv_fs_chmod(loop, &req, "test_file", 0400, NULL);
1261
+ r = uv_fs_chmod(NULL, &req, "test_file", 0400, NULL);
1263
1262
  ASSERT(r == 0);
1264
1263
  ASSERT(req.result == 0);
1265
1264
  uv_fs_req_cleanup(&req);
@@ -1267,7 +1266,7 @@ TEST_IMPL(fs_chmod) {
1267
1266
  check_permission("test_file", 0400);
1268
1267
 
1269
1268
  /* Make the file read+write with sync uv_fs_fchmod */
1270
- r = uv_fs_fchmod(loop, &req, file, 0600, NULL);
1269
+ r = uv_fs_fchmod(NULL, &req, file, 0600, NULL);
1271
1270
  ASSERT(r == 0);
1272
1271
  ASSERT(req.result == 0);
1273
1272
  uv_fs_req_cleanup(&req);
@@ -1333,7 +1332,7 @@ TEST_IMPL(fs_unlink_readonly) {
1333
1332
 
1334
1333
  loop = uv_default_loop();
1335
1334
 
1336
- r = uv_fs_open(loop,
1335
+ r = uv_fs_open(NULL,
1337
1336
  &req,
1338
1337
  "test_file",
1339
1338
  O_RDWR | O_CREAT,
@@ -1345,7 +1344,7 @@ TEST_IMPL(fs_unlink_readonly) {
1345
1344
  uv_fs_req_cleanup(&req);
1346
1345
 
1347
1346
  iov = uv_buf_init(test_buf, sizeof(test_buf));
1348
- r = uv_fs_write(loop, &req, file, &iov, 1, -1, NULL);
1347
+ r = uv_fs_write(NULL, &req, file, &iov, 1, -1, NULL);
1349
1348
  ASSERT(r == sizeof(test_buf));
1350
1349
  ASSERT(req.result == sizeof(test_buf));
1351
1350
  uv_fs_req_cleanup(&req);
@@ -1353,7 +1352,7 @@ TEST_IMPL(fs_unlink_readonly) {
1353
1352
  close(file);
1354
1353
 
1355
1354
  /* Make the file read-only */
1356
- r = uv_fs_chmod(loop, &req, "test_file", 0400, NULL);
1355
+ r = uv_fs_chmod(NULL, &req, "test_file", 0400, NULL);
1357
1356
  ASSERT(r == 0);
1358
1357
  ASSERT(req.result == 0);
1359
1358
  uv_fs_req_cleanup(&req);
@@ -1361,7 +1360,7 @@ TEST_IMPL(fs_unlink_readonly) {
1361
1360
  check_permission("test_file", 0400);
1362
1361
 
1363
1362
  /* Try to unlink the file */
1364
- r = uv_fs_unlink(loop, &req, "test_file", NULL);
1363
+ r = uv_fs_unlink(NULL, &req, "test_file", NULL);
1365
1364
  ASSERT(r == 0);
1366
1365
  ASSERT(req.result == 0);
1367
1366
  uv_fs_req_cleanup(&req);
@@ -1373,7 +1372,7 @@ TEST_IMPL(fs_unlink_readonly) {
1373
1372
  uv_run(loop, UV_RUN_DEFAULT);
1374
1373
 
1375
1374
  /* Cleanup. */
1376
- uv_fs_chmod(loop, &req, "test_file", 0600, NULL);
1375
+ uv_fs_chmod(NULL, &req, "test_file", 0600, NULL);
1377
1376
  uv_fs_req_cleanup(&req);
1378
1377
  unlink("test_file");
1379
1378
 
@@ -1392,7 +1391,7 @@ TEST_IMPL(fs_chown) {
1392
1391
 
1393
1392
  loop = uv_default_loop();
1394
1393
 
1395
- r = uv_fs_open(loop, &req, "test_file", O_RDWR | O_CREAT,
1394
+ r = uv_fs_open(NULL, &req, "test_file", O_RDWR | O_CREAT,
1396
1395
  S_IWUSR | S_IRUSR, NULL);
1397
1396
  ASSERT(r >= 0);
1398
1397
  ASSERT(req.result >= 0);
@@ -1400,13 +1399,13 @@ TEST_IMPL(fs_chown) {
1400
1399
  uv_fs_req_cleanup(&req);
1401
1400
 
1402
1401
  /* sync chown */
1403
- r = uv_fs_chown(loop, &req, "test_file", -1, -1, NULL);
1402
+ r = uv_fs_chown(NULL, &req, "test_file", -1, -1, NULL);
1404
1403
  ASSERT(r == 0);
1405
1404
  ASSERT(req.result == 0);
1406
1405
  uv_fs_req_cleanup(&req);
1407
1406
 
1408
1407
  /* sync fchown */
1409
- r = uv_fs_fchown(loop, &req, file, -1, -1, NULL);
1408
+ r = uv_fs_fchown(NULL, &req, file, -1, -1, NULL);
1410
1409
  ASSERT(r == 0);
1411
1410
  ASSERT(req.result == 0);
1412
1411
  uv_fs_req_cleanup(&req);
@@ -1458,7 +1457,7 @@ TEST_IMPL(fs_link) {
1458
1457
 
1459
1458
  loop = uv_default_loop();
1460
1459
 
1461
- r = uv_fs_open(loop, &req, "test_file", O_RDWR | O_CREAT,
1460
+ r = uv_fs_open(NULL, &req, "test_file", O_RDWR | O_CREAT,
1462
1461
  S_IWUSR | S_IRUSR, NULL);
1463
1462
  ASSERT(r >= 0);
1464
1463
  ASSERT(req.result >= 0);
@@ -1466,7 +1465,7 @@ TEST_IMPL(fs_link) {
1466
1465
  uv_fs_req_cleanup(&req);
1467
1466
 
1468
1467
  iov = uv_buf_init(test_buf, sizeof(test_buf));
1469
- r = uv_fs_write(loop, &req, file, &iov, 1, -1, NULL);
1468
+ r = uv_fs_write(NULL, &req, file, &iov, 1, -1, NULL);
1470
1469
  ASSERT(r == sizeof(test_buf));
1471
1470
  ASSERT(req.result == sizeof(test_buf));
1472
1471
  uv_fs_req_cleanup(&req);
@@ -1474,12 +1473,12 @@ TEST_IMPL(fs_link) {
1474
1473
  close(file);
1475
1474
 
1476
1475
  /* sync link */
1477
- r = uv_fs_link(loop, &req, "test_file", "test_file_link", NULL);
1476
+ r = uv_fs_link(NULL, &req, "test_file", "test_file_link", NULL);
1478
1477
  ASSERT(r == 0);
1479
1478
  ASSERT(req.result == 0);
1480
1479
  uv_fs_req_cleanup(&req);
1481
1480
 
1482
- r = uv_fs_open(loop, &req, "test_file_link", O_RDWR, 0, NULL);
1481
+ r = uv_fs_open(NULL, &req, "test_file_link", O_RDWR, 0, NULL);
1483
1482
  ASSERT(r >= 0);
1484
1483
  ASSERT(req.result >= 0);
1485
1484
  link = req.result;
@@ -1487,7 +1486,7 @@ TEST_IMPL(fs_link) {
1487
1486
 
1488
1487
  memset(buf, 0, sizeof(buf));
1489
1488
  iov = uv_buf_init(buf, sizeof(buf));
1490
- r = uv_fs_read(loop, &req, link, &iov, 1, 0, NULL);
1489
+ r = uv_fs_read(NULL, &req, link, &iov, 1, 0, NULL);
1491
1490
  ASSERT(r >= 0);
1492
1491
  ASSERT(req.result >= 0);
1493
1492
  ASSERT(strcmp(buf, test_buf) == 0);
@@ -1500,7 +1499,7 @@ TEST_IMPL(fs_link) {
1500
1499
  uv_run(loop, UV_RUN_DEFAULT);
1501
1500
  ASSERT(link_cb_count == 1);
1502
1501
 
1503
- r = uv_fs_open(loop, &req, "test_file_link2", O_RDWR, 0, NULL);
1502
+ r = uv_fs_open(NULL, &req, "test_file_link2", O_RDWR, 0, NULL);
1504
1503
  ASSERT(r >= 0);
1505
1504
  ASSERT(req.result >= 0);
1506
1505
  link = req.result;
@@ -1508,7 +1507,7 @@ TEST_IMPL(fs_link) {
1508
1507
 
1509
1508
  memset(buf, 0, sizeof(buf));
1510
1509
  iov = uv_buf_init(buf, sizeof(buf));
1511
- r = uv_fs_read(loop, &req, link, &iov, 1, 0, NULL);
1510
+ r = uv_fs_read(NULL, &req, link, &iov, 1, 0, NULL);
1512
1511
  ASSERT(r >= 0);
1513
1512
  ASSERT(req.result >= 0);
1514
1513
  ASSERT(strcmp(buf, test_buf) == 0);
@@ -1542,7 +1541,7 @@ TEST_IMPL(fs_readlink) {
1542
1541
  ASSERT(req.result == UV_ENOENT);
1543
1542
  uv_fs_req_cleanup(&req);
1544
1543
 
1545
- ASSERT(UV_ENOENT == uv_fs_readlink(loop, &req, "no_such_file", NULL));
1544
+ ASSERT(UV_ENOENT == uv_fs_readlink(NULL, &req, "no_such_file", NULL));
1546
1545
  ASSERT(req.ptr == NULL);
1547
1546
  ASSERT(req.result == UV_ENOENT);
1548
1547
  uv_fs_req_cleanup(&req);
@@ -1567,7 +1566,7 @@ TEST_IMPL(fs_symlink) {
1567
1566
 
1568
1567
  loop = uv_default_loop();
1569
1568
 
1570
- r = uv_fs_open(loop, &req, "test_file", O_RDWR | O_CREAT,
1569
+ r = uv_fs_open(NULL, &req, "test_file", O_RDWR | O_CREAT,
1571
1570
  S_IWUSR | S_IRUSR, NULL);
1572
1571
  ASSERT(r >= 0);
1573
1572
  ASSERT(req.result >= 0);
@@ -1575,7 +1574,7 @@ TEST_IMPL(fs_symlink) {
1575
1574
  uv_fs_req_cleanup(&req);
1576
1575
 
1577
1576
  iov = uv_buf_init(test_buf, sizeof(test_buf));
1578
- r = uv_fs_write(loop, &req, file, &iov, 1, -1, NULL);
1577
+ r = uv_fs_write(NULL, &req, file, &iov, 1, -1, NULL);
1579
1578
  ASSERT(r == sizeof(test_buf));
1580
1579
  ASSERT(req.result == sizeof(test_buf));
1581
1580
  uv_fs_req_cleanup(&req);
@@ -1583,7 +1582,7 @@ TEST_IMPL(fs_symlink) {
1583
1582
  close(file);
1584
1583
 
1585
1584
  /* sync symlink */
1586
- r = uv_fs_symlink(loop, &req, "test_file", "test_file_symlink", 0, NULL);
1585
+ r = uv_fs_symlink(NULL, &req, "test_file", "test_file_symlink", 0, NULL);
1587
1586
  #ifdef _WIN32
1588
1587
  if (r < 0) {
1589
1588
  if (r == UV_ENOTSUP) {
@@ -1605,7 +1604,7 @@ TEST_IMPL(fs_symlink) {
1605
1604
  ASSERT(req.result == 0);
1606
1605
  uv_fs_req_cleanup(&req);
1607
1606
 
1608
- r = uv_fs_open(loop, &req, "test_file_symlink", O_RDWR, 0, NULL);
1607
+ r = uv_fs_open(NULL, &req, "test_file_symlink", O_RDWR, 0, NULL);
1609
1608
  ASSERT(r >= 0);
1610
1609
  ASSERT(req.result >= 0);
1611
1610
  link = req.result;
@@ -1613,14 +1612,14 @@ TEST_IMPL(fs_symlink) {
1613
1612
 
1614
1613
  memset(buf, 0, sizeof(buf));
1615
1614
  iov = uv_buf_init(buf, sizeof(buf));
1616
- r = uv_fs_read(loop, &req, link, &iov, 1, 0, NULL);
1615
+ r = uv_fs_read(NULL, &req, link, &iov, 1, 0, NULL);
1617
1616
  ASSERT(r >= 0);
1618
1617
  ASSERT(req.result >= 0);
1619
1618
  ASSERT(strcmp(buf, test_buf) == 0);
1620
1619
 
1621
1620
  close(link);
1622
1621
 
1623
- r = uv_fs_symlink(loop,
1622
+ r = uv_fs_symlink(NULL,
1624
1623
  &req,
1625
1624
  "test_file_symlink",
1626
1625
  "test_file_symlink_symlink",
@@ -1629,7 +1628,7 @@ TEST_IMPL(fs_symlink) {
1629
1628
  ASSERT(r == 0);
1630
1629
  uv_fs_req_cleanup(&req);
1631
1630
 
1632
- r = uv_fs_readlink(loop, &req, "test_file_symlink_symlink", NULL);
1631
+ r = uv_fs_readlink(NULL, &req, "test_file_symlink_symlink", NULL);
1633
1632
  ASSERT(r == 0);
1634
1633
  ASSERT(strcmp(req.ptr, "test_file_symlink") == 0);
1635
1634
  uv_fs_req_cleanup(&req);
@@ -1645,7 +1644,7 @@ TEST_IMPL(fs_symlink) {
1645
1644
  uv_run(loop, UV_RUN_DEFAULT);
1646
1645
  ASSERT(symlink_cb_count == 1);
1647
1646
 
1648
- r = uv_fs_open(loop, &req, "test_file_symlink2", O_RDWR, 0, NULL);
1647
+ r = uv_fs_open(NULL, &req, "test_file_symlink2", O_RDWR, 0, NULL);
1649
1648
  ASSERT(r >= 0);
1650
1649
  ASSERT(req.result >= 0);
1651
1650
  link = req.result;
@@ -1653,14 +1652,14 @@ TEST_IMPL(fs_symlink) {
1653
1652
 
1654
1653
  memset(buf, 0, sizeof(buf));
1655
1654
  iov = uv_buf_init(buf, sizeof(buf));
1656
- r = uv_fs_read(loop, &req, link, &iov, 1, 0, NULL);
1655
+ r = uv_fs_read(NULL, &req, link, &iov, 1, 0, NULL);
1657
1656
  ASSERT(r >= 0);
1658
1657
  ASSERT(req.result >= 0);
1659
1658
  ASSERT(strcmp(buf, test_buf) == 0);
1660
1659
 
1661
1660
  close(link);
1662
1661
 
1663
- r = uv_fs_symlink(loop,
1662
+ r = uv_fs_symlink(NULL,
1664
1663
  &req,
1665
1664
  "test_file_symlink2",
1666
1665
  "test_file_symlink2_symlink",
@@ -1706,7 +1705,7 @@ TEST_IMPL(fs_symlink_dir) {
1706
1705
 
1707
1706
  loop = uv_default_loop();
1708
1707
 
1709
- uv_fs_mkdir(loop, &req, "test_dir", 0777, NULL);
1708
+ uv_fs_mkdir(NULL, &req, "test_dir", 0777, NULL);
1710
1709
  uv_fs_req_cleanup(&req);
1711
1710
 
1712
1711
  #ifdef _WIN32
@@ -1723,18 +1722,18 @@ TEST_IMPL(fs_symlink_dir) {
1723
1722
  test_dir = "test_dir";
1724
1723
  #endif
1725
1724
 
1726
- r = uv_fs_symlink(loop, &req, test_dir, "test_dir_symlink",
1725
+ r = uv_fs_symlink(NULL, &req, test_dir, "test_dir_symlink",
1727
1726
  UV_FS_SYMLINK_JUNCTION, NULL);
1728
1727
  ASSERT(r == 0);
1729
1728
  ASSERT(req.result == 0);
1730
1729
  uv_fs_req_cleanup(&req);
1731
1730
 
1732
- r = uv_fs_stat(loop, &req, "test_dir_symlink", NULL);
1731
+ r = uv_fs_stat(NULL, &req, "test_dir_symlink", NULL);
1733
1732
  ASSERT(r == 0);
1734
1733
  ASSERT(((uv_stat_t*)req.ptr)->st_mode & S_IFDIR);
1735
1734
  uv_fs_req_cleanup(&req);
1736
1735
 
1737
- r = uv_fs_lstat(loop, &req, "test_dir_symlink", NULL);
1736
+ r = uv_fs_lstat(NULL, &req, "test_dir_symlink", NULL);
1738
1737
  ASSERT(r == 0);
1739
1738
  ASSERT(((uv_stat_t*)req.ptr)->st_mode & S_IFLNK);
1740
1739
  #ifdef _WIN32
@@ -1744,7 +1743,7 @@ TEST_IMPL(fs_symlink_dir) {
1744
1743
  #endif
1745
1744
  uv_fs_req_cleanup(&req);
1746
1745
 
1747
- r = uv_fs_readlink(loop, &req, "test_dir_symlink", NULL);
1746
+ r = uv_fs_readlink(NULL, &req, "test_dir_symlink", NULL);
1748
1747
  ASSERT(r == 0);
1749
1748
  #ifdef _WIN32
1750
1749
  ASSERT(strcmp(req.ptr, test_dir + 4) == 0);
@@ -1753,23 +1752,23 @@ TEST_IMPL(fs_symlink_dir) {
1753
1752
  #endif
1754
1753
  uv_fs_req_cleanup(&req);
1755
1754
 
1756
- r = uv_fs_open(loop, &open_req1, "test_dir/file1", O_WRONLY | O_CREAT,
1755
+ r = uv_fs_open(NULL, &open_req1, "test_dir/file1", O_WRONLY | O_CREAT,
1757
1756
  S_IWUSR | S_IRUSR, NULL);
1758
1757
  ASSERT(r >= 0);
1759
1758
  uv_fs_req_cleanup(&open_req1);
1760
- r = uv_fs_close(loop, &close_req, open_req1.result, NULL);
1759
+ r = uv_fs_close(NULL, &close_req, open_req1.result, NULL);
1761
1760
  ASSERT(r == 0);
1762
1761
  uv_fs_req_cleanup(&close_req);
1763
1762
 
1764
- r = uv_fs_open(loop, &open_req1, "test_dir/file2", O_WRONLY | O_CREAT,
1763
+ r = uv_fs_open(NULL, &open_req1, "test_dir/file2", O_WRONLY | O_CREAT,
1765
1764
  S_IWUSR | S_IRUSR, NULL);
1766
1765
  ASSERT(r >= 0);
1767
1766
  uv_fs_req_cleanup(&open_req1);
1768
- r = uv_fs_close(loop, &close_req, open_req1.result, NULL);
1767
+ r = uv_fs_close(NULL, &close_req, open_req1.result, NULL);
1769
1768
  ASSERT(r == 0);
1770
1769
  uv_fs_req_cleanup(&close_req);
1771
1770
 
1772
- r = uv_fs_scandir(loop, &scandir_req, "test_dir_symlink", 0, NULL);
1771
+ r = uv_fs_scandir(NULL, &scandir_req, "test_dir_symlink", 0, NULL);
1773
1772
  ASSERT(r == 2);
1774
1773
  ASSERT(scandir_req.result == 2);
1775
1774
  ASSERT(scandir_req.ptr);
@@ -1785,15 +1784,15 @@ TEST_IMPL(fs_symlink_dir) {
1785
1784
  ASSERT(!scandir_req.ptr);
1786
1785
 
1787
1786
  /* unlink will remove the directory symlink */
1788
- r = uv_fs_unlink(loop, &req, "test_dir_symlink", NULL);
1787
+ r = uv_fs_unlink(NULL, &req, "test_dir_symlink", NULL);
1789
1788
  ASSERT(r == 0);
1790
1789
  uv_fs_req_cleanup(&req);
1791
1790
 
1792
- r = uv_fs_scandir(loop, &scandir_req, "test_dir_symlink", 0, NULL);
1791
+ r = uv_fs_scandir(NULL, &scandir_req, "test_dir_symlink", 0, NULL);
1793
1792
  ASSERT(r == UV_ENOENT);
1794
1793
  uv_fs_req_cleanup(&scandir_req);
1795
1794
 
1796
- r = uv_fs_scandir(loop, &scandir_req, "test_dir", 0, NULL);
1795
+ r = uv_fs_scandir(NULL, &scandir_req, "test_dir", 0, NULL);
1797
1796
  ASSERT(r == 2);
1798
1797
  ASSERT(scandir_req.result == 2);
1799
1798
  ASSERT(scandir_req.ptr);
@@ -1830,8 +1829,7 @@ TEST_IMPL(fs_utime) {
1830
1829
  /* Setup. */
1831
1830
  loop = uv_default_loop();
1832
1831
  unlink(path);
1833
- r = uv_fs_open(loop, &req, path, O_RDWR | O_CREAT,
1834
- S_IWUSR | S_IRUSR, NULL);
1832
+ r = uv_fs_open(NULL, &req, path, O_RDWR | O_CREAT, S_IWUSR | S_IRUSR, NULL);
1835
1833
  ASSERT(r >= 0);
1836
1834
  ASSERT(req.result >= 0);
1837
1835
  uv_fs_req_cleanup(&req);
@@ -1839,12 +1837,12 @@ TEST_IMPL(fs_utime) {
1839
1837
 
1840
1838
  atime = mtime = 400497753; /* 1982-09-10 11:22:33 */
1841
1839
 
1842
- r = uv_fs_utime(loop, &req, path, atime, mtime, NULL);
1840
+ r = uv_fs_utime(NULL, &req, path, atime, mtime, NULL);
1843
1841
  ASSERT(r == 0);
1844
1842
  ASSERT(req.result == 0);
1845
1843
  uv_fs_req_cleanup(&req);
1846
1844
 
1847
- r = uv_fs_stat(loop, &req, path, NULL);
1845
+ r = uv_fs_stat(NULL, &req, path, NULL);
1848
1846
  ASSERT(r == 0);
1849
1847
  ASSERT(req.result == 0);
1850
1848
  check_utime(path, atime, mtime);
@@ -1875,26 +1873,26 @@ TEST_IMPL(fs_stat_root) {
1875
1873
  int r;
1876
1874
  uv_loop_t* loop = uv_default_loop();
1877
1875
 
1878
- r = uv_fs_stat(loop, &stat_req, "\\", NULL);
1876
+ r = uv_fs_stat(NULL, &stat_req, "\\", NULL);
1879
1877
  ASSERT(r == 0);
1880
1878
 
1881
- r = uv_fs_stat(loop, &stat_req, "..\\..\\..\\..\\..\\..\\..", NULL);
1879
+ r = uv_fs_stat(NULL, &stat_req, "..\\..\\..\\..\\..\\..\\..", NULL);
1882
1880
  ASSERT(r == 0);
1883
1881
 
1884
- r = uv_fs_stat(loop, &stat_req, "..", NULL);
1882
+ r = uv_fs_stat(NULL, &stat_req, "..", NULL);
1885
1883
  ASSERT(r == 0);
1886
1884
 
1887
- r = uv_fs_stat(loop, &stat_req, "..\\", NULL);
1885
+ r = uv_fs_stat(NULL, &stat_req, "..\\", NULL);
1888
1886
  ASSERT(r == 0);
1889
1887
 
1890
1888
  /* stats the current directory on c: */
1891
- r = uv_fs_stat(loop, &stat_req, "c:", NULL);
1889
+ r = uv_fs_stat(NULL, &stat_req, "c:", NULL);
1892
1890
  ASSERT(r == 0);
1893
1891
 
1894
- r = uv_fs_stat(loop, &stat_req, "c:\\", NULL);
1892
+ r = uv_fs_stat(NULL, &stat_req, "c:\\", NULL);
1895
1893
  ASSERT(r == 0);
1896
1894
 
1897
- r = uv_fs_stat(loop, &stat_req, "\\\\?\\C:\\", NULL);
1895
+ r = uv_fs_stat(NULL, &stat_req, "\\\\?\\C:\\", NULL);
1898
1896
  ASSERT(r == 0);
1899
1897
 
1900
1898
  MAKE_VALGRIND_HAPPY();
@@ -1915,8 +1913,7 @@ TEST_IMPL(fs_futime) {
1915
1913
  /* Setup. */
1916
1914
  loop = uv_default_loop();
1917
1915
  unlink(path);
1918
- r = uv_fs_open(loop, &req, path, O_RDWR | O_CREAT,
1919
- S_IWUSR | S_IRUSR, NULL);
1916
+ r = uv_fs_open(NULL, &req, path, O_RDWR | O_CREAT, S_IWUSR | S_IRUSR, NULL);
1920
1917
  ASSERT(r >= 0);
1921
1918
  ASSERT(req.result >= 0);
1922
1919
  uv_fs_req_cleanup(&req);
@@ -1924,18 +1921,18 @@ TEST_IMPL(fs_futime) {
1924
1921
 
1925
1922
  atime = mtime = 400497753; /* 1982-09-10 11:22:33 */
1926
1923
 
1927
- r = uv_fs_open(loop, &req, path, O_RDWR, 0, NULL);
1924
+ r = uv_fs_open(NULL, &req, path, O_RDWR, 0, NULL);
1928
1925
  ASSERT(r >= 0);
1929
1926
  ASSERT(req.result >= 0);
1930
1927
  file = req.result; /* FIXME probably not how it's supposed to be used */
1931
1928
  uv_fs_req_cleanup(&req);
1932
1929
 
1933
- r = uv_fs_futime(loop, &req, file, atime, mtime, NULL);
1930
+ r = uv_fs_futime(NULL, &req, file, atime, mtime, NULL);
1934
1931
  ASSERT(r == 0);
1935
1932
  ASSERT(req.result == 0);
1936
1933
  uv_fs_req_cleanup(&req);
1937
1934
 
1938
- r = uv_fs_stat(loop, &req, path, NULL);
1935
+ r = uv_fs_stat(NULL, &req, path, NULL);
1939
1936
  ASSERT(r == 0);
1940
1937
  ASSERT(req.result == 0);
1941
1938
  check_utime(path, atime, mtime);
@@ -1968,7 +1965,7 @@ TEST_IMPL(fs_stat_missing_path) {
1968
1965
 
1969
1966
  loop = uv_default_loop();
1970
1967
 
1971
- r = uv_fs_stat(loop, &req, "non_existent_file", NULL);
1968
+ r = uv_fs_stat(NULL, &req, "non_existent_file", NULL);
1972
1969
  ASSERT(r == UV_ENOENT);
1973
1970
  ASSERT(req.result == UV_ENOENT);
1974
1971
  uv_fs_req_cleanup(&req);
@@ -1987,13 +1984,13 @@ TEST_IMPL(fs_scandir_empty_dir) {
1987
1984
  path = "./empty_dir/";
1988
1985
  loop = uv_default_loop();
1989
1986
 
1990
- uv_fs_mkdir(loop, &req, path, 0777, NULL);
1987
+ uv_fs_mkdir(NULL, &req, path, 0777, NULL);
1991
1988
  uv_fs_req_cleanup(&req);
1992
1989
 
1993
1990
  /* Fill the req to ensure that required fields are cleaned up */
1994
1991
  memset(&req, 0xdb, sizeof(req));
1995
1992
 
1996
- r = uv_fs_scandir(loop, &req, path, 0, NULL);
1993
+ r = uv_fs_scandir(NULL, &req, path, 0, NULL);
1997
1994
  ASSERT(r == 0);
1998
1995
  ASSERT(req.result == 0);
1999
1996
  ASSERT(req.ptr == NULL);
@@ -2007,7 +2004,7 @@ TEST_IMPL(fs_scandir_empty_dir) {
2007
2004
  uv_run(loop, UV_RUN_DEFAULT);
2008
2005
  ASSERT(scandir_cb_count == 1);
2009
2006
 
2010
- uv_fs_rmdir(loop, &req, path, NULL);
2007
+ uv_fs_rmdir(NULL, &req, path, NULL);
2011
2008
  uv_fs_req_cleanup(&req);
2012
2009
 
2013
2010
  MAKE_VALGRIND_HAPPY();
@@ -2022,7 +2019,7 @@ TEST_IMPL(fs_scandir_file) {
2022
2019
  path = "test/fixtures/empty_file";
2023
2020
  loop = uv_default_loop();
2024
2021
 
2025
- r = uv_fs_scandir(loop, &scandir_req, path, 0, NULL);
2022
+ r = uv_fs_scandir(NULL, &scandir_req, path, 0, NULL);
2026
2023
  ASSERT(r == UV_ENOTDIR);
2027
2024
  uv_fs_req_cleanup(&scandir_req);
2028
2025
 
@@ -2046,14 +2043,14 @@ TEST_IMPL(fs_open_dir) {
2046
2043
  path = ".";
2047
2044
  loop = uv_default_loop();
2048
2045
 
2049
- r = uv_fs_open(loop, &req, path, O_RDONLY, 0, NULL);
2046
+ r = uv_fs_open(NULL, &req, path, O_RDONLY, 0, NULL);
2050
2047
  ASSERT(r >= 0);
2051
2048
  ASSERT(req.result >= 0);
2052
2049
  ASSERT(req.ptr == NULL);
2053
2050
  file = r;
2054
2051
  uv_fs_req_cleanup(&req);
2055
2052
 
2056
- r = uv_fs_close(loop, &req, file, NULL);
2053
+ r = uv_fs_close(NULL, &req, file, NULL);
2057
2054
  ASSERT(r == 0);
2058
2055
 
2059
2056
  r = uv_fs_open(loop, &req, path, O_RDONLY, 0, open_cb_simple);
@@ -2076,47 +2073,46 @@ TEST_IMPL(fs_file_open_append) {
2076
2073
 
2077
2074
  loop = uv_default_loop();
2078
2075
 
2079
- r = uv_fs_open(loop, &open_req1, "test_file", O_WRONLY | O_CREAT,
2076
+ r = uv_fs_open(NULL, &open_req1, "test_file", O_WRONLY | O_CREAT,
2080
2077
  S_IWUSR | S_IRUSR, NULL);
2081
2078
  ASSERT(r >= 0);
2082
2079
  ASSERT(open_req1.result >= 0);
2083
2080
  uv_fs_req_cleanup(&open_req1);
2084
2081
 
2085
2082
  iov = uv_buf_init(test_buf, sizeof(test_buf));
2086
- r = uv_fs_write(loop, &write_req, open_req1.result, &iov, 1, -1, NULL);
2083
+ r = uv_fs_write(NULL, &write_req, open_req1.result, &iov, 1, -1, NULL);
2087
2084
  ASSERT(r >= 0);
2088
2085
  ASSERT(write_req.result >= 0);
2089
2086
  uv_fs_req_cleanup(&write_req);
2090
2087
 
2091
- r = uv_fs_close(loop, &close_req, open_req1.result, NULL);
2088
+ r = uv_fs_close(NULL, &close_req, open_req1.result, NULL);
2092
2089
  ASSERT(r == 0);
2093
2090
  ASSERT(close_req.result == 0);
2094
2091
  uv_fs_req_cleanup(&close_req);
2095
2092
 
2096
- r = uv_fs_open(loop, &open_req1, "test_file", O_RDWR | O_APPEND, 0, NULL);
2093
+ r = uv_fs_open(NULL, &open_req1, "test_file", O_RDWR | O_APPEND, 0, NULL);
2097
2094
  ASSERT(r >= 0);
2098
2095
  ASSERT(open_req1.result >= 0);
2099
2096
  uv_fs_req_cleanup(&open_req1);
2100
2097
 
2101
2098
  iov = uv_buf_init(test_buf, sizeof(test_buf));
2102
- r = uv_fs_write(loop, &write_req, open_req1.result, &iov, 1, -1, NULL);
2099
+ r = uv_fs_write(NULL, &write_req, open_req1.result, &iov, 1, -1, NULL);
2103
2100
  ASSERT(r >= 0);
2104
2101
  ASSERT(write_req.result >= 0);
2105
2102
  uv_fs_req_cleanup(&write_req);
2106
2103
 
2107
- r = uv_fs_close(loop, &close_req, open_req1.result, NULL);
2104
+ r = uv_fs_close(NULL, &close_req, open_req1.result, NULL);
2108
2105
  ASSERT(r == 0);
2109
2106
  ASSERT(close_req.result == 0);
2110
2107
  uv_fs_req_cleanup(&close_req);
2111
2108
 
2112
- r = uv_fs_open(loop, &open_req1, "test_file", O_RDONLY, S_IRUSR, NULL);
2109
+ r = uv_fs_open(NULL, &open_req1, "test_file", O_RDONLY, S_IRUSR, NULL);
2113
2110
  ASSERT(r >= 0);
2114
2111
  ASSERT(open_req1.result >= 0);
2115
2112
  uv_fs_req_cleanup(&open_req1);
2116
2113
 
2117
2114
  iov = uv_buf_init(buf, sizeof(buf));
2118
- r = uv_fs_read(loop, &read_req, open_req1.result, &iov, 1, -1,
2119
- NULL);
2115
+ r = uv_fs_read(NULL, &read_req, open_req1.result, &iov, 1, -1, NULL);
2120
2116
  printf("read = %d\n", r);
2121
2117
  ASSERT(r == 26);
2122
2118
  ASSERT(read_req.result == 26);
@@ -2125,7 +2121,7 @@ TEST_IMPL(fs_file_open_append) {
2125
2121
  sizeof("test-buffer\n\0test-buffer\n\0") - 1) == 0);
2126
2122
  uv_fs_req_cleanup(&read_req);
2127
2123
 
2128
- r = uv_fs_close(loop, &close_req, open_req1.result, NULL);
2124
+ r = uv_fs_close(NULL, &close_req, open_req1.result, NULL);
2129
2125
  ASSERT(r == 0);
2130
2126
  ASSERT(close_req.result == 0);
2131
2127
  uv_fs_req_cleanup(&close_req);
@@ -2147,54 +2143,53 @@ TEST_IMPL(fs_rename_to_existing_file) {
2147
2143
 
2148
2144
  loop = uv_default_loop();
2149
2145
 
2150
- r = uv_fs_open(loop, &open_req1, "test_file", O_WRONLY | O_CREAT,
2146
+ r = uv_fs_open(NULL, &open_req1, "test_file", O_WRONLY | O_CREAT,
2151
2147
  S_IWUSR | S_IRUSR, NULL);
2152
2148
  ASSERT(r >= 0);
2153
2149
  ASSERT(open_req1.result >= 0);
2154
2150
  uv_fs_req_cleanup(&open_req1);
2155
2151
 
2156
2152
  iov = uv_buf_init(test_buf, sizeof(test_buf));
2157
- r = uv_fs_write(loop, &write_req, open_req1.result, &iov, 1, -1, NULL);
2153
+ r = uv_fs_write(NULL, &write_req, open_req1.result, &iov, 1, -1, NULL);
2158
2154
  ASSERT(r >= 0);
2159
2155
  ASSERT(write_req.result >= 0);
2160
2156
  uv_fs_req_cleanup(&write_req);
2161
2157
 
2162
- r = uv_fs_close(loop, &close_req, open_req1.result, NULL);
2158
+ r = uv_fs_close(NULL, &close_req, open_req1.result, NULL);
2163
2159
  ASSERT(r == 0);
2164
2160
  ASSERT(close_req.result == 0);
2165
2161
  uv_fs_req_cleanup(&close_req);
2166
2162
 
2167
- r = uv_fs_open(loop, &open_req1, "test_file2", O_WRONLY | O_CREAT,
2163
+ r = uv_fs_open(NULL, &open_req1, "test_file2", O_WRONLY | O_CREAT,
2168
2164
  S_IWUSR | S_IRUSR, NULL);
2169
2165
  ASSERT(r >= 0);
2170
2166
  ASSERT(open_req1.result >= 0);
2171
2167
  uv_fs_req_cleanup(&open_req1);
2172
2168
 
2173
- r = uv_fs_close(loop, &close_req, open_req1.result, NULL);
2169
+ r = uv_fs_close(NULL, &close_req, open_req1.result, NULL);
2174
2170
  ASSERT(r == 0);
2175
2171
  ASSERT(close_req.result == 0);
2176
2172
  uv_fs_req_cleanup(&close_req);
2177
2173
 
2178
- r = uv_fs_rename(loop, &rename_req, "test_file", "test_file2", NULL);
2174
+ r = uv_fs_rename(NULL, &rename_req, "test_file", "test_file2", NULL);
2179
2175
  ASSERT(r == 0);
2180
2176
  ASSERT(rename_req.result == 0);
2181
2177
  uv_fs_req_cleanup(&rename_req);
2182
2178
 
2183
- r = uv_fs_open(loop, &open_req1, "test_file2", O_RDONLY, 0, NULL);
2179
+ r = uv_fs_open(NULL, &open_req1, "test_file2", O_RDONLY, 0, NULL);
2184
2180
  ASSERT(r >= 0);
2185
2181
  ASSERT(open_req1.result >= 0);
2186
2182
  uv_fs_req_cleanup(&open_req1);
2187
2183
 
2188
2184
  memset(buf, 0, sizeof(buf));
2189
2185
  iov = uv_buf_init(buf, sizeof(buf));
2190
- r = uv_fs_read(loop, &read_req, open_req1.result, &iov, 1, -1,
2191
- NULL);
2186
+ r = uv_fs_read(NULL, &read_req, open_req1.result, &iov, 1, -1, NULL);
2192
2187
  ASSERT(r >= 0);
2193
2188
  ASSERT(read_req.result >= 0);
2194
2189
  ASSERT(strcmp(buf, test_buf) == 0);
2195
2190
  uv_fs_req_cleanup(&read_req);
2196
2191
 
2197
- r = uv_fs_close(loop, &close_req, open_req1.result, NULL);
2192
+ r = uv_fs_close(NULL, &close_req, open_req1.result, NULL);
2198
2193
  ASSERT(r == 0);
2199
2194
  ASSERT(close_req.result == 0);
2200
2195
  uv_fs_req_cleanup(&close_req);
@@ -2216,44 +2211,44 @@ TEST_IMPL(fs_read_file_eof) {
2216
2211
 
2217
2212
  loop = uv_default_loop();
2218
2213
 
2219
- r = uv_fs_open(loop, &open_req1, "test_file", O_WRONLY | O_CREAT,
2214
+ r = uv_fs_open(NULL, &open_req1, "test_file", O_WRONLY | O_CREAT,
2220
2215
  S_IWUSR | S_IRUSR, NULL);
2221
2216
  ASSERT(r >= 0);
2222
2217
  ASSERT(open_req1.result >= 0);
2223
2218
  uv_fs_req_cleanup(&open_req1);
2224
2219
 
2225
2220
  iov = uv_buf_init(test_buf, sizeof(test_buf));
2226
- r = uv_fs_write(loop, &write_req, open_req1.result, &iov, 1, -1, NULL);
2221
+ r = uv_fs_write(NULL, &write_req, open_req1.result, &iov, 1, -1, NULL);
2227
2222
  ASSERT(r >= 0);
2228
2223
  ASSERT(write_req.result >= 0);
2229
2224
  uv_fs_req_cleanup(&write_req);
2230
2225
 
2231
- r = uv_fs_close(loop, &close_req, open_req1.result, NULL);
2226
+ r = uv_fs_close(NULL, &close_req, open_req1.result, NULL);
2232
2227
  ASSERT(r == 0);
2233
2228
  ASSERT(close_req.result == 0);
2234
2229
  uv_fs_req_cleanup(&close_req);
2235
2230
 
2236
- r = uv_fs_open(loop, &open_req1, "test_file", O_RDONLY, 0, NULL);
2231
+ r = uv_fs_open(NULL, &open_req1, "test_file", O_RDONLY, 0, NULL);
2237
2232
  ASSERT(r >= 0);
2238
2233
  ASSERT(open_req1.result >= 0);
2239
2234
  uv_fs_req_cleanup(&open_req1);
2240
2235
 
2241
2236
  memset(buf, 0, sizeof(buf));
2242
2237
  iov = uv_buf_init(buf, sizeof(buf));
2243
- r = uv_fs_read(loop, &read_req, open_req1.result, &iov, 1, -1, NULL);
2238
+ r = uv_fs_read(NULL, &read_req, open_req1.result, &iov, 1, -1, NULL);
2244
2239
  ASSERT(r >= 0);
2245
2240
  ASSERT(read_req.result >= 0);
2246
2241
  ASSERT(strcmp(buf, test_buf) == 0);
2247
2242
  uv_fs_req_cleanup(&read_req);
2248
2243
 
2249
2244
  iov = uv_buf_init(buf, sizeof(buf));
2250
- r = uv_fs_read(loop, &read_req, open_req1.result, &iov, 1,
2245
+ r = uv_fs_read(NULL, &read_req, open_req1.result, &iov, 1,
2251
2246
  read_req.result, NULL);
2252
2247
  ASSERT(r == 0);
2253
2248
  ASSERT(read_req.result == 0);
2254
2249
  uv_fs_req_cleanup(&read_req);
2255
2250
 
2256
- r = uv_fs_close(loop, &close_req, open_req1.result, NULL);
2251
+ r = uv_fs_close(NULL, &close_req, open_req1.result, NULL);
2257
2252
  ASSERT(r == 0);
2258
2253
  ASSERT(close_req.result == 0);
2259
2254
  uv_fs_req_cleanup(&close_req);
@@ -2275,7 +2270,7 @@ TEST_IMPL(fs_write_multiple_bufs) {
2275
2270
 
2276
2271
  loop = uv_default_loop();
2277
2272
 
2278
- r = uv_fs_open(loop, &open_req1, "test_file", O_WRONLY | O_CREAT,
2273
+ r = uv_fs_open(NULL, &open_req1, "test_file", O_WRONLY | O_CREAT,
2279
2274
  S_IWUSR | S_IRUSR, NULL);
2280
2275
  ASSERT(r >= 0);
2281
2276
  ASSERT(open_req1.result >= 0);
@@ -2283,17 +2278,17 @@ TEST_IMPL(fs_write_multiple_bufs) {
2283
2278
 
2284
2279
  iovs[0] = uv_buf_init(test_buf, sizeof(test_buf));
2285
2280
  iovs[1] = uv_buf_init(test_buf2, sizeof(test_buf2));
2286
- r = uv_fs_write(loop, &write_req, open_req1.result, iovs, 2, 0, NULL);
2281
+ r = uv_fs_write(NULL, &write_req, open_req1.result, iovs, 2, 0, NULL);
2287
2282
  ASSERT(r >= 0);
2288
2283
  ASSERT(write_req.result >= 0);
2289
2284
  uv_fs_req_cleanup(&write_req);
2290
2285
 
2291
- r = uv_fs_close(loop, &close_req, open_req1.result, NULL);
2286
+ r = uv_fs_close(NULL, &close_req, open_req1.result, NULL);
2292
2287
  ASSERT(r == 0);
2293
2288
  ASSERT(close_req.result == 0);
2294
2289
  uv_fs_req_cleanup(&close_req);
2295
2290
 
2296
- r = uv_fs_open(loop, &open_req1, "test_file", O_RDONLY, 0, NULL);
2291
+ r = uv_fs_open(NULL, &open_req1, "test_file", O_RDONLY, 0, NULL);
2297
2292
  ASSERT(r >= 0);
2298
2293
  ASSERT(open_req1.result >= 0);
2299
2294
  uv_fs_req_cleanup(&open_req1);
@@ -2303,7 +2298,7 @@ TEST_IMPL(fs_write_multiple_bufs) {
2303
2298
  /* Read the strings back to separate buffers. */
2304
2299
  iovs[0] = uv_buf_init(buf, sizeof(test_buf));
2305
2300
  iovs[1] = uv_buf_init(buf2, sizeof(test_buf2));
2306
- r = uv_fs_read(loop, &read_req, open_req1.result, iovs, 2, 0, NULL);
2301
+ r = uv_fs_read(NULL, &read_req, open_req1.result, iovs, 2, 0, NULL);
2307
2302
  ASSERT(r >= 0);
2308
2303
  ASSERT(read_req.result >= 0);
2309
2304
  ASSERT(strcmp(buf, test_buf) == 0);
@@ -2311,13 +2306,13 @@ TEST_IMPL(fs_write_multiple_bufs) {
2311
2306
  uv_fs_req_cleanup(&read_req);
2312
2307
 
2313
2308
  iov = uv_buf_init(buf, sizeof(buf));
2314
- r = uv_fs_read(loop, &read_req, open_req1.result, &iov, 1,
2309
+ r = uv_fs_read(NULL, &read_req, open_req1.result, &iov, 1,
2315
2310
  read_req.result, NULL);
2316
2311
  ASSERT(r == 0);
2317
2312
  ASSERT(read_req.result == 0);
2318
2313
  uv_fs_req_cleanup(&read_req);
2319
2314
 
2320
- r = uv_fs_close(loop, &close_req, open_req1.result, NULL);
2315
+ r = uv_fs_close(NULL, &close_req, open_req1.result, NULL);
2321
2316
  ASSERT(r == 0);
2322
2317
  ASSERT(close_req.result == 0);
2323
2318
  uv_fs_req_cleanup(&close_req);
@@ -2345,7 +2340,7 @@ TEST_IMPL(fs_write_alotof_bufs) {
2345
2340
  iovs = malloc(sizeof(*iovs) * iovcount);
2346
2341
  ASSERT(iovs != NULL);
2347
2342
 
2348
- r = uv_fs_open(loop,
2343
+ r = uv_fs_open(NULL,
2349
2344
  &open_req1,
2350
2345
  "test_file",
2351
2346
  O_RDWR | O_CREAT,
@@ -2358,7 +2353,7 @@ TEST_IMPL(fs_write_alotof_bufs) {
2358
2353
  for (index = 0; index < iovcount; ++index)
2359
2354
  iovs[index] = uv_buf_init(test_buf, sizeof(test_buf));
2360
2355
 
2361
- r = uv_fs_write(loop,
2356
+ r = uv_fs_write(NULL,
2362
2357
  &write_req,
2363
2358
  open_req1.result,
2364
2359
  iovs,
@@ -2377,7 +2372,7 @@ TEST_IMPL(fs_write_alotof_bufs) {
2377
2372
  iovs[index] = uv_buf_init(buffer + index * sizeof(test_buf),
2378
2373
  sizeof(test_buf));
2379
2374
 
2380
- r = uv_fs_read(loop, &read_req, open_req1.result, iovs, iovcount, 0, NULL);
2375
+ r = uv_fs_read(NULL, &read_req, open_req1.result, iovs, iovcount, 0, NULL);
2381
2376
  ASSERT(r >= 0);
2382
2377
  ASSERT((size_t)read_req.result == sizeof(test_buf) * iovcount);
2383
2378
 
@@ -2390,7 +2385,7 @@ TEST_IMPL(fs_write_alotof_bufs) {
2390
2385
  free(buffer);
2391
2386
 
2392
2387
  iov = uv_buf_init(buf, sizeof(buf));
2393
- r = uv_fs_read(loop,
2388
+ r = uv_fs_read(NULL,
2394
2389
  &read_req,
2395
2390
  open_req1.result,
2396
2391
  &iov,
@@ -2401,7 +2396,7 @@ TEST_IMPL(fs_write_alotof_bufs) {
2401
2396
  ASSERT(read_req.result == 0);
2402
2397
  uv_fs_req_cleanup(&read_req);
2403
2398
 
2404
- r = uv_fs_close(loop, &close_req, open_req1.result, NULL);
2399
+ r = uv_fs_close(NULL, &close_req, open_req1.result, NULL);
2405
2400
  ASSERT(r == 0);
2406
2401
  ASSERT(close_req.result == 0);
2407
2402
  uv_fs_req_cleanup(&close_req);
@@ -2433,7 +2428,7 @@ TEST_IMPL(fs_write_alotof_bufs_with_offset) {
2433
2428
  iovs = malloc(sizeof(*iovs) * iovcount);
2434
2429
  ASSERT(iovs != NULL);
2435
2430
 
2436
- r = uv_fs_open(loop,
2431
+ r = uv_fs_open(NULL,
2437
2432
  &open_req1,
2438
2433
  "test_file",
2439
2434
  O_RDWR | O_CREAT,
@@ -2444,7 +2439,7 @@ TEST_IMPL(fs_write_alotof_bufs_with_offset) {
2444
2439
  uv_fs_req_cleanup(&open_req1);
2445
2440
 
2446
2441
  iov = uv_buf_init(filler, filler_len);
2447
- r = uv_fs_write(loop, &write_req, open_req1.result, &iov, 1, -1, NULL);
2442
+ r = uv_fs_write(NULL, &write_req, open_req1.result, &iov, 1, -1, NULL);
2448
2443
  ASSERT(r == filler_len);
2449
2444
  ASSERT(write_req.result == filler_len);
2450
2445
  uv_fs_req_cleanup(&write_req);
@@ -2453,7 +2448,7 @@ TEST_IMPL(fs_write_alotof_bufs_with_offset) {
2453
2448
  for (index = 0; index < iovcount; ++index)
2454
2449
  iovs[index] = uv_buf_init(test_buf, sizeof(test_buf));
2455
2450
 
2456
- r = uv_fs_write(loop,
2451
+ r = uv_fs_write(NULL,
2457
2452
  &write_req,
2458
2453
  open_req1.result,
2459
2454
  iovs,
@@ -2472,7 +2467,8 @@ TEST_IMPL(fs_write_alotof_bufs_with_offset) {
2472
2467
  iovs[index] = uv_buf_init(buffer + index * sizeof(test_buf),
2473
2468
  sizeof(test_buf));
2474
2469
 
2475
- r = uv_fs_read(loop, &read_req, open_req1.result, iovs, iovcount, offset, NULL);
2470
+ r = uv_fs_read(NULL, &read_req, open_req1.result,
2471
+ iovs, iovcount, offset, NULL);
2476
2472
  ASSERT(r >= 0);
2477
2473
  ASSERT(read_req.result == sizeof(test_buf) * iovcount);
2478
2474
 
@@ -2484,14 +2480,14 @@ TEST_IMPL(fs_write_alotof_bufs_with_offset) {
2484
2480
  uv_fs_req_cleanup(&read_req);
2485
2481
  free(buffer);
2486
2482
 
2487
- r = uv_fs_stat(loop, &stat_req, "test_file", NULL);
2483
+ r = uv_fs_stat(NULL, &stat_req, "test_file", NULL);
2488
2484
  ASSERT(r == 0);
2489
2485
  ASSERT((int64_t)((uv_stat_t*)stat_req.ptr)->st_size ==
2490
2486
  offset + (int64_t)(iovcount * sizeof(test_buf)));
2491
2487
  uv_fs_req_cleanup(&stat_req);
2492
2488
 
2493
2489
  iov = uv_buf_init(buf, sizeof(buf));
2494
- r = uv_fs_read(loop,
2490
+ r = uv_fs_read(NULL,
2495
2491
  &read_req,
2496
2492
  open_req1.result,
2497
2493
  &iov,
@@ -2502,7 +2498,7 @@ TEST_IMPL(fs_write_alotof_bufs_with_offset) {
2502
2498
  ASSERT(read_req.result == 0);
2503
2499
  uv_fs_req_cleanup(&read_req);
2504
2500
 
2505
- r = uv_fs_close(loop, &close_req, open_req1.result, NULL);
2501
+ r = uv_fs_close(NULL, &close_req, open_req1.result, NULL);
2506
2502
  ASSERT(r == 0);
2507
2503
  ASSERT(close_req.result == 0);
2508
2504
  uv_fs_req_cleanup(&close_req);
@@ -2514,3 +2510,24 @@ TEST_IMPL(fs_write_alotof_bufs_with_offset) {
2514
2510
  MAKE_VALGRIND_HAPPY();
2515
2511
  return 0;
2516
2512
  }
2513
+
2514
+
2515
+ TEST_IMPL(fs_read_write_null_arguments) {
2516
+ int r;
2517
+
2518
+ r = uv_fs_read(NULL, NULL, 0, NULL, 0, -1, NULL);
2519
+ ASSERT(r == UV_EINVAL);
2520
+
2521
+ r = uv_fs_write(NULL, NULL, 0, NULL, 0, -1, NULL);
2522
+ ASSERT(r == UV_EINVAL);
2523
+
2524
+ iov = uv_buf_init(NULL, 0);
2525
+ r = uv_fs_read(NULL, NULL, 0, &iov, 0, -1, NULL);
2526
+ ASSERT(r == UV_EINVAL);
2527
+
2528
+ iov = uv_buf_init(NULL, 0);
2529
+ r = uv_fs_write(NULL, NULL, 0, &iov, 0, -1, NULL);
2530
+ ASSERT(r == UV_EINVAL);
2531
+
2532
+ return 0;
2533
+ }