[PATCH] Make InputAttributes tags strings const

Dan Nicholson dbn.lists at gmail.com
Sat May 15 08:12:42 PDT 2010


"const char * const *tags" makes the both the pointers and the strings
in the array immutable, which is what we're after even though it seems
to require a cast.
---
 config/hal.c    |    3 ++-
 config/udev.c   |    2 +-
 include/input.h |    2 +-
 3 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/config/hal.c b/config/hal.c
index 9396cef..3b4bfd6 100644
--- a/config/hal.c
+++ b/config/hal.c
@@ -167,7 +167,8 @@ device_added(LibHalContext *hal_ctx, const char *udi)
 
     attrs.vendor = vendor = get_prop_string(hal_ctx, udi, "info.vendor");
     hal_tags = get_prop_string(hal_ctx, udi, "input.tags");
-    attrs.tags = tags = xstrtokenize(hal_tags, ",");
+    tags = xstrtokenize(hal_tags, ",");
+    attrs.tags = (const char * const *)tags;
     free(hal_tags);
 
     if (libhal_device_query_capability(hal_ctx, udi, "input.keys", NULL))
diff --git a/config/udev.c b/config/udev.c
index 941bfbe..201506a 100644
--- a/config/udev.c
+++ b/config/udev.c
@@ -89,7 +89,7 @@ device_added(struct udev_device *udev_device)
     add_option(&options, "device", path);
     attrs.device = path;
     tags = xstrtokenize(udev_device_get_property_value(udev_device, "ID_INPUT.tags"), ",");
-    attrs.tags = tags;
+    attrs.tags = (const char * const *)tags;
 
     config_info = Xprintf("udev:%s", syspath);
     if (!config_info)
diff --git a/include/input.h b/include/input.h
index aadcdf1..e36577d 100644
--- a/include/input.h
+++ b/include/input.h
@@ -215,7 +215,7 @@ typedef struct _InputAttributes {
     const char          *product;
     const char          *vendor;
     const char          *device;
-    char        * const *tags; /* null-terminated */
+    const char  * const *tags; /* null-terminated */
     uint32_t            flags;
 } InputAttributes;
 
-- 
1.6.6.1


More information about the xorg-devel mailing list