mirror of
https://gitlab.freedesktop.org/libevdev/libevdev.git
synced 2025-12-24 18:10:07 +01:00
Use ENOMEM instead of ENOSPC
From errno(3): ENOMEM Not enough space (POSIX.1) ENOSPC No space left on device (POSIX.1) when we run out memory the reason is a failed malloc, for which ENOMEM seems more appropriate. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
This commit is contained in:
parent
69f89c8877
commit
9675287062
5 changed files with 10 additions and 10 deletions
|
|
@ -194,11 +194,11 @@ static inline int
|
|||
queue_alloc(struct libevdev *dev, size_t size)
|
||||
{
|
||||
if (size == 0)
|
||||
return -ENOSPC;
|
||||
return -ENOMEM;
|
||||
|
||||
dev->queue = calloc(size, sizeof(struct input_event));
|
||||
if (!dev->queue)
|
||||
return -ENOSPC;
|
||||
return -ENOMEM;
|
||||
|
||||
dev->queue_size = size;
|
||||
dev->queue_next = 0;
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@ libevdev_new_from_fd(int fd, struct libevdev **dev)
|
|||
|
||||
d = libevdev_new();
|
||||
if (!d)
|
||||
return -ENOSPC;
|
||||
return -ENOMEM;
|
||||
|
||||
rc = libevdev_set_fd(d, fd);
|
||||
if (rc < 0)
|
||||
|
|
@ -152,7 +152,7 @@ libevdev_set_fd(struct libevdev* dev, int fd)
|
|||
free(dev->name);
|
||||
dev->name = strdup(buf);
|
||||
if (!dev->name) {
|
||||
errno = ENOSPC;
|
||||
errno = ENOMEM;
|
||||
goto out;
|
||||
}
|
||||
|
||||
|
|
@ -167,7 +167,7 @@ libevdev_set_fd(struct libevdev* dev, int fd)
|
|||
} else {
|
||||
dev->phys = strdup(buf);
|
||||
if (!dev->phys) {
|
||||
errno = ENOSPC;
|
||||
errno = ENOMEM;
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
|
|
@ -182,7 +182,7 @@ libevdev_set_fd(struct libevdev* dev, int fd)
|
|||
} else {
|
||||
dev->uniq = strdup(buf);
|
||||
if (!dev->uniq) {
|
||||
errno = ENOSPC;
|
||||
errno = ENOMEM;
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -202,7 +202,7 @@ extern "C" {
|
|||
*
|
||||
* dev = libevdev_new();
|
||||
* if (!dev)
|
||||
* return ENOSPC;
|
||||
* return ENOMEM;
|
||||
*
|
||||
* err = libevdev_set_fd(dev, fd);
|
||||
* if (err < 0) {
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ uinput_device_new_with_events_v(struct uinput_device **d, const char *name, cons
|
|||
|
||||
dev = uinput_device_new(name);
|
||||
if (!dev)
|
||||
return -ENOSPC;
|
||||
return -ENOMEM;
|
||||
if (id != DEFAULT_IDS)
|
||||
uinput_device_set_ids(dev, id);
|
||||
|
||||
|
|
|
|||
|
|
@ -34,10 +34,10 @@ START_TEST(test_queue_alloc)
|
|||
int rc;
|
||||
|
||||
rc = queue_alloc(&dev, 0);
|
||||
ck_assert_int_eq(rc, -ENOSPC);
|
||||
ck_assert_int_eq(rc, -ENOMEM);
|
||||
|
||||
rc = queue_alloc(&dev, ULONG_MAX);
|
||||
ck_assert_int_eq(rc, -ENOSPC);
|
||||
ck_assert_int_eq(rc, -ENOMEM);
|
||||
|
||||
rc = queue_alloc(&dev, 100);
|
||||
ck_assert_int_eq(rc, 0);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue