summaryrefslogtreecommitdiff
path: root/config
diff options
context:
space:
mode:
authorDaniel Stone <daniel@fooishbar.org>2010-12-28 12:29:53 +0000
committerDaniel Stone <daniel@fooishbar.org>2010-12-31 12:36:44 +0000
commit22796cfa4805cc9551e1b3fa1d3e2e1bfae5bad1 (patch)
tree5eabfe15a4d9c4428cb06e4a68477c56c8192aca /config
parent03f2eb1e156796afb70118d7f7f60ac61beed026 (diff)
udev: Add strdups to kill const warnings
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@fooishbar.org> Reviewed-by: Dan Nicholson <dbn.lists@gmail.com>
Diffstat (limited to 'config')
-rw-r--r--config/udev.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/config/udev.c b/config/udev.c
index 496bfbf11..e401894a4 100644
--- a/config/udev.c
+++ b/config/udev.c
@@ -94,6 +94,7 @@ device_added(struct udev_device *udev_device)
if (parent) {
const char *ppath = udev_device_get_devnode(parent);
const char *product = udev_device_get_property_value(parent, "PRODUCT");
+ const char *pnp_id = udev_device_get_sysattr_value(parent, "id");
unsigned int usb_vendor, usb_model;
name = udev_device_get_sysattr_value(parent, "name");
@@ -103,8 +104,9 @@ device_added(struct udev_device *udev_device)
LOG_PROPERTY(ppath, "NAME", name);
}
- attrs.pnp_id = udev_device_get_sysattr_value(parent, "id");
- LOG_SYSATTR(ppath, "id", attrs.pnp_id);
+ if (pnp_id)
+ attrs.pnp_id = strdup(pnp_id);
+ LOG_SYSATTR(ppath, "id", pnp_id);
/* construct USB ID in lowercase hex - "0000:ffff" */
if (product && sscanf(product, "%*x/%4x/%4x/%*x", &usb_vendor, &usb_model) == 2) {
@@ -118,12 +120,13 @@ device_added(struct udev_device *udev_device)
if (!name)
name = "(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;
+ if (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 +165,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 +205,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) {