On Fri, May 14, 2010 at 05:47:23PM -0700, Keith Packard wrote:
> On Wed, 12 May 2010 21:38:05 +0200, Julien Cristau <[email protected]> 
> wrote:
> > On Wed, May 12, 2010 at 10:53:18 -0700, Dan Nicholson wrote:
> 
> > The attached seems to build without warnings on master.
> 
> Are you guys happy with this version now? It appears to be all nicely
> reviewed and ready to merge. Any reason to think we should be using
> const char *const *tag in the structure?

I'd prefer if the patch below was added to do that. I know nobody likes
casts, but it gives us the desired result.

Dan

>From c838b10e8426bc8d019d3bc2dd9cb0c6fd2de0fb Mon Sep 17 00:00:00 2001
From: Dan Nicholson <[email protected]>
Date: Sat, 15 May 2010 08:12:42 -0700
Subject: [PATCH] Make InputAttributes tags strings const

"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
_______________________________________________
[email protected]: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

Reply via email to