mirror of
https://gitlab.freedesktop.org/libevdev/libevdev.git
synced 2025-12-21 21:20:06 +01:00
Replace a few malloc + strcpy with strdup
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
parent
9b7cc815ea
commit
51244538b5
1 changed files with 3 additions and 6 deletions
|
|
@ -145,12 +145,11 @@ libevdev_set_fd(struct libevdev* dev, int fd)
|
||||||
if (rc < 0)
|
if (rc < 0)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
dev->name = calloc(strlen(buf) + 1, sizeof(char));
|
dev->name = strdup(buf);
|
||||||
if (!dev->name) {
|
if (!dev->name) {
|
||||||
errno = ENOSPC;
|
errno = ENOSPC;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
strcpy(dev->name, buf);
|
|
||||||
|
|
||||||
memset(buf, 0, sizeof(buf));
|
memset(buf, 0, sizeof(buf));
|
||||||
rc = ioctl(fd, EVIOCGPHYS(sizeof(buf) - 1), buf);
|
rc = ioctl(fd, EVIOCGPHYS(sizeof(buf) - 1), buf);
|
||||||
|
|
@ -159,12 +158,11 @@ libevdev_set_fd(struct libevdev* dev, int fd)
|
||||||
if (errno != ENOENT)
|
if (errno != ENOENT)
|
||||||
goto out;
|
goto out;
|
||||||
} else {
|
} else {
|
||||||
dev->phys = calloc(strlen(buf) + 1, sizeof(char));
|
dev->phys = strdup(buf);
|
||||||
if (!dev->phys) {
|
if (!dev->phys) {
|
||||||
errno = ENOSPC;
|
errno = ENOSPC;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
strcpy(dev->phys, buf);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
memset(buf, 0, sizeof(buf));
|
memset(buf, 0, sizeof(buf));
|
||||||
|
|
@ -173,12 +171,11 @@ libevdev_set_fd(struct libevdev* dev, int fd)
|
||||||
if (errno != ENOENT)
|
if (errno != ENOENT)
|
||||||
goto out;
|
goto out;
|
||||||
} else {
|
} else {
|
||||||
dev->uniq = calloc(strlen(buf) + 1, sizeof(char));
|
dev->uniq = strdup(buf);
|
||||||
if (!dev->uniq) {
|
if (!dev->uniq) {
|
||||||
errno = ENOSPC;
|
errno = ENOSPC;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
strcpy(dev->uniq, buf);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = ioctl(fd, EVIOCGID, &dev->ids);
|
rc = ioctl(fd, EVIOCGID, &dev->ids);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue