config/udev: handle const strings

Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
This commit is contained in:
Keith Packard 2013-11-16 23:25:50 -08:00
parent b7633c6ff2
commit 86647e7279

View File

@ -137,11 +137,13 @@ device_added(struct udev_device *udev_device)
/* construct USB ID in lowercase hex - "0000:ffff" */ /* construct USB ID in lowercase hex - "0000:ffff" */
if (product && if (product &&
sscanf(product, "%*x/%4x/%4x/%*x", &usb_vendor, &usb_model) == 2) { sscanf(product, "%*x/%4x/%4x/%*x", &usb_vendor, &usb_model) == 2) {
if (asprintf(&attrs.usb_id, "%04x:%04x", usb_vendor, usb_model) char *usb_id;
if (asprintf(&usb_id, "%04x:%04x", usb_vendor, usb_model)
== -1) == -1)
attrs.usb_id = NULL; usb_id = NULL;
else else
LOG_PROPERTY(ppath, "PRODUCT", product); LOG_PROPERTY(ppath, "PRODUCT", product);
attrs.usb_id = usb_id;
} }
} }
if (!name) if (!name)
@ -240,16 +242,16 @@ device_added(struct udev_device *udev_device)
free(config_info); free(config_info);
input_option_free_list(&input_options); input_option_free_list(&input_options);
free(attrs.usb_id); free((void *) attrs.usb_id);
free(attrs.pnp_id); free((void *) attrs.pnp_id);
free(attrs.product); free((void *) attrs.product);
free(attrs.device); free((void *) attrs.device);
free(attrs.vendor); free((void *) attrs.vendor);
if (attrs.tags) { if (attrs.tags) {
char **tag = attrs.tags; const char **tag = attrs.tags;
while (*tag) { while (*tag) {
free(*tag); free((void *) *tag);
tag++; tag++;
} }
free(attrs.tags); free(attrs.tags);