[Spice-devel,xf86-video-qxl,05/13] spiceqxl_inputs: fix const discard at initialization warnings

Submitted by Alon Levy on April 9, 2012, 5:33 p.m.

Details

Message ID 1333992799-14302-6-git-send-email-alevy@redhat.com
State New
Headers show

Not browsing as part of any series.

Commit Message

Alon Levy April 9, 2012, 5:33 p.m.
---
 src/spiceqxl_inputs.c |   64 ++++++++++++++++++++++++++++---------------------
 1 file changed, 37 insertions(+), 27 deletions(-)

Patch hide | download patch | download mbox

diff --git a/src/spiceqxl_inputs.c b/src/spiceqxl_inputs.c
index 62ef19f..5cfa823 100644
--- a/src/spiceqxl_inputs.c
+++ b/src/spiceqxl_inputs.c
@@ -46,26 +46,6 @@  void XSpicePointerUnInit(InputDriverPtr drv, InputInfoPtr pInfo, int flags);
 static
 void XSpiceKeyboardUnInit(InputDriverPtr drv, InputInfoPtr pInfo, int flags);
 
-static InputDriverRec XSPICE_POINTER = {
-    1,
-    "xspice pointer",
-    NULL,
-    XSpicePointerPreInit,
-    XSpicePointerUnInit,
-    NULL,
-    NULL /* defaults */
-};
-
-static InputDriverRec XSPICE_KEYBOARD = {
-    1,
-    "xspice keyboard",
-    NULL,
-    XSpiceKeyboardPreInit,
-    XSpiceKeyboardUnInit,
-    NULL,
-    NULL
-};
-
 #define BUTTONS 5
 
 typedef struct XSpiceKbd {
@@ -152,12 +132,17 @@  static void xspice_keyboard_control(DeviceIntPtr device, KeybdCtrl *ctrl)
 static int xspice_keyboard_proc(DeviceIntPtr pDevice, int onoff)
 {
     DevicePtr pDev = (DevicePtr)pDevice;
+    char rules[] = "evdev";
+    char model[] = "pc105";
+    char layout[] = "us";
+    char variant[] = "";
+    char options[] = "";
     XkbRMLVOSet rmlvo = {
-        .rules = "evdev",
-        .model = "pc105",
-        .layout = "us",
-        .variant = "",
-        .options = "",
+        .rules = rules,
+        .model = model,
+        .layout = layout,
+        .variant = variant,
+        .options = options,
     };
 
     switch (onoff) {
@@ -354,13 +339,14 @@  static int
 XSpiceKeyboardPreInit(InputDriverPtr drv, InputInfoPtr pInfo, int flags)
 {
     XSpiceKbd *kbd;
+    static char type_name[] = "UNKNOWN";
 
     kbd = calloc(sizeof(*kbd), 1);
     kbd->sin.base.sif = &kbd_interface.base;
     kbd->pInfo = pInfo;
 
     pInfo->private = kbd;
-    pInfo->type_name = "UNKNOWN";
+    pInfo->type_name = type_name;
     pInfo->device_control = xspice_keyboard_proc;
     pInfo->read_input = NULL;
     pInfo->switch_mode = NULL;
@@ -373,6 +359,7 @@  static int
 XSpicePointerPreInit(InputDriverPtr drv, InputInfoPtr pInfo, int flags)
 {
     XSpicePointer *pointer;
+    static char type_name[] = "UNKNOWN";
 
     pointer = calloc(sizeof(*pointer), 1);
     pointer->mouse.base.sif  = &mouse_interface.base;
@@ -381,7 +368,7 @@  XSpicePointerPreInit(InputDriverPtr drv, InputInfoPtr pInfo, int flags)
     pointer->pInfo = pInfo;
 
     pInfo->private = NULL;
-    pInfo->type_name = "UNKNOWN";
+    pInfo->type_name = type_name;
     pInfo->device_control = xspice_pointer_proc;
     pInfo->read_input = NULL;
     pInfo->switch_mode = NULL;
@@ -402,6 +389,29 @@  XSpiceKeyboardUnInit(InputDriverPtr drv, InputInfoPtr pInfo, int flags)
 
 void xspice_add_input_drivers(pointer module)
 {
+    char xspice_pointer[] = "xspice pointer";
+    char xspice_keyboard[] = "xspice keyboard";
+
+    InputDriverRec XSPICE_POINTER = {
+        1,
+        xspice_pointer,
+        NULL,
+        XSpicePointerPreInit,
+        XSpicePointerUnInit,
+        NULL,
+        NULL /* defaults */
+    };
+
+    InputDriverRec XSPICE_KEYBOARD = {
+        1,
+        xspice_keyboard,
+        NULL,
+        XSpiceKeyboardPreInit,
+        XSpiceKeyboardUnInit,
+        NULL,
+        NULL
+    };
+
     xf86AddInputDriver(&XSPICE_POINTER, module, 0);
     xf86AddInputDriver(&XSPICE_KEYBOARD, module, 0);
 }

Comments

Same question as the other patch, wouldn't we be better off just doing
(char *)"xspice pointer" casts? Or disabling this warning?

Christophe

On Mon, Apr 09, 2012 at 08:33:11PM +0300, Alon Levy wrote:
> ---
>  src/spiceqxl_inputs.c |   64 ++++++++++++++++++++++++++++---------------------
>  1 file changed, 37 insertions(+), 27 deletions(-)
> 
> diff --git a/src/spiceqxl_inputs.c b/src/spiceqxl_inputs.c
> index 62ef19f..5cfa823 100644
> --- a/src/spiceqxl_inputs.c
> +++ b/src/spiceqxl_inputs.c
> @@ -46,26 +46,6 @@ void XSpicePointerUnInit(InputDriverPtr drv, InputInfoPtr pInfo, int flags);
>  static
>  void XSpiceKeyboardUnInit(InputDriverPtr drv, InputInfoPtr pInfo, int flags);
>  
> -static InputDriverRec XSPICE_POINTER = {
> -    1,
> -    "xspice pointer",
> -    NULL,
> -    XSpicePointerPreInit,
> -    XSpicePointerUnInit,
> -    NULL,
> -    NULL /* defaults */
> -};
> -
> -static InputDriverRec XSPICE_KEYBOARD = {
> -    1,
> -    "xspice keyboard",
> -    NULL,
> -    XSpiceKeyboardPreInit,
> -    XSpiceKeyboardUnInit,
> -    NULL,
> -    NULL
> -};
> -
>  #define BUTTONS 5
>  
>  typedef struct XSpiceKbd {
> @@ -152,12 +132,17 @@ static void xspice_keyboard_control(DeviceIntPtr device, KeybdCtrl *ctrl)
>  static int xspice_keyboard_proc(DeviceIntPtr pDevice, int onoff)
>  {
>      DevicePtr pDev = (DevicePtr)pDevice;
> +    char rules[] = "evdev";
> +    char model[] = "pc105";
> +    char layout[] = "us";
> +    char variant[] = "";
> +    char options[] = "";
>      XkbRMLVOSet rmlvo = {
> -        .rules = "evdev",
> -        .model = "pc105",
> -        .layout = "us",
> -        .variant = "",
> -        .options = "",
> +        .rules = rules,
> +        .model = model,
> +        .layout = layout,
> +        .variant = variant,
> +        .options = options,
>      };
>  
>      switch (onoff) {
> @@ -354,13 +339,14 @@ static int
>  XSpiceKeyboardPreInit(InputDriverPtr drv, InputInfoPtr pInfo, int flags)
>  {
>      XSpiceKbd *kbd;
> +    static char type_name[] = "UNKNOWN";
>  
>      kbd = calloc(sizeof(*kbd), 1);
>      kbd->sin.base.sif = &kbd_interface.base;
>      kbd->pInfo = pInfo;
>  
>      pInfo->private = kbd;
> -    pInfo->type_name = "UNKNOWN";
> +    pInfo->type_name = type_name;
>      pInfo->device_control = xspice_keyboard_proc;
>      pInfo->read_input = NULL;
>      pInfo->switch_mode = NULL;
> @@ -373,6 +359,7 @@ static int
>  XSpicePointerPreInit(InputDriverPtr drv, InputInfoPtr pInfo, int flags)
>  {
>      XSpicePointer *pointer;
> +    static char type_name[] = "UNKNOWN";
>  
>      pointer = calloc(sizeof(*pointer), 1);
>      pointer->mouse.base.sif  = &mouse_interface.base;
> @@ -381,7 +368,7 @@ XSpicePointerPreInit(InputDriverPtr drv, InputInfoPtr pInfo, int flags)
>      pointer->pInfo = pInfo;
>  
>      pInfo->private = NULL;
> -    pInfo->type_name = "UNKNOWN";
> +    pInfo->type_name = type_name;
>      pInfo->device_control = xspice_pointer_proc;
>      pInfo->read_input = NULL;
>      pInfo->switch_mode = NULL;
> @@ -402,6 +389,29 @@ XSpiceKeyboardUnInit(InputDriverPtr drv, InputInfoPtr pInfo, int flags)
>  
>  void xspice_add_input_drivers(pointer module)
>  {
> +    char xspice_pointer[] = "xspice pointer";
> +    char xspice_keyboard[] = "xspice keyboard";
> +
> +    InputDriverRec XSPICE_POINTER = {
> +        1,
> +        xspice_pointer,
> +        NULL,
> +        XSpicePointerPreInit,
> +        XSpicePointerUnInit,
> +        NULL,
> +        NULL /* defaults */
> +    };
> +
> +    InputDriverRec XSPICE_KEYBOARD = {
> +        1,
> +        xspice_keyboard,
> +        NULL,
> +        XSpiceKeyboardPreInit,
> +        XSpiceKeyboardUnInit,
> +        NULL,
> +        NULL
> +    };
> +
>      xf86AddInputDriver(&XSPICE_POINTER, module, 0);
>      xf86AddInputDriver(&XSPICE_KEYBOARD, module, 0);
>  }
> -- 
> 1.7.9.3
> 
> _______________________________________________
> Spice-devel mailing list
> Spice-devel@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/spice-devel
On Tue, Apr 10, 2012 at 12:28:31PM +0200, Christophe Fergeau wrote:
> Same question as the other patch, wouldn't we be better off just doing
> (char *)"xspice pointer" casts? Or disabling this warning?

Same answer.

> 
> Christophe
> 
> On Mon, Apr 09, 2012 at 08:33:11PM +0300, Alon Levy wrote:
> > ---
> >  src/spiceqxl_inputs.c |   64 ++++++++++++++++++++++++++++---------------------
> >  1 file changed, 37 insertions(+), 27 deletions(-)
> > 
> > diff --git a/src/spiceqxl_inputs.c b/src/spiceqxl_inputs.c
> > index 62ef19f..5cfa823 100644
> > --- a/src/spiceqxl_inputs.c
> > +++ b/src/spiceqxl_inputs.c
> > @@ -46,26 +46,6 @@ void XSpicePointerUnInit(InputDriverPtr drv, InputInfoPtr pInfo, int flags);
> >  static
> >  void XSpiceKeyboardUnInit(InputDriverPtr drv, InputInfoPtr pInfo, int flags);
> >  
> > -static InputDriverRec XSPICE_POINTER = {
> > -    1,
> > -    "xspice pointer",
> > -    NULL,
> > -    XSpicePointerPreInit,
> > -    XSpicePointerUnInit,
> > -    NULL,
> > -    NULL /* defaults */
> > -};
> > -
> > -static InputDriverRec XSPICE_KEYBOARD = {
> > -    1,
> > -    "xspice keyboard",
> > -    NULL,
> > -    XSpiceKeyboardPreInit,
> > -    XSpiceKeyboardUnInit,
> > -    NULL,
> > -    NULL
> > -};
> > -
> >  #define BUTTONS 5
> >  
> >  typedef struct XSpiceKbd {
> > @@ -152,12 +132,17 @@ static void xspice_keyboard_control(DeviceIntPtr device, KeybdCtrl *ctrl)
> >  static int xspice_keyboard_proc(DeviceIntPtr pDevice, int onoff)
> >  {
> >      DevicePtr pDev = (DevicePtr)pDevice;
> > +    char rules[] = "evdev";
> > +    char model[] = "pc105";
> > +    char layout[] = "us";
> > +    char variant[] = "";
> > +    char options[] = "";
> >      XkbRMLVOSet rmlvo = {
> > -        .rules = "evdev",
> > -        .model = "pc105",
> > -        .layout = "us",
> > -        .variant = "",
> > -        .options = "",
> > +        .rules = rules,
> > +        .model = model,
> > +        .layout = layout,
> > +        .variant = variant,
> > +        .options = options,
> >      };
> >  
> >      switch (onoff) {
> > @@ -354,13 +339,14 @@ static int
> >  XSpiceKeyboardPreInit(InputDriverPtr drv, InputInfoPtr pInfo, int flags)
> >  {
> >      XSpiceKbd *kbd;
> > +    static char type_name[] = "UNKNOWN";
> >  
> >      kbd = calloc(sizeof(*kbd), 1);
> >      kbd->sin.base.sif = &kbd_interface.base;
> >      kbd->pInfo = pInfo;
> >  
> >      pInfo->private = kbd;
> > -    pInfo->type_name = "UNKNOWN";
> > +    pInfo->type_name = type_name;
> >      pInfo->device_control = xspice_keyboard_proc;
> >      pInfo->read_input = NULL;
> >      pInfo->switch_mode = NULL;
> > @@ -373,6 +359,7 @@ static int
> >  XSpicePointerPreInit(InputDriverPtr drv, InputInfoPtr pInfo, int flags)
> >  {
> >      XSpicePointer *pointer;
> > +    static char type_name[] = "UNKNOWN";
> >  
> >      pointer = calloc(sizeof(*pointer), 1);
> >      pointer->mouse.base.sif  = &mouse_interface.base;
> > @@ -381,7 +368,7 @@ XSpicePointerPreInit(InputDriverPtr drv, InputInfoPtr pInfo, int flags)
> >      pointer->pInfo = pInfo;
> >  
> >      pInfo->private = NULL;
> > -    pInfo->type_name = "UNKNOWN";
> > +    pInfo->type_name = type_name;
> >      pInfo->device_control = xspice_pointer_proc;
> >      pInfo->read_input = NULL;
> >      pInfo->switch_mode = NULL;
> > @@ -402,6 +389,29 @@ XSpiceKeyboardUnInit(InputDriverPtr drv, InputInfoPtr pInfo, int flags)
> >  
> >  void xspice_add_input_drivers(pointer module)
> >  {
> > +    char xspice_pointer[] = "xspice pointer";
> > +    char xspice_keyboard[] = "xspice keyboard";
> > +
> > +    InputDriverRec XSPICE_POINTER = {
> > +        1,
> > +        xspice_pointer,
> > +        NULL,
> > +        XSpicePointerPreInit,
> > +        XSpicePointerUnInit,
> > +        NULL,
> > +        NULL /* defaults */
> > +    };
> > +
> > +    InputDriverRec XSPICE_KEYBOARD = {
> > +        1,
> > +        xspice_keyboard,
> > +        NULL,
> > +        XSpiceKeyboardPreInit,
> > +        XSpiceKeyboardUnInit,
> > +        NULL,
> > +        NULL
> > +    };
> > +
> >      xf86AddInputDriver(&XSPICE_POINTER, module, 0);
> >      xf86AddInputDriver(&XSPICE_KEYBOARD, module, 0);
> >  }
> > -- 
> > 1.7.9.3
> > 
> > _______________________________________________
> > Spice-devel mailing list
> > Spice-devel@lists.freedesktop.org
> > http://lists.freedesktop.org/mailman/listinfo/spice-devel