[Spice-devel,1/2] win-usb-driver-install: initialize "req" with memset

Submitted by Uri Lublin on July 10, 2012, 4:27 p.m.

Details

Message ID 1341937679-21174-1-git-send-email-uril@redhat.com
State New
Headers show

Not browsing as part of any series.

Commit Message

Uri Lublin July 10, 2012, 4:27 p.m.
This fixes the following compilation error message:

../../gtk/win-usb-driver-install.c: In function 'spice_win_usb_driver_send_request':
../../gtk/win-usb-driver-install.c:187:5: error: missing braces around initializer [-Werror=missing-braces]
../../gtk/win-usb-driver-install.c:187:5: error: (near initialization for 'req.hdr') [-Werror=missing-braces]
---
 gtk/win-usb-driver-install.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

Patch hide | download patch | download mbox

diff --git a/gtk/win-usb-driver-install.c b/gtk/win-usb-driver-install.c
index 8b326b5..02d20d6 100644
--- a/gtk/win-usb-driver-install.c
+++ b/gtk/win-usb-driver-install.c
@@ -184,7 +184,7 @@  static
 gboolean spice_win_usb_driver_send_request(SpiceWinUsbDriver *self, guint16 op,
                                            guint16 vid, guint16 pid, GError **err)
 {
-    USBClerkDriverOp req = {0,};
+    USBClerkDriverOp req;
     GOutputStream *ostream;
     SpiceWinUsbDriverPrivate *priv;
     gsize bytes;
@@ -196,6 +196,7 @@  gboolean spice_win_usb_driver_send_request(SpiceWinUsbDriver *self, guint16 op,
     g_return_val_if_fail(SPICE_IS_WIN_USB_DRIVER(self), FALSE);
     priv = self->priv;

+    memset(&req, 0, sizeof(req));
     req.hdr.magic   = USB_CLERK_MAGIC;
     req.hdr.version = USB_CLERK_VERSION;
     req.hdr.type    = op;

Comments

----- Mensaje original -----
> This fixes the following compilation error message:
> 
> ../../gtk/win-usb-driver-install.c: In function
> 'spice_win_usb_driver_send_request':
> ../../gtk/win-usb-driver-install.c:187:5: error: missing braces
> around initializer [-Werror=missing-braces]
> ../../gtk/win-usb-driver-install.c:187:5: error: (near initialization
> for 'req.hdr') [-Werror=missing-braces]

ah yeah, struct in struct initilialization, we usually use a define for these cases in GLib. That also allows changing the initialization later on if the structure changes, or if you want initial value etc (see all the G_*_INIT define)

ack anyway