@@ -533,17 +533,19 @@ fio_close(int fd)
533
533
{
534
534
if (fio_is_remote_fd (fd ))
535
535
{
536
- fio_header hdr ;
536
+ fio_header hdr = {
537
+ .cop = FIO_CLOSE ,
538
+ .handle = fd & ~FIO_PIPE_MARKER ,
539
+ .size = 0 ,
540
+ .arg = 0 ,
541
+ };
537
542
538
- hdr .cop = FIO_CLOSE ;
539
- hdr .handle = fd & ~FIO_PIPE_MARKER ;
540
- hdr .size = 0 ;
541
543
fio_fdset &= ~(1 << hdr .handle );
542
-
543
544
IO_CHECK (fio_write_all (fio_stdout , & hdr , sizeof (hdr )), sizeof (hdr ));
544
545
545
546
/* Wait for response */
546
547
IO_CHECK (fio_read_all (fio_stdin , & hdr , sizeof (hdr )), sizeof (hdr ));
548
+ Assert (hdr .arg == FIO_CLOSE );
547
549
548
550
if (hdr .arg != 0 )
549
551
{
@@ -563,10 +565,12 @@ fio_close(int fd)
563
565
static void
564
566
fio_close_impl (int fd , int out )
565
567
{
566
- fio_header hdr ;
567
-
568
- hdr .cop = FIO_CLOSE ;
569
- hdr .arg = 0 ;
568
+ fio_header hdr = {
569
+ .cop = FIO_CLOSE ,
570
+ .handle = -1 ,
571
+ .size = 0 ,
572
+ .arg = 0 ,
573
+ };
570
574
571
575
if (close (fd ) != 0 )
572
576
hdr .arg = errno ;
@@ -592,12 +596,12 @@ fio_truncate(int fd, off_t size)
592
596
{
593
597
if (fio_is_remote_fd (fd ))
594
598
{
595
- fio_header hdr ;
596
-
597
- hdr . cop = FIO_TRUNCATE ;
598
- hdr . handle = fd & ~ FIO_PIPE_MARKER ;
599
- hdr . size = 0 ;
600
- hdr . arg = size ;
599
+ fio_header hdr = {
600
+ . cop = FIO_TRUNCATE ,
601
+ . handle = fd & ~ FIO_PIPE_MARKER ,
602
+ . size = 0 ,
603
+ . arg = size ,
604
+ } ;
601
605
602
606
IO_CHECK (fio_write_all (fio_stdout , & hdr , sizeof (hdr )), sizeof (hdr ));
603
607
@@ -745,17 +749,19 @@ fio_write(int fd, void const* buf, size_t size)
745
749
{
746
750
if (fio_is_remote_fd (fd ))
747
751
{
748
- fio_header hdr ;
749
-
750
- hdr .cop = FIO_WRITE ;
751
- hdr .handle = fd & ~FIO_PIPE_MARKER ;
752
- hdr .size = size ;
752
+ fio_header hdr = {
753
+ .cop = FIO_WRITE ,
754
+ .handle = fd & ~FIO_PIPE_MARKER ,
755
+ .size = size ,
756
+ .arg = 0 ,
757
+ };
753
758
754
759
IO_CHECK (fio_write_all (fio_stdout , & hdr , sizeof (hdr )), sizeof (hdr ));
755
760
IO_CHECK (fio_write_all (fio_stdout , buf , size ), size );
756
761
757
762
/* check results */
758
763
IO_CHECK (fio_read_all (fio_stdin , & hdr , sizeof (hdr )), sizeof (hdr ));
764
+ Assert (hdr .arg == FIO_WRITE );
759
765
760
766
/* set errno */
761
767
if (hdr .arg > 0 )
@@ -775,14 +781,16 @@ fio_write(int fd, void const* buf, size_t size)
775
781
static void
776
782
fio_write_impl (int fd , void const * buf , size_t size , int out )
777
783
{
784
+ fio_header hdr = {
785
+ .cop = FIO_WRITE ,
786
+ .handle = -1 ,
787
+ .size = 0 ,
788
+ .arg = 0 ,
789
+ };
778
790
int rc ;
779
- fio_header hdr ;
780
791
781
792
rc = durable_write (fd , buf , size );
782
793
783
- hdr .arg = 0 ;
784
- hdr .size = 0 ;
785
-
786
794
if (rc < 0 )
787
795
hdr .arg = errno ;
788
796
@@ -810,19 +818,19 @@ fio_write_async(int fd, void const* buf, size_t size)
810
818
811
819
if (fio_is_remote_fd (fd ))
812
820
{
813
- fio_header hdr ;
814
-
815
- hdr .cop = FIO_WRITE_ASYNC ;
816
- hdr .handle = fd & ~FIO_PIPE_MARKER ;
817
- hdr .size = size ;
821
+ fio_header hdr = {
822
+ .cop = FIO_WRITE_ASYNC ,
823
+ .handle = fd & ~FIO_PIPE_MARKER ,
824
+ .size = size ,
825
+ .arg = 0 ,
826
+ };
818
827
819
828
IO_CHECK (fio_write_all (fio_stdout , & hdr , sizeof (hdr )), sizeof (hdr ));
820
829
IO_CHECK (fio_write_all (fio_stdout , buf , size ), size );
830
+ return size ;
821
831
}
822
832
else
823
833
return durable_write (fd , buf , size );
824
-
825
- return size ;
826
834
}
827
835
828
836
static void
@@ -1019,12 +1027,12 @@ fio_read(int fd, void* buf, size_t size)
1019
1027
{
1020
1028
if (fio_is_remote_fd (fd ))
1021
1029
{
1022
- fio_header hdr ;
1023
-
1024
- hdr . cop = FIO_READ ;
1025
- hdr . handle = fd & ~ FIO_PIPE_MARKER ;
1026
- hdr . size = 0 ;
1027
- hdr . arg = size ;
1030
+ fio_header hdr = {
1031
+ . cop = FIO_READ ,
1032
+ . handle = fd & ~ FIO_PIPE_MARKER ,
1033
+ . size = 0 ,
1034
+ . arg = size ,
1035
+ } ;
1028
1036
1029
1037
IO_CHECK (fio_write_all (fio_stdout , & hdr , sizeof (hdr )), sizeof (hdr ));
1030
1038
@@ -1046,16 +1054,15 @@ fio_stat(fio_location location, const char* path, struct stat* st, bool follow_s
1046
1054
{
1047
1055
if (fio_is_remote (location ))
1048
1056
{
1049
- fio_header hdr ;
1050
- size_t path_len = strlen (path ) + 1 ;
1051
-
1052
- hdr .cop = FIO_STAT ;
1053
- hdr .handle = -1 ;
1054
- hdr .arg = follow_symlink ;
1055
- hdr .size = path_len ;
1057
+ fio_header hdr = {
1058
+ .cop = FIO_STAT ,
1059
+ .handle = -1 ,
1060
+ .size = strlen (path ) + 1 ,
1061
+ .arg = follow_symlink ,
1062
+ };
1056
1063
1057
1064
IO_CHECK (fio_write_all (fio_stdout , & hdr , sizeof (hdr )), sizeof (hdr ));
1058
- IO_CHECK (fio_write_all (fio_stdout , path , path_len ), path_len );
1065
+ IO_CHECK (fio_write_all (fio_stdout , path , hdr . size ), hdr . size );
1059
1066
1060
1067
IO_CHECK (fio_read_all (fio_stdin , & hdr , sizeof (hdr )), sizeof (hdr ));
1061
1068
Assert (hdr .cop == FIO_STAT );
0 commit comments