mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2025-11-02 09:01:38 -05:00
Zero-initialize structs in init functions
Ensures there is no field left to its previous undefined value after calling an init function.
This commit is contained in:
parent
54653b5d95
commit
6c350799b2
20 changed files with 29 additions and 1 deletions
|
|
@ -15,6 +15,7 @@ void wlr_data_source_init(struct wlr_data_source *source,
|
|||
const struct wlr_data_source_impl *impl) {
|
||||
assert(impl->send);
|
||||
|
||||
memset(source, 0, sizeof(*source));
|
||||
source->impl = impl;
|
||||
wl_array_init(&source->mime_types);
|
||||
wl_signal_init(&source->events.destroy);
|
||||
|
|
|
|||
|
|
@ -377,6 +377,8 @@ void wlr_output_init(struct wlr_output *output, struct wlr_backend *backend,
|
|||
if (impl->set_cursor || impl->move_cursor) {
|
||||
assert(impl->set_cursor && impl->move_cursor);
|
||||
}
|
||||
|
||||
memset(output, 0, sizeof(*output));
|
||||
output->backend = backend;
|
||||
output->impl = impl;
|
||||
output->display = display;
|
||||
|
|
|
|||
|
|
@ -48,6 +48,7 @@ static struct wlr_scene *scene_node_get_root(struct wlr_scene_node *node) {
|
|||
}
|
||||
|
||||
static void scene_node_state_init(struct wlr_scene_node_state *state) {
|
||||
memset(state, 0, sizeof(*state));
|
||||
wl_list_init(&state->children);
|
||||
wl_list_init(&state->link);
|
||||
state->enabled = true;
|
||||
|
|
@ -61,6 +62,7 @@ static void scene_node_init(struct wlr_scene_node *node,
|
|||
enum wlr_scene_node_type type, struct wlr_scene_node *parent) {
|
||||
assert(type == WLR_SCENE_NODE_ROOT || parent != NULL);
|
||||
|
||||
memset(node, 0, sizeof(*node));
|
||||
node->type = type;
|
||||
node->parent = parent;
|
||||
scene_node_state_init(&node->state);
|
||||
|
|
|
|||
|
|
@ -17,6 +17,8 @@ void wlr_buffer_init(struct wlr_buffer *buffer,
|
|||
if (impl->begin_data_ptr_access || impl->end_data_ptr_access) {
|
||||
assert(impl->begin_data_ptr_access && impl->end_data_ptr_access);
|
||||
}
|
||||
|
||||
memset(buffer, 0, sizeof(*buffer));
|
||||
buffer->impl = impl;
|
||||
buffer->width = width;
|
||||
buffer->height = height;
|
||||
|
|
|
|||
|
|
@ -583,6 +583,8 @@ struct wlr_surface *wlr_surface_from_resource(struct wl_resource *resource) {
|
|||
}
|
||||
|
||||
static void surface_state_init(struct wlr_surface_state *state) {
|
||||
memset(state, 0, sizeof(*state));
|
||||
|
||||
state->scale = 1;
|
||||
state->transform = WL_OUTPUT_TRANSFORM_NORMAL;
|
||||
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
void wlr_input_device_init(struct wlr_input_device *dev,
|
||||
enum wlr_input_device_type type, const char *name) {
|
||||
memset(dev, 0, sizeof(*dev));
|
||||
dev->type = type;
|
||||
dev->name = strdup(name);
|
||||
dev->vendor = 0;
|
||||
|
|
|
|||
|
|
@ -116,6 +116,7 @@ void wlr_keyboard_notify_key(struct wlr_keyboard *keyboard,
|
|||
|
||||
void wlr_keyboard_init(struct wlr_keyboard *kb,
|
||||
const struct wlr_keyboard_impl *impl, const char *name) {
|
||||
memset(kb, 0, sizeof(*kb));
|
||||
wlr_input_device_init(&kb->base, WLR_INPUT_DEVICE_KEYBOARD, name);
|
||||
kb->base.keyboard = kb;
|
||||
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@
|
|||
|
||||
void wlr_pointer_init(struct wlr_pointer *pointer,
|
||||
const struct wlr_pointer_impl *impl, const char *name) {
|
||||
memset(pointer, 0, sizeof(*pointer));
|
||||
wlr_input_device_init(&pointer->base, WLR_INPUT_DEVICE_POINTER, name);
|
||||
pointer->base.pointer = pointer;
|
||||
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ void wlr_primary_selection_source_init(
|
|||
struct wlr_primary_selection_source *source,
|
||||
const struct wlr_primary_selection_source_impl *impl) {
|
||||
assert(impl->send);
|
||||
memset(source, 0, sizeof(*source));
|
||||
wl_array_init(&source->mime_types);
|
||||
wl_signal_init(&source->events.destroy);
|
||||
source->impl = impl;
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@
|
|||
|
||||
void wlr_switch_init(struct wlr_switch *switch_device,
|
||||
const struct wlr_switch_impl *impl, const char *name) {
|
||||
memset(switch_device, 0, sizeof(*switch_device));
|
||||
wlr_input_device_init(&switch_device->base, WLR_INPUT_DEVICE_SWITCH, name);
|
||||
switch_device->base.switch_device = switch_device;
|
||||
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@
|
|||
|
||||
void wlr_tablet_pad_init(struct wlr_tablet_pad *pad,
|
||||
const struct wlr_tablet_pad_impl *impl, const char *name) {
|
||||
memset(pad, 0, sizeof(*pad));
|
||||
wlr_input_device_init(&pad->base, WLR_INPUT_DEVICE_TABLET_PAD, name);
|
||||
pad->base.tablet_pad = pad;
|
||||
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@
|
|||
|
||||
void wlr_tablet_init(struct wlr_tablet *tablet,
|
||||
const struct wlr_tablet_impl *impl, const char *name) {
|
||||
memset(tablet, 0, sizeof(*tablet));
|
||||
wlr_input_device_init(&tablet->base, WLR_INPUT_DEVICE_TABLET_TOOL, name);
|
||||
tablet->base.tablet = tablet;
|
||||
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@
|
|||
|
||||
void wlr_touch_init(struct wlr_touch *touch,
|
||||
const struct wlr_touch_impl *impl, const char *name) {
|
||||
memset(touch, 0, sizeof(*touch));
|
||||
wlr_input_device_init(&touch->base, WLR_INPUT_DEVICE_TOUCH, name);
|
||||
touch->base.touch = touch;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue