Skip to content

Commit

Permalink
Drop unused /dev/ prefix to unbreak FreeBSD 11.0
Browse files Browse the repository at this point in the history
uhidd.c:291:16: error: passing 'const char *' to parameter of type 'char *' discards qualifiers
      [-Werror,-Wincompatible-pointer-types-discards-qualifiers]
                    basename(hi->dev));
                             ^~~~~~~
/usr/include/libgen.h:38:22: note: passing argument to parameter here
char    *basename(char *);
                        ^
  • Loading branch information
jbeich committed May 29, 2016
1 parent db33170 commit ea1925e
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 42 deletions.
38 changes: 19 additions & 19 deletions uhidd/uhidd.c
Expand Up @@ -231,7 +231,7 @@ main(int argc, char **argv)

STAILQ_INIT(&hilist);

if (find_device(*argv) < 0) {
if (find_device(basename(*argv)) < 0) {
eval = 1;
goto uhidd_end;
}
Expand Down Expand Up @@ -288,7 +288,7 @@ create_runtime_dir(void)
hi = STAILQ_FIRST(&hilist);
if (hi != NULL && hi->dev != NULL) {
snprintf(dpath, sizeof(dpath), "/var/run/uhidd.%s",
basename(hi->dev));
hi->dev);
mkdir(dpath, 0755);
}
}
Expand All @@ -304,7 +304,7 @@ remove_runtime_dir(void)
hi = STAILQ_FIRST(&hilist);
if (hi != NULL && hi->dev != NULL) {
snprintf(dpath, sizeof(dpath), "/var/run/uhidd.%s",
basename(hi->dev));
hi->dev);
if ((dir = opendir(dpath)) != NULL) {
while ((d = readdir(dir)) != NULL) {
snprintf(fpath, sizeof(fpath), "%s/%s", dpath,
Expand Down Expand Up @@ -343,7 +343,7 @@ find_device(const char *dev)
unsigned int bus, addr;
int ret;

if (sscanf(dev, "/dev/ugen%u.%u", &bus, &addr) < 2) {
if (sscanf(dev, "ugen%u.%u", &bus, &addr) < 2) {
syslog(LOG_ERR, "%s not found", dev);
return (-1);
}
Expand Down Expand Up @@ -461,7 +461,7 @@ open_iface(const char *dev, struct libusb20_device *pdev,
e = libusb20_dev_request_sync(pdev, &req, rdesc, &actlen, 0, 0);
if (e) {
syslog(LOG_ERR, "%s[%d]=> libusb20_dev_request_sync"
" failed", basename(dev), ndx);
" failed", dev, ndx);
return;
}

Expand Down Expand Up @@ -496,14 +496,14 @@ open_iface(const char *dev, struct libusb20_device *pdev,
e = libusb20_dev_request_sync(pdev, &req, buf, &buflen, 0, 0);
if (e) {
syslog(LOG_ERR, "%s[%d]=> libusb20_dev_request_sync"
" failed", basename(dev), ndx);
" failed", dev, ndx);
syslog(LOG_ERR, "%s[%d]=> GET_PROTOCOL failed",
basename(dev), ndx);
dev, ndx);
goto alloc_parent;
}
if (buflen != 1) {
syslog(LOG_ERR, "%s[%d]=> GET_PROTOCOL failed: "
"buflen != 1", basename(dev), ndx);
"buflen != 1", dev, ndx);
goto alloc_parent;
}
if (buf[0] == 1) {
Expand All @@ -513,7 +513,7 @@ open_iface(const char *dev, struct libusb20_device *pdev,
}
if (buf[0] != 0) {
syslog(LOG_ERR, "%s[%d]=> GET_PROTOCOL failed: "
"invalid data: %u", basename(dev), ndx,
"invalid data: %u", dev, ndx,
(unsigned) buf[0]);
goto alloc_parent;
}
Expand All @@ -530,9 +530,9 @@ open_iface(const char *dev, struct libusb20_device *pdev,
e = libusb20_dev_request_sync(pdev, &req, NULL, NULL, 0, 0);
if (e) {
syslog(LOG_ERR, "%s[%d]=> libusb20_dev_request_sync"
" failed", basename(dev), ndx);
" failed", dev, ndx);
syslog(LOG_ERR, "%s[%d]=> SET_PROTOCOL failed",
basename(dev), ndx);
dev, ndx);
goto alloc_parent;
}
PRINT0(0, dev, ndx, "Interface SET_PROTOCOL ok.\n");
Expand Down Expand Up @@ -611,7 +611,7 @@ alloc_hid_interface_be(struct hid_interface *hi)

assert(hi != NULL);

if (sscanf(hi->dev, "/dev/ugen%u.%u", &bus, &addr) < 2) {
if (sscanf(hi->dev, "ugen%u.%u", &bus, &addr) < 2) {
syslog(LOG_ERR, "%s not found", hi->dev);
return (-1);
}
Expand Down Expand Up @@ -708,7 +708,7 @@ start_hid_interface(void *arg)
PRINT1(1, "HID interface task started\n");

if ((buf = malloc(_TR_BUFSIZE)) == NULL) {
syslog(LOG_ERR, "%s[%d] malloc failed\n", basename(hi->dev),
syslog(LOG_ERR, "%s[%d] malloc failed\n", hi->dev,
hi->ndx);
goto parent_end;
}
Expand All @@ -718,7 +718,7 @@ start_hid_interface(void *arg)
xfer = libusb20_tr_get_pointer(hi->pdev, x);
if (xfer == NULL) {
syslog(LOG_ERR, "%s[%d] libusb20_tr_get_pointer failed\n",
basename(hi->dev), hi->ndx);
hi->dev, hi->ndx);
goto parent_end;
}

Expand All @@ -727,7 +727,7 @@ start_hid_interface(void *arg)
PRINT1(0, "xfer already opened\n");
} else if (e) {
syslog(LOG_ERR, "%s[%d] libusb20_tr_open failed\n",
basename(hi->dev), hi->ndx);
hi->dev, hi->ndx);
goto parent_end;
}

Expand Down Expand Up @@ -798,14 +798,14 @@ hid_interrupt_out(void *context, int report_id, char *buf, int len)
xfer = libusb20_tr_get_pointer(hi->pdev, x);
if (xfer == NULL) {
syslog(LOG_ERR, "%s[%d] libusb20_tr_get_pointer failed\n",
basename(hi->dev), hi->ndx);
hi->dev, hi->ndx);
return (-1);
}

