@@ -603,17 +603,19 @@ fio_close(int fd)
603
603
{
604
604
if (fio_is_remote_fd (fd ))
605
605
{
606
- fio_header hdr ;
606
+ fio_header hdr = {
607
+ .cop = FIO_CLOSE ,
608
+ .handle = fd & ~FIO_PIPE_MARKER ,
609
+ .size = 0 ,
610
+ .arg = 0 ,
611
+ };
607
612
608
- hdr .cop = FIO_CLOSE ;
609
- hdr .handle = fd & ~FIO_PIPE_MARKER ;
610
- hdr .size = 0 ;
611
613
fio_fdset &= ~(1 << hdr .handle );
612
-
613
614
IO_CHECK (fio_write_all (fio_stdout , & hdr , sizeof (hdr )), sizeof (hdr ));
614
615
615
616
/* Wait for response */
616
617
IO_CHECK (fio_read_all (fio_stdin , & hdr , sizeof (hdr )), sizeof (hdr ));
618
+ Assert (hdr .arg == FIO_CLOSE );
617
619
618
620
if (hdr .arg != 0 )
619
621
{
@@ -633,10 +635,12 @@ fio_close(int fd)
633
635
static void
634
636
fio_close_impl (int fd , int out )
635
637
{
636
- fio_header hdr ;
637
-
638
- hdr .cop = FIO_CLOSE ;
639
- hdr .arg = 0 ;
638
+ fio_header hdr = {
639
+ .cop = FIO_CLOSE ,
640
+ .handle = -1 ,
641
+ .size = 0 ,
642
+ .arg = 0 ,
643
+ };
640
644
641
645
if (close (fd ) != 0 )
642
646
hdr .arg = errno ;
@@ -662,12 +666,12 @@ fio_truncate(int fd, off_t size)
662
666
{
663
667
if (fio_is_remote_fd (fd ))
664
668
{
665
- fio_header hdr ;
666
-
667
- hdr . cop = FIO_TRUNCATE ;
668
- hdr . handle = fd & ~ FIO_PIPE_MARKER ;
669
- hdr . size = 0 ;
670
- hdr . arg = size ;
669
+ fio_header hdr = {
670
+ . cop = FIO_TRUNCATE ,
671
+ . handle = fd & ~ FIO_PIPE_MARKER ,
672
+ . size = 0 ,
673
+ . arg = size ,
674
+ } ;
671
675
672
676
IO_CHECK (fio_write_all (fio_stdout , & hdr , sizeof (hdr )), sizeof (hdr ));
673
677
@@ -815,17 +819,19 @@ fio_write(int fd, void const* buf, size_t size)
815
819
{
816
820
if (fio_is_remote_fd (fd ))
817
821
{
818
- fio_header hdr ;
819
-
820
- hdr .cop = FIO_WRITE ;
821
- hdr .handle = fd & ~FIO_PIPE_MARKER ;
822
- hdr .size = size ;
822
+ fio_header hdr = {
823
+ .cop = FIO_WRITE ,
824
+ .handle = fd & ~FIO_PIPE_MARKER ,
825
+ .size = size ,
826
+ .arg = 0 ,
827
+ };
823
828
824
829
IO_CHECK (fio_write_all (fio_stdout , & hdr , sizeof (hdr )), sizeof (hdr ));
825
830
IO_CHECK (fio_write_all (fio_stdout , buf , size ), size );
826
831
827
832
/* check results */
828
833
IO_CHECK (fio_read_all (fio_stdin , & hdr , sizeof (hdr )), sizeof (hdr ));
834
+ Assert (hdr .arg == FIO_WRITE );
829
835
830
836
/* set errno */
831
837
if (hdr .arg > 0 )
@@ -845,14 +851,16 @@ fio_write(int fd, void const* buf, size_t size)
845
851
static void
846
852
fio_write_impl (int fd , void const * buf , size_t size , int out )
847
853
{
854
+ fio_header hdr = {
855
+ .cop = FIO_WRITE ,
856
+ .handle = -1 ,
857
+ .size = 0 ,
858
+ .arg = 0 ,
859
+ };
848
860
int rc ;
849
- fio_header hdr ;
850
861
851
862
rc = durable_write (fd , buf , size );
852
863
853
- hdr .arg = 0 ;
854
- hdr .size = 0 ;
855
-
856
864
if (rc < 0 )
857
865
hdr .arg = errno ;
858
866
@@ -880,19 +888,19 @@ fio_write_async(int fd, void const* buf, size_t size)
880
888
881
889
if (fio_is_remote_fd (fd ))
882
890
{
883
- fio_header hdr ;
884
-
885
- hdr .cop = FIO_WRITE_ASYNC ;
886
- hdr .handle = fd & ~FIO_PIPE_MARKER ;
887
- hdr .size = size ;
891
+ fio_header hdr = {
892
+ .cop = FIO_WRITE_ASYNC ,
893
+ .handle = fd & ~FIO_PIPE_MARKER ,
894
+ .size = size ,
895
+ .arg = 0 ,
896
+ };
888
897
889
898
IO_CHECK (fio_write_all (fio_stdout , & hdr , sizeof (hdr )), sizeof (hdr ));
890
899
IO_CHECK (fio_write_all (fio_stdout , buf , size ), size );
900
+ return size ;
891
901
}
892
902
else
893
903
return durable_write (fd , buf , size );
894
-
895
- return size ;
896
904
}
897
905
898
906
static void
@@ -1089,12 +1097,12 @@ fio_read(int fd, void* buf, size_t size)
1089
1097
{
1090
1098
if (fio_is_remote_fd (fd ))
1091
1099
{
1092
- fio_header hdr ;
1093
-
1094
- hdr . cop = FIO_READ ;
1095
- hdr . handle = fd & ~ FIO_PIPE_MARKER ;
1096
- hdr . size = 0 ;
1097
- hdr . arg = size ;
1100
+ fio_header hdr = {
1101
+ . cop = FIO_READ ,
1102
+ . handle = fd & ~ FIO_PIPE_MARKER ,
1103
+ . size = 0 ,
1104
+ . arg = size ,
1105
+ } ;
1098
1106
1099
1107
IO_CHECK (fio_write_all (fio_stdout , & hdr , sizeof (hdr )), sizeof (hdr ));
1100
1108
@@ -1116,16 +1124,15 @@ fio_stat(fio_location location, const char* path, struct stat* st, bool follow_s
1116
1124
{
1117
1125
if (fio_is_remote (location ))
1118
1126
{
1119
- fio_header hdr ;
1120
- size_t path_len = strlen (path ) + 1 ;
1121
-
1122
- hdr .cop = FIO_STAT ;
1123
- hdr .handle = -1 ;
1124
- hdr .arg = follow_symlink ;
1125
- hdr .size = path_len ;
1127
+ fio_header hdr = {
1128
+ .cop = FIO_STAT ,
1129
+ .handle = -1 ,
1130
+ .size = strlen (path ) + 1 ,
1131
+ .arg = follow_symlink ,
1132
+ };
1126
1133
1127
1134
IO_CHECK (fio_write_all (fio_stdout , & hdr , sizeof (hdr )), sizeof (hdr ));
1128
- IO_CHECK (fio_write_all (fio_stdout , path , path_len ), path_len );
1135
+ IO_CHECK (fio_write_all (fio_stdout , path , hdr . size ), hdr . size );
1129
1136
1130
1137
IO_CHECK (fio_read_all (fio_stdin , & hdr , sizeof (hdr )), sizeof (hdr ));
1131
1138
Assert (hdr .cop == FIO_STAT );
0 commit comments