[PATCH 21/44] xi: More warning cleanup for input

Keith Packard keithp at keithp.com
Wed Dec 11 12:23:53 PST 2013


Lots more const char stuff.

Remove duplicate defs of CoreKeyboardProc and CorePointerProc from
test/xi2/protocol-common.c

Signed-off-by: Keith Packard <keithp at keithp.com>
---
 Xi/extinit.c               |  4 ++--
 Xi/listdev.c               |  2 +-
 dix/devices.c              | 11 ++++++-----
 dix/inpututils.c           | 16 ++++++++--------
 include/input.h            | 12 ++++++------
 include/inputstr.h         |  2 +-
 test/input.c               |  4 ++--
 test/xi2/protocol-common.c |  3 ---
 8 files changed, 26 insertions(+), 28 deletions(-)

diff --git a/Xi/extinit.c b/Xi/extinit.c
index a49a421..c13bc47 100644
--- a/Xi/extinit.c
+++ b/Xi/extinit.c
@@ -1169,8 +1169,8 @@ IResetProc(ExtensionEntry * unused)
     EventSwapVector[DevicePropertyNotify] = NotImplemented;
     RestoreExtensionEvents();
 
-    free(xi_all_devices.name);
-    free(xi_all_master_devices.name);
+    free((void *) xi_all_devices.name);
+    free((void *) xi_all_master_devices.name);
 
     XIBarrierReset();
 }
diff --git a/Xi/listdev.c b/Xi/listdev.c
index 014c61d..470fb52 100644
--- a/Xi/listdev.c
+++ b/Xi/listdev.c
@@ -119,7 +119,7 @@ SizeDeviceInfo(DeviceIntPtr d, int *namesize, int *size)
  */
 
 static void