e = libusb20_tr_open(xfer, _TR_BUFSIZE, 1, XXX); /* FIXME */
if (e && e != LIBUSB20_ERROR_BUSY) {
syslog(LOG_ERR, "%s[%d] libusb20_tr_open failed\n",
basename(hi->dev), hi->ndx);
hi->dev, hi->ndx);
return (-1);
}

Expand Down Expand Up @@ -888,12 +888,12 @@ hid_set_report(void *context, int report_id, char *buf, int len)
e = libusb20_dev_request_sync(hi->pdev, &req, buf, &actlen, 0, 0);
if (e && verbose)
syslog(LOG_ERR, "%s[%d] libusb20_dev_request_sync failed",
basename(hi->dev), hi->ndx);
hi->dev, hi->ndx);
try++;
} while (e && try < _SET_REPORT_RETRY);
if (e) {
syslog(LOG_ERR, "%s[%d] libusb20_dev_request_sync failed",
basename(hi->dev), hi->ndx);
hi->dev, hi->ndx);
return (-1);
}
if (verbose) {
Expand Down
5 changes: 2 additions & 3 deletions uhidd/uhidd.h
Expand Up @@ -392,8 +392,7 @@ struct evdev_cb {
do { \
if (verbose >= (v)) { \
char pb[64], pb2[1024]; \
snprintf(pb, sizeof(pb), "%s[%d]", basename(d), \
(n)); \
snprintf(pb, sizeof(pb), "%s[%d]", d, (n)); \
snprintf(pb2, sizeof(pb2), __VA_ARGS__); \
printf("%s-> %s", pb, pb2); \
} \
Expand All @@ -404,7 +403,7 @@ struct evdev_cb {
if (verbose >= (v)) { \
char pb[64], pb2[1024]; \
snprintf(pb, sizeof(pb), "%s[%d]", \
basename(hi->dev), hi->ndx); \
hi->dev, hi->ndx); \
snprintf(pb2, sizeof(pb2), __VA_ARGS__); \
printf("%s-> %s", pb, pb2); \
} \
Expand Down
4 changes: 2 additions & 2 deletions uhidd/uhidd_cc.c
Expand Up @@ -69,11 +69,11 @@ cc_write_keymap_file(struct hid_interface *hi)
int i;

snprintf(fpath, sizeof(fpath), "/var/run/uhidd.%s/cc_keymap",
basename(hi->dev));
hi->dev);
fp = fopen(fpath, "w+");
if (fp == NULL) {
syslog(LOG_ERR, "%s[%d] fopen %s failed: %m",
basename(hi->dev), hi->ndx, fpath);
hi->dev, hi->ndx, fpath);
return;
}
fprintf(fp, "0x%04x:0x%04x={\n", hi->vendor_id, hi->product_id);
Expand Down
4 changes: 2 additions & 2 deletions uhidd/uhidd_evdev.c
Expand Up @@ -157,7 +157,7 @@ struct evmsg {
if (verbose >= (v)) { \
char pb[64], pb2[1024]; \
snprintf(pb, sizeof(pb), "%s[%d][%s]", \
basename(hi->dev), hi->ndx, ed->devname); \
hi->dev, hi->ndx, ed->devname); \
snprintf(pb2, sizeof(pb2), __VA_ARGS__); \
printf("%s-> %s", pb, pb2); \
} \
Expand All @@ -168,7 +168,7 @@ struct evmsg {
if (verbose >= (v)) { \
char pb[64], pb2[1024]; \
snprintf(pb, sizeof(pb), "%s[%d][%s][c:%d]", \
basename(hi->dev), hi->ndx, ed->devname, \
hi->dev, hi->ndx, ed->devname, \
ec->ndx); \
snprintf(pb2, sizeof(pb2), __VA_ARGS__); \
printf("%s-> %s", pb, pb2); \
Expand Down
6 changes: 3 additions & 3 deletions uhidd/uhidd_kbd.c
Expand Up @@ -770,7 +770,7 @@ kbd_attach(struct hid_appcol *ha)
/* Open /dev/vkbdctl. */
if ((kd->vkbd_fd = open("/dev/vkbdctl", O_RDWR)) < 0) {
syslog(LOG_ERR, "%s[%d] could not open /dev/vkbdctl:"
" %m", basename(hi->dev), hi->ndx);
" %m", hi->dev, hi->ndx);
if (errno == ENOENT)
PRINT1(1, "vkbd.ko kernel module not "
"loaded?\n");
Expand All @@ -780,7 +780,7 @@ kbd_attach(struct hid_appcol *ha)
if (verbose) {
if (fstat(kd->vkbd_fd, &sb) < 0) {
syslog(LOG_ERR, "%s[%d] fstat: /dev/vkbdctl:"
" %m", basename(hi->dev), hi->ndx);
" %m", hi->dev, hi->ndx);
return (-1);
}
PRINT1(1, "kbd device name: %s\n",
Expand All @@ -799,7 +799,7 @@ kbd_attach(struct hid_appcol *ha)
kd->evdev = evdev_register_device(kd, &kbd_evdev_cb);
if (kd->evdev == NULL) {
syslog(LOG_ERR, "%s[%d] could not register evdev "
"device", basename(hi->dev), hi->ndx);
"device", hi->dev, hi->ndx);
return (-1);
}
PRINT1(1, "kbd evdev device name: %s\n",
Expand Down
4 changes: 2 additions & 2 deletions uhidd/uhidd_mouse.c
Expand Up @@ -93,7 +93,7 @@ mouse_attach(struct hid_appcol *ha)
md->cons_fd = open("/dev/consolectl", O_RDWR);
if (md->cons_fd < 0) {
syslog(LOG_ERR, "%s[%d] could not open /dev/consolectl: %m",
basename(hi->dev), hi->ndx);
hi->dev, hi->ndx);
return (-1);
}

Expand Down Expand Up @@ -213,5 +213,5 @@ mouse_recv(struct hid_appcol *ha, struct hid_report *hr)

if (ioctl(md->cons_fd, CONS_MOUSECTL, &mi) < 0)
syslog(LOG_ERR, "%s[%d] could not submit mouse data:"
" ioctl failed: %m", basename(hi->dev), hi->ndx);
" ioctl failed: %m", hi->dev, hi->ndx);
}
18 changes: 9 additions & 9 deletions uhidd/uhidd_vhid.c
Expand Up @@ -97,21 +97,21 @@ vhid_attach(struct hid_appcol *ha)
*/
if ((vd->vd_fd = open("/dev/uvhidctl", O_RDWR)) < 0) {
syslog(LOG_ERR, "%s[%d] could not open /dev/uvhidctl: %m",
basename(hi->dev), hi->ndx);
hi->dev, hi->ndx);
if (errno == ENOENT)
PRINT1(1, "uvhid.ko kernel moduel not loaded?\n")
return (-1);
}

