mirror of
https://github.com/libratbag/libratbag.git
synced 2026-11-07 23:23:52 +01:00
Abort if zalloc fails
Let's not pretend we will handle out-of-memory errors correctly, and really, it's not something we really need to be worried about. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
@@ -687,9 +687,6 @@ etekcity_probe(struct ratbag_device *device, const struct ratbag_id id)
|
||||
}
|
||||
|
||||
drv_data = zalloc(sizeof(*drv_data));
|
||||
if (!drv_data)
|
||||
return -ENODEV;
|
||||
|
||||
ratbag_set_drv_data(device, drv_data);
|
||||
|
||||
/* retrieve the "on-to-go" speed setting */
|
||||
|
||||
@@ -208,10 +208,6 @@ hidpp10drv_probe(struct ratbag_device *device, const struct ratbag_id id)
|
||||
}
|
||||
|
||||
drv_data = zalloc(sizeof(*drv_data));
|
||||
if (!drv_data) {
|
||||
rc = -ENODEV;
|
||||
goto err;
|
||||
}
|
||||
|
||||
/* We can treat all devices as wired devices here. If we talk to the
|
||||
* correct hidraw device the kernel adjusts the device index for us,
|
||||
|
||||
@@ -443,9 +443,6 @@ hidpp20drv_probe(struct ratbag_device *device, const struct ratbag_id id)
|
||||
}
|
||||
|
||||
drv_data = zalloc(sizeof(*drv_data));
|
||||
if (!drv_data)
|
||||
return -ENODEV;
|
||||
|
||||
ratbag_set_drv_data(device, drv_data);
|
||||
|
||||
drv_data->proto_major = 1;
|
||||
|
||||
@@ -325,8 +325,6 @@ int hidpp20_feature_set_get(struct ratbag_device *device,
|
||||
}
|
||||
|
||||
flist = zalloc(feature_count * sizeof(struct hidpp20_feature));
|
||||
if (!flist)
|
||||
return -ENOMEM;
|
||||
|
||||
for (i = 0; i < feature_count; i++) {
|
||||
rc = hidpp20_feature_set_get_feature_id(device,
|
||||
@@ -464,8 +462,6 @@ hidpp20_kbd_reprogrammable_keys_get_controls(struct ratbag_device *device,
|
||||
}
|
||||
|
||||
c_list = zalloc(num_controls * sizeof(struct hidpp20_control_id));
|
||||
if (!c_list)
|
||||
return -ENOMEM;
|
||||
|
||||
for (i = 0; i < num_controls; i++) {
|
||||
control = &c_list[i];
|
||||
@@ -608,8 +604,6 @@ int hidpp20_special_key_mouse_get_controls(struct ratbag_device *device,
|
||||
}
|
||||
|
||||
c_list = zalloc(num_controls * sizeof(struct hidpp20_control_id));
|
||||
if (!c_list)
|
||||
return -ENOMEM;
|
||||
|
||||
for (i = 0; i < num_controls; i++) {
|
||||
control = &c_list[i];
|
||||
@@ -851,8 +845,6 @@ int hidpp20_adjustable_dpi_get_sensors(struct ratbag_device *device,
|
||||
}
|
||||
|
||||
s_list = zalloc(num_sensors * sizeof(struct hidpp20_sensor));
|
||||
if (!s_list)
|
||||
return -ENOMEM;
|
||||
|
||||
for (i = 0; i < num_sensors; i++) {
|
||||
sensor = &s_list[i];
|
||||
|
||||
@@ -92,7 +92,11 @@ strncpy_safe(char *dest, const char *src, size_t n)
|
||||
static inline void *
|
||||
zalloc(size_t size)
|
||||
{
|
||||
return calloc(1, size);
|
||||
void *p = calloc(1, size);
|
||||
|
||||
if (!p)
|
||||
abort();
|
||||
return p;
|
||||
}
|
||||
|
||||
static inline void
|
||||
|
||||
@@ -99,11 +99,6 @@ log_buffer(struct ratbag *ratbag,
|
||||
buf_len += 1; /* terminating '\0' */
|
||||
|
||||
output_buf = zalloc(buf_len);
|
||||
if (!output_buf) {
|
||||
log_msg(ratbag, priority, "%s ......", header ? header : "");
|
||||
return;
|
||||
}
|
||||
|
||||
n = 0;
|
||||
if (header)
|
||||
n += sprintf(output_buf, "%s", header);
|
||||
@@ -255,9 +250,6 @@ ratbag_device_new(struct ratbag *ratbag, struct udev_device *udev_device,
|
||||
struct ratbag_device *device = NULL;
|
||||
|
||||
device = zalloc(sizeof(*device));
|
||||
if (!device)
|
||||
return NULL;
|
||||
|
||||
device->name = strdup(name);
|
||||
|
||||
if (!name) {
|
||||
@@ -498,9 +490,6 @@ ratbag_create_context(const struct ratbag_interface *interface,
|
||||
return NULL;
|
||||
|
||||
ratbag = zalloc(sizeof(*ratbag));
|
||||
if (!ratbag)
|
||||
return NULL;
|
||||
|
||||
ratbag->refcount = 1;
|
||||
ratbag->interface = interface;
|
||||
ratbag->userdata = userdata;
|
||||
@@ -553,9 +542,6 @@ ratbag_create_button(struct ratbag_profile *profile, unsigned int index)
|
||||
struct ratbag_button *button;
|
||||
|
||||
button = zalloc(sizeof(*button));
|
||||
if (!button)
|
||||
return NULL;
|
||||
|
||||
button->refcount = 1;
|
||||
button->profile = profile;
|
||||
button->index = index;
|
||||
@@ -590,9 +576,6 @@ ratbag_create_profile(struct ratbag_device *device,
|
||||
unsigned i;
|
||||
|
||||
profile = zalloc(sizeof(*profile));
|
||||
if (!profile)
|
||||
return NULL;
|
||||
|
||||
profile->refcount = 1;
|
||||
profile->device = device;
|
||||
profile->index = index;
|
||||
|
||||
Reference in New Issue
Block a user