-CopyDeviceName(char **namebuf, char *name)
+CopyDeviceName(char **namebuf, const char *name)
 {
     char *nameptr = (char *) *namebuf;
 
diff --git a/dix/devices.c b/dix/devices.c
index a680ed8..3aecd1b 100644
--- a/dix/devices.c
+++ b/dix/devices.c
@@ -955,7 +955,7 @@ CloseDevice(DeviceIntPtr dev)
     while (dev->xkb_interest)
         XkbRemoveResourceClient((DevicePtr) dev, dev->xkb_interest->resource);
 
-    free(dev->name);
+    free((void *) dev->name);
 
     classes = (ClassesPtr) &dev->key;
     FreeAllDeviceClasses(classes);
@@ -2735,6 +2735,7 @@ AllocDevicePair(ClientPtr client, const char *name,
 {
     DeviceIntPtr pointer;
     DeviceIntPtr keyboard;
+    char *dev_name;
 
     *ptr = *keybd = NULL;
 
@@ -2745,12 +2746,12 @@ AllocDevicePair(ClientPtr client, const char *name,
     if (!pointer)
         return BadAlloc;
 
-    if (asprintf(&pointer->name, "%s pointer", name) == -1) {
-        pointer->name = NULL;
+    if (asprintf(&dev_name, "%s pointer", name) == -1) {
         RemoveDevice(pointer, FALSE);
 
         return BadAlloc;
     }
+    pointer->name = dev_name;
 
     pointer->public.processInputProc = ProcessOtherEvent;
     pointer->public.realInputProc = ProcessOtherEvent;
@@ -2771,13 +2772,13 @@ AllocDevicePair(ClientPtr client, const char *name,
         return BadAlloc;
     }
 
-    if (asprintf(&keyboard->name, "%s keyboard", name) == -1) {
-        keyboard->name = NULL;
+    if (asprintf(&dev_name, "%s keyboard", name) == -1) {
         RemoveDevice(keyboard, FALSE);
         RemoveDevice(pointer, FALSE);
 
         return BadAlloc;
     }
+    keyboard->name = dev_name;
 
     keyboard->public.processInputProc = ProcessOtherEvent;
     keyboard->public.realInputProc = ProcessOtherEvent;
diff --git a/dix/inpututils.c b/dix/inpututils.c
index a10a7c7..3e1d75f 100644
--- a/dix/inpututils.c
+++ b/dix/inpututils.c
@@ -351,7 +351,7 @@ DuplicateInputAttributes(InputAttributes * attrs)
 {
     InputAttributes *new_attr;
     int ntags = 0;
-    char **tags, **new_tags;
+    const char **tags, **new_tags;
 
     if (!attrs)
         return NULL;
@@ -403,20 +403,20 @@ DuplicateInputAttributes(InputAttributes * attrs)
 void
 FreeInputAttributes(InputAttributes * attrs)
 {
-    char **tags;
+    const char **tags;
 
     if (!attrs)
         return;
 
-    free(attrs->product);
-    free(attrs->vendor);
-    free(attrs->device);
-    free(attrs->pnp_id);
-    free(attrs->usb_id);
+    free((void *) attrs->product);
+    free((void *) attrs->vendor);
+    free((void *) attrs->device);
+    free((void *) attrs->pnp_id);
+    free((void *) attrs->usb_id);
 
     if ((tags = attrs->tags))
         while (*tags)
-            free(*tags++);
+            free((void *) *tags++);
 
     free(attrs->tags);
     free(attrs);
diff --git a/include/input.h b/include/input.h
index 2d5e531..042128f 100644
--- a/include/input.h
+++ b/include/input.h
@@ -221,12 +221,12 @@ typedef struct _InputOption InputOption;
 typedef struct _XI2Mask XI2Mask;
 
 typedef struct _InputAttributes {
-    char *product;
-    char *vendor;
-    char *device;
-    char *pnp_id;
-    char *usb_id;
-    char **tags;                /* null-terminated */
+    const char *product;
+    const char *vendor;
+    const char *device;
+    const char *pnp_id;
+    const char *usb_id;
+    const char **tags;                /* null-terminated */
     uint32_t flags;
 } InputAttributes;
 
diff --git a/include/inputstr.h b/include/inputstr.h
index dc36c5d..d369c9f 100644
--- a/include/inputstr.h
+++ b/include/inputstr.h
@@ -542,7 +542,7 @@ typedef struct _DeviceIntRec {
     GrabInfoRec deviceGrab;     /* grab on the device */
     int type;                   /* MASTER_POINTER, MASTER_KEYBOARD, SLAVE */
     Atom xinput_type;
-    char *name;
+    const char *name;
     int id;
     KeyClassPtr key;
     ValuatorClassPtr valuator;
diff --git a/test/input.c b/test/input.c
index df20f82..aaa7a69 100644
--- a/test/input.c
+++ b/test/input.c
@@ -1101,7 +1101,7 @@ xi_unregister_handlers(void)
 static void
 cmp_attr_fields(InputAttributes * attr1, InputAttributes * attr2)
 {
-    char **tags1, **tags2;
+    const char **tags1, **tags2;
 
     assert(attr1 && attr2);
     assert(attr1 != attr2);
@@ -1182,7 +1182,7 @@ dix_input_attributes(void)
 {
     InputAttributes orig = { 0 };
     InputAttributes *new;
-    char *tags[4] = { "tag1", "tag2", "tag2", NULL };
+    const char *tags[4] = { "tag1", "tag2", "tag2", NULL };
 
     new = DuplicateInputAttributes(NULL);
     assert(!new);
diff --git a/test/xi2/protocol-common.c b/test/xi2/protocol-common.c
index e2b0b8b..0947898 100644
--- a/test/xi2/protocol-common.c
+++ b/test/xi2/protocol-common.c
@@ -43,9 +43,6 @@ static ClientRec server_client;
 
 void *userdata;
 
-extern int CorePointerProc(DeviceIntPtr pDev, int what);
-extern int CoreKeyboardProc(DeviceIntPtr pDev, int what);
-
 static void
 fake_init_sprite(DeviceIntPtr dev)
 {
-- 
1.8.4.4



More information about the xorg-devel mailing list