if (fstat(vd->vd_fd, &sb) < 0) {
syslog(LOG_ERR, "%s[%d] fstat: /dev/uvhidctl: %m",
basename(hi->dev), hi->ndx);
hi->dev, hi->ndx);
close(vd->vd_fd);
return (-1);
}

if ((vd->vd_name = strdup(devname(sb.st_rdev, S_IFCHR))) == NULL) {
syslog(LOG_ERR, "%s[%d] strdup failed: %m", basename(hi->dev),
syslog(LOG_ERR, "%s[%d] strdup failed: %m", hi->dev,
hi->ndx);
close(vd->vd_fd);
return (-1);
Expand All @@ -128,7 +128,7 @@ vhid_attach(struct hid_appcol *ha)

if (ioctl(vd->vd_fd, USB_SET_REPORT_DESC, &ugd) < 0) {
syslog(LOG_ERR, "%s[%d] ioctl(USB_SET_REPORT_DESC): %m",
basename(hi->dev), hi->ndx);
hi->dev, hi->ndx);
return (-1);
}

Expand All @@ -147,15 +147,15 @@ vhid_attach(struct hid_appcol *ha)

if (ioctl(vd->vd_fd, USB_SET_REPORT_ID, &vd->vd_rid) < 0) {
syslog(LOG_ERR, "%s[%d] ioctl(USB_SET_REPORT_ID): %m",
basename(hi->dev), hi->ndx);
hi->dev, hi->ndx);
return (-1);
}

