From 8589ae19de1d5699a586f96fe34a35c586e1e29c Mon Sep 17 00:00:00 2001 From: random human Date: Fri, 31 Aug 2018 16:11:46 +0530 Subject: Fix bugs listed by clang's static analyzer A few pedantic changes and unused variables (1-4), and genuine bugs (5, 6). The reports with the corresponding files and lines numbers are as follows. 1. backend/libinput/tablet_pad.c@31,44,57 "Allocator sizeof operand mismatch" "Result of 'calloc' is converted to a pointer of type 'unsigned int', which is incompatible with sizeof operand type 'int'" 2. types/tablet_v2/wlr_tablet_v2_pad.c@371 "Allocator sizeof operand mismatch" "Result of 'calloc' is converted to a pointer of type 'uint32_t', which is incompatible with sizeof operand type 'int'" 3. types/wlr_cursor.c@335 "Dead initialization" "Value stored to 'dx'/'dy' during its initialization is never read" 4. rootston/xdg_shell.c@510 "Dead initialization" "Value stored to 'desktop' during its initialization is never read" 5. types/tablet_v2/wlr_tablet_v2_pad.c@475 "Dereference of null pointer" "Access to field 'strips' results in a dereference of a null pointer (loaded from field 'current_client')" The boolean logic was incorrect (c.f. the check in the following function). 6. examples/idle.c@163,174,182 "Uninitialized argument value" "1st function call argument is an uninitialized value" If close_timeout != 0, but simulate_activity_timeout >= close_timeout, the program would segfault at pthread_cancel(t1). --- rootston/xdg_shell.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'rootston') diff --git a/rootston/xdg_shell.c b/rootston/xdg_shell.c index fed9afcd..2cf2081e 100644 --- a/rootston/xdg_shell.c +++ b/rootston/xdg_shell.c @@ -507,8 +507,6 @@ static void decoration_handle_surface_commit(struct wl_listener *listener, } void handle_xdg_toplevel_decoration(struct wl_listener *listener, void *data) { - struct roots_desktop *desktop = - wl_container_of(listener, desktop, xdg_toplevel_decoration); struct wlr_xdg_toplevel_decoration_v1 *wlr_decoration = data; wlr_log(WLR_DEBUG, "new xdg toplevel decoration"); -- cgit v1.2.3 From 472476ebcfd3c78ee136f9a465523c236295a049 Mon Sep 17 00:00:00 2001 From: emersion Date: Sat, 1 Sep 2018 18:30:41 +0200 Subject: Do not modeset disabled outputs --- rootston/output.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'rootston') diff --git a/rootston/output.c b/rootston/output.c index d8edf1c2..8677f491 100644 --- a/rootston/output.c +++ b/rootston/output.c @@ -822,12 +822,6 @@ void handle_new_output(struct wl_listener *listener, void *data) { wlr_output->model, wlr_output->serial, wlr_output->phys_width, wlr_output->phys_height); - if (!wl_list_empty(&wlr_output->modes)) { - struct wlr_output_mode *mode = - wl_container_of((&wlr_output->modes)->prev, mode, link); - wlr_output_set_mode(wlr_output, mode); - } - struct roots_output *output = calloc(1, sizeof(struct roots_output)); clock_gettime(CLOCK_MONOTONIC, &output->last_frame); output->desktop = desktop; @@ -856,22 +850,28 @@ void handle_new_output(struct wl_listener *listener, void *data) { struct roots_output_config *output_config = roots_config_get_output(config, wlr_output); + + if ((!output_config || output_config->enable) && !wl_list_empty(&wlr_output->modes)) { + struct wlr_output_mode *mode = + wl_container_of(wlr_output->modes.prev, mode, link); + wlr_output_set_mode(wlr_output, mode); + } + if (output_config) { if (output_config->enable) { - struct roots_output_mode_config *mode_config; - if (wlr_output_is_drm(wlr_output)) { + struct roots_output_mode_config *mode_config; wl_list_for_each(mode_config, &output_config->modes, link) { wlr_drm_connector_add_mode(wlr_output, &mode_config->info); } - } else { - if (!wl_list_empty(&output_config->modes)) { - wlr_log(WLR_ERROR, "Can only add modes for DRM backend"); - } + } else if (!wl_list_empty(&output_config->modes)) { + wlr_log(WLR_ERROR, "Can only add modes for DRM backend"); } + if (output_config->mode.width) { set_mode(wlr_output, output_config); } + wlr_output_set_scale(wlr_output, output_config->scale); wlr_output_set_transform(wlr_output, output_config->transform); wlr_output_layout_add(desktop->layout, wlr_output, output_config->x, -- cgit v1.2.3 From 2f0815838d921f3fc4a22cb45985fd7d35db5d95 Mon Sep 17 00:00:00 2001 From: emersion Date: Sat, 1 Sep 2018 19:27:18 +0200 Subject: Init dmabuf global in renderer --- include/rootston/desktop.h | 2 -- render/wlr_renderer.c | 7 ++++++- rootston/desktop.c | 4 ---- 3 files changed, 6 insertions(+), 7 deletions(-) (limited to 'rootston') diff --git a/include/rootston/desktop.h b/include/rootston/desktop.h index 363a16f0..3496fb43 100644 --- a/include/rootston/desktop.h +++ b/include/rootston/desktop.h @@ -10,7 +10,6 @@ #include #include #include -#include #include #include #include @@ -53,7 +52,6 @@ struct roots_desktop { struct wlr_idle *idle; struct wlr_idle_inhibit_manager_v1 *idle_inhibit; struct wlr_input_inhibit_manager *input_inhibit; - struct wlr_linux_dmabuf_v1 *linux_dmabuf; struct wlr_layer_shell *layer_shell; struct wlr_virtual_keyboard_manager_v1 *virtual_keyboard; struct wlr_screencopy_manager_v1 *screencopy; diff --git a/render/wlr_renderer.c b/render/wlr_renderer.c index 6c2b9fbb..31bf2b18 100644 --- a/render/wlr_renderer.c +++ b/render/wlr_renderer.c @@ -1,10 +1,11 @@ #include #include #include +#include #include #include +#include #include -#include #include #include "util/signal.h" @@ -176,6 +177,10 @@ void wlr_renderer_init_wl_display(struct wlr_renderer *r, } } + if (r->impl->texture_from_dmabuf) { + wlr_linux_dmabuf_v1_create(wl_display, r); + } + if (r->impl->init_wl_display) { r->impl->init_wl_display(r, wl_display); } diff --git a/rootston/desktop.c b/rootston/desktop.c index 658611e3..efb7581a 100644 --- a/rootston/desktop.c +++ b/rootston/desktop.c @@ -14,7 +14,6 @@ #include #include #include -#include #include #include #include @@ -893,9 +892,6 @@ struct roots_desktop *desktop_create(struct roots_server *server, wl_signal_add(&desktop->input_inhibit->events.deactivate, &desktop->input_inhibit_deactivate); - desktop->linux_dmabuf = wlr_linux_dmabuf_v1_create(server->wl_display, - server->renderer); - desktop->virtual_keyboard = wlr_virtual_keyboard_manager_v1_create( server->wl_display); wl_signal_add(&desktop->virtual_keyboard->events.new_virtual_keyboard, -- cgit v1.2.3