diff mbox

[12/18] savevm.c: fix warning with _FORTIFY_SOURCE

Message ID 1261273167-3240-12-git-send-email-kirill@shutemov.name
State New
Headers show

Commit Message

Kirill A . Shutemov Dec. 20, 2009, 1:39 a.m. UTC
CC    savevm.o
cc1: warnings being treated as errors
savevm.c: In function 'file_put_buffer':
savevm.c:342: error: ignoring return value of 'fwrite', declared with attribute warn_unused_result
make: *** [savevm.o] Error 1

Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
---
 savevm.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)

Comments

Blue Swirl Dec. 22, 2009, 7:21 p.m. UTC | #1
On Sun, Dec 20, 2009 at 1:39 AM, Kirill A. Shutemov
<kirill@shutemov.name> wrote:
>  CC    savevm.o
> cc1: warnings being treated as errors
> savevm.c: In function 'file_put_buffer':
> savevm.c:342: error: ignoring return value of 'fwrite', declared with attribute warn_unused_result
> make: *** [savevm.o] Error 1
>
> Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
> ---
>  savevm.c |    3 +--
>  1 files changed, 1 insertions(+), 2 deletions(-)
>
> diff --git a/savevm.c b/savevm.c
> index aefe052..829f735 100644
> --- a/savevm.c
> +++ b/savevm.c
> @@ -339,8 +339,7 @@ static int file_put_buffer(void *opaque, const uint8_t *buf,
>  {
>     QEMUFileStdio *s = opaque;
>     fseek(s->stdio_file, pos, SEEK_SET);
> -    fwrite(buf, 1, size, s->stdio_file);
> -    return size;
> +    return fwrite(buf, 1, size, s->stdio_file);

Looks OK.

The callers do not handle partial writes, but that's because the
return value is not used correctly. They should be fixed some time.

We are truncating size_t to int, but that is OK given that the input
size is also int. The interfaces should be cleaned up to use
size_t/ssize_t later.
diff mbox

Patch

diff --git a/savevm.c b/savevm.c
index aefe052..829f735 100644
--- a/savevm.c
+++ b/savevm.c
@@ -339,8 +339,7 @@  static int file_put_buffer(void *opaque, const uint8_t *buf,
 {
     QEMUFileStdio *s = opaque;
     fseek(s->stdio_file, pos, SEEK_SET);
-    fwrite(buf, 1, size, s->stdio_file);
-    return size;
+    return fwrite(buf, 1, size, s->stdio_file);
 }
 
 static int file_get_buffer(void *opaque, uint8_t *buf, int64_t pos, int size)