mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-12-23 18:39:48 +01:00
Merge pull request #1101 from martinetd/static-analysis
Static analysis fixes
This commit is contained in:
commit
167105e606
14 changed files with 50 additions and 28 deletions
|
@ -203,6 +203,7 @@ struct wlr_backend *wlr_backend_autocreate(struct wl_display *display,
|
||||||
wlr_log(L_ERROR, "failed to start backend '%s'", name);
|
wlr_log(L_ERROR, "failed to start backend '%s'", name);
|
||||||
wlr_backend_destroy(backend);
|
wlr_backend_destroy(backend);
|
||||||
wlr_session_destroy(session);
|
wlr_session_destroy(session);
|
||||||
|
free(names);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -210,12 +211,14 @@ struct wlr_backend *wlr_backend_autocreate(struct wl_display *display,
|
||||||
wlr_log(L_ERROR, "failed to add backend '%s'", name);
|
wlr_log(L_ERROR, "failed to add backend '%s'", name);
|
||||||
wlr_backend_destroy(backend);
|
wlr_backend_destroy(backend);
|
||||||
wlr_session_destroy(session);
|
wlr_session_destroy(session);
|
||||||
|
free(names);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
name = strtok_r(NULL, ",", &saveptr);
|
name = strtok_r(NULL, ",", &saveptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
free(names);
|
||||||
return backend;
|
return backend;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -83,8 +83,8 @@ static void set_plane_props(struct atomic *atom, struct wlr_drm_plane *plane,
|
||||||
// The src_* properties are in 16.16 fixed point
|
// The src_* properties are in 16.16 fixed point
|
||||||
atomic_add(atom, id, props->src_x, 0);
|
atomic_add(atom, id, props->src_x, 0);
|
||||||
atomic_add(atom, id, props->src_y, 0);
|
atomic_add(atom, id, props->src_y, 0);
|
||||||
atomic_add(atom, id, props->src_w, plane->surf.width << 16);
|
atomic_add(atom, id, props->src_w, (uint64_t)plane->surf.width << 16);
|
||||||
atomic_add(atom, id, props->src_h, plane->surf.height << 16);
|
atomic_add(atom, id, props->src_h, (uint64_t)plane->surf.height << 16);
|
||||||
atomic_add(atom, id, props->crtc_w, plane->surf.width);
|
atomic_add(atom, id, props->crtc_w, plane->surf.width);
|
||||||
atomic_add(atom, id, props->crtc_h, plane->surf.height);
|
atomic_add(atom, id, props->crtc_h, plane->surf.height);
|
||||||
atomic_add(atom, id, props->fb_id, fb_id);
|
atomic_add(atom, id, props->fb_id, fb_id);
|
||||||
|
|
|
@ -973,7 +973,7 @@ int handle_drm_event(int fd, uint32_t mask, void *data) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void restore_drm_outputs(struct wlr_drm_backend *drm) {
|
void restore_drm_outputs(struct wlr_drm_backend *drm) {
|
||||||
uint64_t to_close = (1 << wl_list_length(&drm->outputs)) - 1;
|
uint64_t to_close = (1L << wl_list_length(&drm->outputs)) - 1;
|
||||||
|
|
||||||
struct wlr_drm_connector *conn;
|
struct wlr_drm_connector *conn;
|
||||||
wl_list_for_each(conn, &drm->outputs, link) {
|
wl_list_for_each(conn, &drm->outputs, link) {
|
||||||
|
|
|
@ -39,7 +39,7 @@ struct wlr_input_device *wlr_headless_add_input_device(
|
||||||
wlr_device->keyboard = calloc(1, sizeof(struct wlr_keyboard));
|
wlr_device->keyboard = calloc(1, sizeof(struct wlr_keyboard));
|
||||||
if (wlr_device->keyboard == NULL) {
|
if (wlr_device->keyboard == NULL) {
|
||||||
wlr_log(L_ERROR, "Unable to allocate wlr_keyboard");
|
wlr_log(L_ERROR, "Unable to allocate wlr_keyboard");
|
||||||
return NULL;
|
goto error;
|
||||||
}
|
}
|
||||||
wlr_keyboard_init(wlr_device->keyboard, NULL);
|
wlr_keyboard_init(wlr_device->keyboard, NULL);
|
||||||
break;
|
break;
|
||||||
|
@ -47,7 +47,7 @@ struct wlr_input_device *wlr_headless_add_input_device(
|
||||||
wlr_device->pointer = calloc(1, sizeof(struct wlr_pointer));
|
wlr_device->pointer = calloc(1, sizeof(struct wlr_pointer));
|
||||||
if (wlr_device->pointer == NULL) {
|
if (wlr_device->pointer == NULL) {
|
||||||
wlr_log(L_ERROR, "Unable to allocate wlr_pointer");
|
wlr_log(L_ERROR, "Unable to allocate wlr_pointer");
|
||||||
return NULL;
|
goto error;
|
||||||
}
|
}
|
||||||
wlr_pointer_init(wlr_device->pointer, NULL);
|
wlr_pointer_init(wlr_device->pointer, NULL);
|
||||||
break;
|
break;
|
||||||
|
@ -55,7 +55,7 @@ struct wlr_input_device *wlr_headless_add_input_device(
|
||||||
wlr_device->touch = calloc(1, sizeof(struct wlr_touch));
|
wlr_device->touch = calloc(1, sizeof(struct wlr_touch));
|
||||||
if (wlr_device->touch == NULL) {
|
if (wlr_device->touch == NULL) {
|
||||||
wlr_log(L_ERROR, "Unable to allocate wlr_touch");
|
wlr_log(L_ERROR, "Unable to allocate wlr_touch");
|
||||||
return NULL;
|
goto error;
|
||||||
}
|
}
|
||||||
wlr_touch_init(wlr_device->touch, NULL);
|
wlr_touch_init(wlr_device->touch, NULL);
|
||||||
break;
|
break;
|
||||||
|
@ -63,7 +63,7 @@ struct wlr_input_device *wlr_headless_add_input_device(
|
||||||
wlr_device->tablet_tool = calloc(1, sizeof(struct wlr_tablet_tool));
|
wlr_device->tablet_tool = calloc(1, sizeof(struct wlr_tablet_tool));
|
||||||
if (wlr_device->tablet_tool == NULL) {
|
if (wlr_device->tablet_tool == NULL) {
|
||||||
wlr_log(L_ERROR, "Unable to allocate wlr_tablet_tool");
|
wlr_log(L_ERROR, "Unable to allocate wlr_tablet_tool");
|
||||||
return NULL;
|
goto error;
|
||||||
}
|
}
|
||||||
wlr_tablet_tool_init(wlr_device->tablet_tool, NULL);
|
wlr_tablet_tool_init(wlr_device->tablet_tool, NULL);
|
||||||
break;
|
break;
|
||||||
|
@ -71,7 +71,7 @@ struct wlr_input_device *wlr_headless_add_input_device(
|
||||||
wlr_device->tablet_pad = calloc(1, sizeof(struct wlr_tablet_pad));
|
wlr_device->tablet_pad = calloc(1, sizeof(struct wlr_tablet_pad));
|
||||||
if (wlr_device->tablet_pad == NULL) {
|
if (wlr_device->tablet_pad == NULL) {
|
||||||
wlr_log(L_ERROR, "Unable to allocate wlr_tablet_pad");
|
wlr_log(L_ERROR, "Unable to allocate wlr_tablet_pad");
|
||||||
return NULL;
|
goto error;
|
||||||
}
|
}
|
||||||
wlr_tablet_pad_init(wlr_device->tablet_pad, NULL);
|
wlr_tablet_pad_init(wlr_device->tablet_pad, NULL);
|
||||||
break;
|
break;
|
||||||
|
@ -84,4 +84,7 @@ struct wlr_input_device *wlr_headless_add_input_device(
|
||||||
}
|
}
|
||||||
|
|
||||||
return wlr_device;
|
return wlr_device;
|
||||||
|
error:
|
||||||
|
free(device);
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -159,7 +159,9 @@ static void communicate(int sock) {
|
||||||
}
|
}
|
||||||
error:
|
error:
|
||||||
send_msg(sock, ret ? -1 : fd, &ret, sizeof(ret));
|
send_msg(sock, ret ? -1 : fd, &ret, sizeof(ret));
|
||||||
|
if (fd >= 0) {
|
||||||
close(fd);
|
close(fd);
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
|
@ -220,7 +220,7 @@ static void xdg_toplevel_handle_configure(void *data, struct zxdg_toplevel_v6 *x
|
||||||
struct wlr_wl_output *output = data;
|
struct wlr_wl_output *output = data;
|
||||||
assert(output && output->xdg_toplevel == xdg_toplevel);
|
assert(output && output->xdg_toplevel == xdg_toplevel);
|
||||||
|
|
||||||
if (width == 0 && height == 0) {
|
if (width == 0 || height == 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// loop over states for maximized etc?
|
// loop over states for maximized etc?
|
||||||
|
|
|
@ -38,10 +38,8 @@ static void pointer_handle_enter(void *data, struct wl_pointer *wl_pointer,
|
||||||
}
|
}
|
||||||
|
|
||||||
struct wlr_wl_output *output = wl_surface_get_user_data(surface);
|
struct wlr_wl_output *output = wl_surface_get_user_data(surface);
|
||||||
|
assert(output);
|
||||||
struct wlr_wl_pointer *pointer = output_get_pointer(output);
|
struct wlr_wl_pointer *pointer = output_get_pointer(output);
|
||||||
if (output == NULL) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
output->enter_serial = serial;
|
output->enter_serial = serial;
|
||||||
backend->current_pointer = pointer;
|
backend->current_pointer = pointer;
|
||||||
|
@ -56,6 +54,7 @@ static void pointer_handle_leave(void *data, struct wl_pointer *wl_pointer,
|
||||||
}
|
}
|
||||||
|
|
||||||
struct wlr_wl_output *output = wl_surface_get_user_data(surface);
|
struct wlr_wl_output *output = wl_surface_get_user_data(surface);
|
||||||
|
assert(output);
|
||||||
output->enter_serial = 0;
|
output->enter_serial = 0;
|
||||||
|
|
||||||
if (backend->current_pointer == NULL ||
|
if (backend->current_pointer == NULL ||
|
||||||
|
|
|
@ -245,13 +245,13 @@ struct wlr_backend *wlr_x11_backend_create(struct wl_display *display,
|
||||||
x11->xlib_conn = XOpenDisplay(x11_display);
|
x11->xlib_conn = XOpenDisplay(x11_display);
|
||||||
if (!x11->xlib_conn) {
|
if (!x11->xlib_conn) {
|
||||||
wlr_log(L_ERROR, "Failed to open X connection");
|
wlr_log(L_ERROR, "Failed to open X connection");
|
||||||
return NULL;
|
goto error_x11;
|
||||||
}
|
}
|
||||||
|
|
||||||
x11->xcb_conn = XGetXCBConnection(x11->xlib_conn);
|
x11->xcb_conn = XGetXCBConnection(x11->xlib_conn);
|
||||||
if (!x11->xcb_conn || xcb_connection_has_error(x11->xcb_conn)) {
|
if (!x11->xcb_conn || xcb_connection_has_error(x11->xcb_conn)) {
|
||||||
wlr_log(L_ERROR, "Failed to open xcb connection");
|
wlr_log(L_ERROR, "Failed to open xcb connection");
|
||||||
goto error_x11;
|
goto error_display;
|
||||||
}
|
}
|
||||||
|
|
||||||
XSetEventQueueOwner(x11->xlib_conn, XCBOwnsEventQueue);
|
XSetEventQueueOwner(x11->xlib_conn, XCBOwnsEventQueue);
|
||||||
|
@ -262,7 +262,7 @@ struct wlr_backend *wlr_x11_backend_create(struct wl_display *display,
|
||||||
x11->event_source = wl_event_loop_add_fd(ev, fd, events, x11_event, x11);
|
x11->event_source = wl_event_loop_add_fd(ev, fd, events, x11_event, x11);
|
||||||
if (!x11->event_source) {
|
if (!x11->event_source) {
|
||||||
wlr_log(L_ERROR, "Could not create event source");
|
wlr_log(L_ERROR, "Could not create event source");
|
||||||
goto error_x11;
|
goto error_display;
|
||||||
}
|
}
|
||||||
|
|
||||||
x11->screen = xcb_setup_roots_iterator(xcb_get_setup(x11->xcb_conn)).data;
|
x11->screen = xcb_setup_roots_iterator(xcb_get_setup(x11->xcb_conn)).data;
|
||||||
|
@ -291,8 +291,9 @@ struct wlr_backend *wlr_x11_backend_create(struct wl_display *display,
|
||||||
|
|
||||||
error_event:
|
error_event:
|
||||||
wl_event_source_remove(x11->event_source);
|
wl_event_source_remove(x11->event_source);
|
||||||
error_x11:
|
error_display:
|
||||||
XCloseDisplay(x11->xlib_conn);
|
XCloseDisplay(x11->xlib_conn);
|
||||||
|
error_x11:
|
||||||
free(x11);
|
free(x11);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,9 +25,12 @@ void wlr_renderer_init(struct wlr_renderer *renderer,
|
||||||
}
|
}
|
||||||
|
|
||||||
void wlr_renderer_destroy(struct wlr_renderer *r) {
|
void wlr_renderer_destroy(struct wlr_renderer *r) {
|
||||||
|
if (!r) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
wlr_signal_emit_safe(&r->events.destroy, r);
|
wlr_signal_emit_safe(&r->events.destroy, r);
|
||||||
|
|
||||||
if (r && r->impl && r->impl->destroy) {
|
if (r->impl && r->impl->destroy) {
|
||||||
r->impl->destroy(r);
|
r->impl->destroy(r);
|
||||||
} else {
|
} else {
|
||||||
free(r);
|
free(r);
|
||||||
|
|
|
@ -381,12 +381,6 @@ void handle_layer_shell_surface(struct wl_listener *listener, void *data) {
|
||||||
layer_surface->client_pending.margin.bottom,
|
layer_surface->client_pending.margin.bottom,
|
||||||
layer_surface->client_pending.margin.left);
|
layer_surface->client_pending.margin.left);
|
||||||
|
|
||||||
struct roots_layer_surface *roots_surface =
|
|
||||||
calloc(1, sizeof(struct roots_layer_surface));
|
|
||||||
if (!roots_surface) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!layer_surface->output) {
|
if (!layer_surface->output) {
|
||||||
struct roots_input *input = desktop->server->input;
|
struct roots_input *input = desktop->server->input;
|
||||||
struct roots_seat *seat = input_last_active_seat(input);
|
struct roots_seat *seat = input_last_active_seat(input);
|
||||||
|
@ -409,6 +403,12 @@ void handle_layer_shell_surface(struct wl_listener *listener, void *data) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct roots_layer_surface *roots_surface =
|
||||||
|
calloc(1, sizeof(struct roots_layer_surface));
|
||||||
|
if (!roots_surface) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
roots_surface->surface_commit.notify = handle_surface_commit;
|
roots_surface->surface_commit.notify = handle_surface_commit;
|
||||||
wl_signal_add(&layer_surface->surface->events.commit,
|
wl_signal_add(&layer_surface->surface->events.commit,
|
||||||
&roots_surface->surface_commit);
|
&roots_surface->surface_commit);
|
||||||
|
|
|
@ -84,6 +84,7 @@ static void manager_handle_capture_output(struct wl_client *client,
|
||||||
&zwlr_export_dmabuf_frame_v1_interface, version, id);
|
&zwlr_export_dmabuf_frame_v1_interface, version, id);
|
||||||
if (frame->resource == NULL) {
|
if (frame->resource == NULL) {
|
||||||
wl_client_post_no_memory(client);
|
wl_client_post_no_memory(client);
|
||||||
|
free(frame);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
wl_resource_set_implementation(frame->resource, &frame_impl, frame,
|
wl_resource_set_implementation(frame->resource, &frame_impl, frame,
|
||||||
|
|
|
@ -144,6 +144,7 @@ void wlr_keyboard_init(struct wlr_keyboard *kb,
|
||||||
wl_signal_init(&kb->events.modifiers);
|
wl_signal_init(&kb->events.modifiers);
|
||||||
wl_signal_init(&kb->events.keymap);
|
wl_signal_init(&kb->events.keymap);
|
||||||
wl_signal_init(&kb->events.repeat_info);
|
wl_signal_init(&kb->events.repeat_info);
|
||||||
|
kb->keymap_fd = -1;
|
||||||
|
|
||||||
// Sane defaults
|
// Sane defaults
|
||||||
kb->repeat_info.rate = 25;
|
kb->repeat_info.rate = 25;
|
||||||
|
@ -156,7 +157,9 @@ void wlr_keyboard_destroy(struct wlr_keyboard *kb) {
|
||||||
}
|
}
|
||||||
xkb_state_unref(kb->xkb_state);
|
xkb_state_unref(kb->xkb_state);
|
||||||
xkb_keymap_unref(kb->keymap);
|
xkb_keymap_unref(kb->keymap);
|
||||||
|
if (kb->keymap_fd >= 0) {
|
||||||
close(kb->keymap_fd);
|
close(kb->keymap_fd);
|
||||||
|
}
|
||||||
if (kb->impl && kb->impl->destroy) {
|
if (kb->impl && kb->impl->destroy) {
|
||||||
kb->impl->destroy(kb);
|
kb->impl->destroy(kb);
|
||||||
} else {
|
} else {
|
||||||
|
@ -212,7 +215,7 @@ void wlr_keyboard_set_keymap(struct wlr_keyboard *kb,
|
||||||
keymap_str = xkb_keymap_get_as_string(kb->keymap,
|
keymap_str = xkb_keymap_get_as_string(kb->keymap,
|
||||||
XKB_KEYMAP_FORMAT_TEXT_V1);
|
XKB_KEYMAP_FORMAT_TEXT_V1);
|
||||||
kb->keymap_size = strlen(keymap_str) + 1;
|
kb->keymap_size = strlen(keymap_str) + 1;
|
||||||
if (kb->keymap_fd) {
|
if (kb->keymap_fd >= 0) {
|
||||||
close(kb->keymap_fd);
|
close(kb->keymap_fd);
|
||||||
}
|
}
|
||||||
kb->keymap_fd = os_create_anonymous_file(kb->keymap_size);
|
kb->keymap_fd = os_create_anonymous_file(kb->keymap_size);
|
||||||
|
@ -228,6 +231,7 @@ void wlr_keyboard_set_keymap(struct wlr_keyboard *kb,
|
||||||
}
|
}
|
||||||
strcpy(ptr, keymap_str);
|
strcpy(ptr, keymap_str);
|
||||||
free(keymap_str);
|
free(keymap_str);
|
||||||
|
munmap(ptr, kb->keymap_size);
|
||||||
|
|
||||||
for (size_t i = 0; i < kb->num_keycodes; ++i) {
|
for (size_t i = 0; i < kb->num_keycodes; ++i) {
|
||||||
xkb_keycode_t keycode = kb->keycodes[i] + 8;
|
xkb_keycode_t keycode = kb->keycodes[i] + 8;
|
||||||
|
@ -244,7 +248,10 @@ err:
|
||||||
kb->xkb_state = NULL;
|
kb->xkb_state = NULL;
|
||||||
xkb_keymap_unref(keymap);
|
xkb_keymap_unref(keymap);
|
||||||
kb->keymap = NULL;
|
kb->keymap = NULL;
|
||||||
|
if (kb->keymap_fd >= 0) {
|
||||||
close(kb->keymap_fd);
|
close(kb->keymap_fd);
|
||||||
|
kb->keymap_fd = -1;
|
||||||
|
}
|
||||||
free(keymap_str);
|
free(keymap_str);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -486,8 +486,8 @@ bool wlr_output_swap_buffers(struct wlr_output *output, struct timespec *when,
|
||||||
pixman_region32_intersect(&render_damage, &render_damage, damage);
|
pixman_region32_intersect(&render_damage, &render_damage, damage);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (when == NULL) {
|
|
||||||
struct timespec now;
|
struct timespec now;
|
||||||
|
if (when == NULL) {
|
||||||
clock_gettime(CLOCK_MONOTONIC, &now);
|
clock_gettime(CLOCK_MONOTONIC, &now);
|
||||||
when = &now;
|
when = &now;
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include "util/os-compatibility.h"
|
#include "util/os-compatibility.h"
|
||||||
|
@ -61,6 +62,7 @@ int create_tmpfile_cloexec(char *tmpname)
|
||||||
{
|
{
|
||||||
int fd;
|
int fd;
|
||||||
|
|
||||||
|
mode_t prev_umask = umask(0066);
|
||||||
#ifdef HAVE_MKOSTEMP
|
#ifdef HAVE_MKOSTEMP
|
||||||
fd = mkostemp(tmpname, O_CLOEXEC);
|
fd = mkostemp(tmpname, O_CLOEXEC);
|
||||||
if (fd >= 0)
|
if (fd >= 0)
|
||||||
|
@ -72,6 +74,7 @@ int create_tmpfile_cloexec(char *tmpname)
|
||||||
unlink(tmpname);
|
unlink(tmpname);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
umask(prev_umask);
|
||||||
|
|
||||||
return fd;
|
return fd;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue