[PATCH] Add devd config backend for FreeBSD (and GNU/kFreeBSD)

Guillem Jover guillem at debian.org
Sat Feb 22 09:15:12 PST 2014


On Sat, 2014-02-22 at 17:12:34 +0100, Guillem Jover wrote:
> > diff --git a/config/devd.c b/config/devd.c
> > new file mode 100644
> > index 0000000..68e658a
> > --- /dev/null
> > +++ b/config/devd.c

> > +static void
> > +device_added(char *line)
> > +{

> > +    vendor = sysctl_get_str("dev.%s.%s.%%desc", hw_types[i].driver, line + strlen(hw_types[i].driver));
> > +    if (vendor == NULL) {
> > +        attrs.vendor = strdup("(unnamed)");
> > +    } else {
> > +        if ((product = strchr(vendor, ' ')) != NULL) {
> > +            product[0] = '\0';
> > +            product++;
> > +        }
> > +        attrs.vendor = strdup(vendor);
> > +        if (product != NULL && (walk = strchr(product, ',')) != NULL)
> > +            walk[0] = '\0';
> > +        attrs.product = strdup(product != NULL ? product : "(unnamed)");
> > +        options = input_option_new(options, "name", product != NULL ? product : "(unnamed)");
> > +    }
> > +    attrs.usb_id = NULL;
> > +    attrs.device = strdup(path);
> > +    options = input_option_new(options, "driver", hw_types[i].xdriver);

> > +    rc = NewInputDeviceRequest(options, &attrs, &dev);

Ah, missed this one, you might want to check how NewInputDeviceRequest()
copes with NULL attributes if strdup() fails, and if you might need to
bail on one of those strdup() failures.

> > +}

Thanks,
Guillem


More information about the xorg-devel mailing list