[Libguestfs] [PATCH] upload: improve file write callback

Matteo Cafasso noxdafox at gmail.com
Wed Nov 9 20:52:25 UTC 2016


As noted by Pino in another patch, the logic passes the first member of
the struct which happens to be the right address to the callback
function.

This will break the callback if order of the members of the struct will
change.

As the callback is using the entire struct, better to pass the pointer
to the struct itself.

Signed-off-by: Matteo Cafasso <noxdafox at gmail.com>
---
 daemon/upload.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/daemon/upload.c b/daemon/upload.c
index f034627..8b4f600 100644
--- a/daemon/upload.c
+++ b/daemon/upload.c
@@ -84,7 +84,7 @@ upload (const char *filename, int flags, int64_t offset)
     }
   }

-  r = receive_file (write_cb, &data.fd);
+  r = receive_file (write_cb, &data);
   if (r == -1) {		/* write error */
     err = errno;
     r = cancel_receive ();
--
2.10.2




More information about the Libguestfs mailing list