[PATCH 3/4] udev: Add strdups to kill const warnings
Daniel Stone
daniel at fooishbar.org
Tue Dec 28 04:54:57 PST 2010
InputAttributes wants non-const members, and while it appears safe to
cast it, just leave it be for the moment.
Signed-off-by: Daniel Stone <daniel at fooishbar.org>
---
config/udev.c | 14 +++++++++-----
1 files changed, 9 insertions(+), 5 deletions(-)
diff --git a/config/udev.c b/config/udev.c
index 496bfbf..d09adb6 100644
--- a/config/udev.c
+++ b/config/udev.c
@@ -103,7 +103,7 @@ device_added(struct udev_device *udev_device)
LOG_PROPERTY(ppath, "NAME", name);
}
- attrs.pnp_id = udev_device_get_sysattr_value(parent, "id");
+ attrs.pnp_id = strdup(udev_device_get_sysattr_value(parent, "id"));
LOG_SYSATTR(ppath, "id", attrs.pnp_id);
/* construct USB ID in lowercase hex - "0000:ffff" */
@@ -116,14 +116,14 @@ device_added(struct udev_device *udev_device)
}
}
if (!name)
- name = "(unnamed)";
+ name = strdup("(unnamed)");
else
- attrs.product = name;
+ attrs.product = strdup(name);
add_option(&options, "name", name);
add_option(&options, "path", path);
add_option(&options, "device", path);
- attrs.device = path;
+ attrs.device = strdup(path);
tags_prop = udev_device_get_property_value(udev_device, "ID_INPUT.tags");
LOG_PROPERTY(path, "ID_INPUT.tags", tags_prop);
@@ -162,7 +162,7 @@ device_added(struct udev_device *udev_device)
add_option(&options, "xkb_options", value);
} else if (!strcmp(key, "ID_VENDOR")) {
LOG_PROPERTY(path, key, value);
- attrs.vendor = value;
+ attrs.vendor = strdup(value);
} else if (!strcmp(key, "ID_INPUT_KEY")) {
LOG_PROPERTY(path, key, value);
attrs.flags |= ATTR_KEYBOARD;
@@ -202,6 +202,10 @@ device_added(struct udev_device *udev_device)
}
free(attrs.usb_id);
+ free(attrs.pnp_id);
+ free(attrs.product);
+ free(attrs.device);
+ free(attrs.vendor);
if (attrs.tags) {
char **tag = attrs.tags;
while (*tag) {
--
1.7.2.3
More information about the xorg-devel
mailing list