Patchwork [02/10] qemu-ga: qmp_guest_file_close(): fix fclose() error check

login
register
mail settings
Submitter Luiz Capitulino
Date Nov. 27, 2012, 1:01 p.m.
Message ID <1354021324-31561-3-git-send-email-lcapitulino@redhat.com>
Download mbox | patch
Permalink /patch/202230/
State New
Headers show

Comments

Luiz Capitulino - Nov. 27, 2012, 1:01 p.m.
fclose() returns EOF on error.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
---
 qga/commands-posix.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Michael Roth - Nov. 28, 2012, 5:02 p.m.
On Tue, Nov 27, 2012 at 11:01:56AM -0200, Luiz Capitulino wrote:
> fclose() returns EOF on error.
> 
> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>

Reviewed-by: Michael Roth <mdroth@linux.vnet.ibm.com>

> ---
>  qga/commands-posix.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/qga/commands-posix.c b/qga/commands-posix.c
> index a2216f2..c284083 100644
> --- a/qga/commands-posix.c
> +++ b/qga/commands-posix.c
> @@ -170,7 +170,7 @@ void qmp_guest_file_close(int64_t handle, Error **err)
>      }
> 
>      ret = fclose(gfh->fh);
> -    if (ret == -1) {
> +    if (ret == EOF) {
>          error_set(err, QERR_QGA_COMMAND_FAILED, "fclose() failed");
>          return;
>      }
> -- 
> 1.8.0
>

Patch

diff --git a/qga/commands-posix.c b/qga/commands-posix.c
index a2216f2..c284083 100644
--- a/qga/commands-posix.c
+++ b/qga/commands-posix.c
@@ -170,7 +170,7 @@  void qmp_guest_file_close(int64_t handle, Error **err)
     }
 
     ret = fclose(gfh->fh);
-    if (ret == -1) {
+    if (ret == EOF) {
         error_set(err, QERR_QGA_COMMAND_FAILED, "fclose() failed");
         return;
     }