ide-test: check return of fwrite
PATCH 1/1 ide-test: check return of fwrite
To quiet patchew, add an assert for fwrite's return value.
Signed-off-by John Snow <[email protected]>
--- tests/ide-test.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
tests/ide-test.c +6 -2
@@ -796,11 +796,13 @@ static void cdrom_pio_impl(int nblocks)int i, j;uint8_t data;uint16_t limit; +size_t ret;/* Prepopulate the CDROM with an interesting pattern */ generate_pattern (pattern, patt_len,ATAPI_BLOCK_SIZE ); fh =fopen (tmp_path,"w+" ); -fwrite (pattern,ATAPI_BLOCK_SIZE , patt_blocks, fh); + ret =fwrite (pattern,ATAPI_BLOCK_SIZE , patt_blocks, fh); + g_assert_cmpint(ret, ==, patt_blocks);fclose (fh); ide_test_start("-drive if=none,file=%s,media=cdrom,format=raw,id=sr0,index=0 "
@@ -880,6 +882,7 @@ static void test_cdrom_pio_large(void)static void test_cdrom_dma (void ) {static const size_t len =ATAPI_BLOCK_SIZE ; +size_t ret;char *pattern =g_malloc (ATAPI_BLOCK_SIZE *16 );char *rx =g_malloc0 (len);uintptr_t guest_buf;
@@ -896,7 +899,8 @@ static void test_cdrom_dma(void)generate_pattern (pattern,ATAPI_BLOCK_SIZE *16 ,ATAPI_BLOCK_SIZE ); fh =fopen (tmp_path,"w+" ); -fwrite (pattern,ATAPI_BLOCK_SIZE ,16 , fh); + ret =fwrite (pattern,ATAPI_BLOCK_SIZE ,16 , fh); + g_assert_cmpint(ret, ==, 16);fclose (fh);send_dma_request (CMD_PACKET ,0 ,1 , prdt,1 , send_scsi_cdb_read10);
Signature · 1 line
2.9.4
Quoted 48 lines · John Snow
To quiet patchew, add an assert for fwrite's return value.
Signed-off-by John Snow <[email protected]>--- tests/ide-test.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)tests/ide-test.c +6
-2@@ -796,11 +796,13 @@ static void cdrom_pio_impl(int nblocks)int i, j;uint8_t data;uint16_t limit; +size_t ret;/* Prepopulate the CDROM with an interesting pattern */ generate_pattern (pattern, patt_len,ATAPI_BLOCK_SIZE ); fh =fopen (tmp_path,"w+" ); -fwrite (pattern,ATAPI_BLOCK_SIZE , patt_blocks, fh); + ret =fwrite (pattern,ATAPI_BLOCK_SIZE , patt_blocks, fh); + g_assert_cmpint(ret, ==, patt_blocks);fclose (fh); ide_test_start("-drive if=none,file=%s,media=cdrom,format=raw,id=sr0,index=0 "@@ -880,6 +882,7 @@ static void test_cdrom_pio_large(void)static void test_cdrom_dma (void ) {static const size_t len =ATAPI_BLOCK_SIZE ; +size_t ret;char *pattern =g_malloc (ATAPI_BLOCK_SIZE *16 );char *rx =g_malloc0 (len);uintptr_t guest_buf;@@ -896,7 +899,8 @@ static void test_cdrom_dma(void)generate_pattern (pattern,ATAPI_BLOCK_SIZE *16 ,ATAPI_BLOCK_SIZE ); fh =fopen (tmp_path,"w+" ); -fwrite (pattern,ATAPI_BLOCK_SIZE ,16 , fh); + ret =fwrite (pattern,ATAPI_BLOCK_SIZE ,16 , fh); + g_assert_cmpint(ret, ==, 16);fclose (fh);send_dma_request (CMD_PACKET ,0 ,1 , prdt,1 , send_scsi_cdb_read10);Signature · 1 line
2.9.4
Reviewed-by Jeff Cody <[email protected]>
Quoted 3 lines · John Snow
To quiet patchew, add an assert for fwrite's return value.
Signed-off-by John Snow <[email protected]>
Reviewed-by Laurent Vivier <[email protected]>
Quoted 42 lines
--- tests/ide-test.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)tests/ide-test.c +6
-2@@ -796,11 +796,13 @@ static void cdrom_pio_impl(int nblocks)int i, j;uint8_t data;uint16_t limit; +size_t ret;/* Prepopulate the CDROM with an interesting pattern */ generate_pattern (pattern, patt_len,ATAPI_BLOCK_SIZE ); fh =fopen (tmp_path,"w+" ); -fwrite (pattern,ATAPI_BLOCK_SIZE , patt_blocks, fh); + ret =fwrite (pattern,ATAPI_BLOCK_SIZE , patt_blocks, fh); + g_assert_cmpint(ret, ==, patt_blocks);fclose (fh); ide_test_start("-drive if=none,file=%s,media=cdrom,format=raw,id=sr0,index=0 "@@ -880,6 +882,7 @@ static void test_cdrom_pio_large(void)static void test_cdrom_dma (void ) {static const size_t len =ATAPI_BLOCK_SIZE ; +size_t ret;char *pattern =g_malloc (ATAPI_BLOCK_SIZE *16 );char *rx =g_malloc0 (len);uintptr_t guest_buf;@@ -896,7 +899,8 @@ static void test_cdrom_dma(void)generate_pattern (pattern,ATAPI_BLOCK_SIZE *16 ,ATAPI_BLOCK_SIZE ); fh =fopen (tmp_path,"w+" ); -fwrite (pattern,ATAPI_BLOCK_SIZE ,16 , fh); + ret =fwrite (pattern,ATAPI_BLOCK_SIZE ,16 , fh); + g_assert_cmpint(ret, ==, 16);fclose (fh);send_dma_request (CMD_PACKET ,0 ,1 , prdt,1 , send_scsi_cdb_read10);
Michael Tokarev
AppliedQuoted 1 line · John Snow
To quiet patchew, add an assert for fwrite's return value.
Applied to -trivial, thanks!
/mjt