/* Create hidctl read task. */
e = pthread_create(&vd->vd_task, NULL, vhid_task, (void *) ha);
if (e) {
syslog(LOG_ERR, "%s[%d] pthread_create failed: %m",
basename(hi->dev), hi->ndx);
hi->dev, hi->ndx);
close(vd->vd_fd);
return (-1);
}
Expand Down Expand Up @@ -188,7 +188,7 @@ vhid_recv_raw(struct hid_appcol *ha, uint8_t *buf, int len)
}

if (write(vd->vd_fd, buf, len) < 0)
syslog(LOG_ERR, "%s[%d] write failed: %m", basename(hi->dev),
syslog(LOG_ERR, "%s[%d] write failed: %m", hi->dev,
hi->ndx);
}

Expand All @@ -209,7 +209,7 @@ vhid_task(void *arg)
assert(vd != NULL);

if ((buf = malloc(_TR_BUFSIZE)) == NULL) {
syslog(LOG_ERR, "%s[%d] malloc failed: %m", basename(hi->dev),
syslog(LOG_ERR, "%s[%d] malloc failed: %m", hi->dev,
hi->ndx);
return (NULL);
}
Expand All @@ -223,7 +223,7 @@ vhid_task(void *arg)
}
if (verbose) {
PRINT1(1, "%s[%d] vhid_task recevied:",
basename(hi->dev), hi->ndx);
hi->dev, hi->ndx);
for (i = 0; i < len; i++)
printf("%d ", buf[i]);
putchar('\n');
Expand Down
4 changes: 2 additions & 2 deletions uhidd/uhidd_vhid_cuse.c
Expand Up @@ -195,7 +195,7 @@ vhid_attach(struct hid_appcol *ha)
vd->vd_rsz = ha->ha_rsz;
} else {
syslog(LOG_ERR, "%s[%d] report descriptor too big!",
basename(hi->dev), hi->ndx);
hi->dev, hi->ndx);
return (-1);
}

Expand Down Expand Up @@ -471,7 +471,7 @@ vhid_write(struct cuse_dev *cdev, int fflags, const void *peer_ptr, int len)
goto write_done;

if (verbose) {
PRINT1(1, "%s[%d] vhid_task recevied:", basename(hi->dev),
PRINT1(1, "%s[%d] vhid_task recevied:", hi->dev,
hi->ndx);
for (i = 0; i < len; i++)
printf("%d ", buf[i]);
Expand Down

0 comments on commit ea1925e

Please sign in to comment.