* [Qemu-devel] [PATCH] ide-test: check return of fwrite
@ 2017-05-31 19:28 John Snow
2017-05-31 19:37 ` Jeff Cody
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: John Snow @ 2017-05-31 19:28 UTC (permalink / raw)
To: qemu-trivial; +Cc: thuth, qemu-devel, John Snow
To quiet patchew, add an assert for fwrite's return value.
Signed-off-by: John Snow <jsnow@redhat.com>
---
tests/ide-test.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/tests/ide-test.c b/tests/ide-test.c
index 139ebc0..bfd79dd 100644
--- a/tests/ide-test.c
+++ b/tests/ide-test.c
@@ -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);
--
2.9.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH] ide-test: check return of fwrite
2017-05-31 19:28 [Qemu-devel] [PATCH] ide-test: check return of fwrite John Snow
@ 2017-05-31 19:37 ` Jeff Cody
2017-06-01 7:18 ` [Qemu-devel] [Qemu-trivial] " Laurent Vivier
2017-06-01 9:52 ` [Qemu-devel] " Michael Tokarev
2 siblings, 0 replies; 4+ messages in thread
From: Jeff Cody @ 2017-05-31 19:37 UTC (permalink / raw)
To: John Snow; +Cc: qemu-trivial, thuth, qemu-devel
On Wed, May 31, 2017 at 03:28:36PM -0400, John Snow wrote:
> To quiet patchew, add an assert for fwrite's return value.
>
> Signed-off-by: John Snow <jsnow@redhat.com>
> ---
> tests/ide-test.c | 8 ++++++--
> 1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/tests/ide-test.c b/tests/ide-test.c
> index 139ebc0..bfd79dd 100644
> --- a/tests/ide-test.c
> +++ b/tests/ide-test.c
> @@ -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);
> --
> 2.9.4
>
>
Reviewed-by: Jeff Cody <jcody@redhat.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [Qemu-trivial] [PATCH] ide-test: check return of fwrite
2017-05-31 19:28 [Qemu-devel] [PATCH] ide-test: check return of fwrite John Snow
2017-05-31 19:37 ` Jeff Cody
@ 2017-06-01 7:18 ` Laurent Vivier
2017-06-01 9:52 ` [Qemu-devel] " Michael Tokarev
2 siblings, 0 replies; 4+ messages in thread
From: Laurent Vivier @ 2017-06-01 7:18 UTC (permalink / raw)
To: John Snow, qemu-trivial; +Cc: thuth, qemu-devel
On 31/05/2017 21:28, John Snow wrote:
> To quiet patchew, add an assert for fwrite's return value.
>
> Signed-off-by: John Snow <jsnow@redhat.com>
Reviewed-by: Laurent Vivier <lvivier@redhat.com>
> ---
> tests/ide-test.c | 8 ++++++--
> 1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/tests/ide-test.c b/tests/ide-test.c
> index 139ebc0..bfd79dd 100644
> --- a/tests/ide-test.c
> +++ b/tests/ide-test.c
> @@ -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);
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH] ide-test: check return of fwrite
2017-05-31 19:28 [Qemu-devel] [PATCH] ide-test: check return of fwrite John Snow
2017-05-31 19:37 ` Jeff Cody
2017-06-01 7:18 ` [Qemu-devel] [Qemu-trivial] " Laurent Vivier
@ 2017-06-01 9:52 ` Michael Tokarev
2 siblings, 0 replies; 4+ messages in thread
From: Michael Tokarev @ 2017-06-01 9:52 UTC (permalink / raw)
To: John Snow, qemu-trivial; +Cc: thuth, qemu-devel
31.05.2017 22:28, John Snow wrote:
> To quiet patchew, add an assert for fwrite's return value.
Applied to -trivial, thanks!
/mjt
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-06-01 9:52 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-31 19:28 [Qemu-devel] [PATCH] ide-test: check return of fwrite John Snow
2017-05-31 19:37 ` Jeff Cody
2017-06-01 7:18 ` [Qemu-devel] [Qemu-trivial] " Laurent Vivier
2017-06-01 9:52 ` [Qemu-devel] " Michael Tokarev
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.