From 75f9feb6de74c7286c42c9bf0d71a2cca52295ae Mon Sep 17 00:00:00 2001 From: Tobias Blass Date: Wed, 30 May 2018 01:12:34 +0200 Subject: Fix double-free in the rotation.c example. The wl_display_destroy function already destroys the backend's renderer. Freeing it by hand causes a segmentation fault. --- examples/rotation.c | 1 - 1 file changed, 1 deletion(-) (limited to 'examples') diff --git a/examples/rotation.c b/examples/rotation.c index bd39a21e..9e9e059a 100644 --- a/examples/rotation.c +++ b/examples/rotation.c @@ -268,6 +268,5 @@ int main(int argc, char *argv[]) { wl_display_run(display); wlr_texture_destroy(state.cat_texture); - wlr_renderer_destroy(state.renderer); wl_display_destroy(display); } -- cgit v1.2.3 From a21894a844963f3b48d17caadf18b3371dab2da7 Mon Sep 17 00:00:00 2001 From: Tobias Blass Date: Wed, 30 May 2018 08:24:25 +0200 Subject: Fix double-free in the tablet.c and touch.c examples The wl_display_destroy function already destroys the backend's renderer. Freeing it by hand causes a segmentation fault. --- examples/tablet.c | 1 - examples/touch.c | 1 - 2 files changed, 2 deletions(-) (limited to 'examples') diff --git a/examples/tablet.c b/examples/tablet.c index f5c4bbb5..e734ca84 100644 --- a/examples/tablet.c +++ b/examples/tablet.c @@ -372,6 +372,5 @@ int main(int argc, char *argv[]) { } wl_display_run(display); - wlr_renderer_destroy(state.renderer); wl_display_destroy(display); } diff --git a/examples/touch.c b/examples/touch.c index 68f78a0a..0e77b48e 100644 --- a/examples/touch.c +++ b/examples/touch.c @@ -277,6 +277,5 @@ int main(int argc, char *argv[]) { wl_display_run(display); wlr_texture_destroy(state.cat_texture); - wlr_renderer_destroy(state.renderer); wl_display_destroy(display); } -- cgit v1.2.3 From 0c1f50168b880d1d37b06c7c7f93e6498ae9f2ad Mon Sep 17 00:00:00 2001 From: emersion Date: Wed, 30 May 2018 08:34:49 +0100 Subject: examples/output-layout: destroy wl_display Thanks @tobiasblass for pointing this out. See #1017. --- examples/output-layout.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'examples') diff --git a/examples/output-layout.c b/examples/output-layout.c index 7b847a3b..bdc8d352 100644 --- a/examples/output-layout.c +++ b/examples/output-layout.c @@ -284,7 +284,7 @@ int main(int argc, char *argv[]) { wl_display_run(display); wlr_texture_destroy(state.cat_texture); - wlr_renderer_destroy(state.renderer); wlr_output_layout_destroy(state.layout); + wl_display_destroy(state.display); } -- cgit v1.2.3 From d1cf9acbd5ab6735952d013e5eb685e7139094a7 Mon Sep 17 00:00:00 2001 From: Genki Sky Date: Wed, 30 May 2018 20:11:57 -0400 Subject: cleanup: Use void for zero-parameter functions Signed-off-by: Genki Sky --- CONTRIBUTING.md | 2 +- examples/layer-shell.c | 4 ++-- examples/simple.c | 2 +- render/gles2/renderer.c | 2 +- types/wlr_cursor.c | 2 +- types/wlr_output_layout.c | 2 +- types/wlr_surface.c | 2 +- 7 files changed, 8 insertions(+), 8 deletions(-) (limited to 'examples') diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 41f504bc..aca308b3 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -96,7 +96,7 @@ not use GNU extensions. Brackets always go on the same line, including in functions. Always include brackets for if/while/for, even if it's a single statement. ```c -void function() { +void function(void) { if (condition1) { do_thing1(); } diff --git a/examples/layer-shell.c b/examples/layer-shell.c index ec25fe42..21ef3e93 100644 --- a/examples/layer-shell.c +++ b/examples/layer-shell.c @@ -149,7 +149,7 @@ static void draw(void) { demo.last_frame = ts; } -static void draw_popup() { +static void draw_popup(void) { static float alpha_mod = -0.01; eglMakeCurrent(egl.display, popup_egl_surface, popup_egl_surface, egl.context); @@ -188,7 +188,7 @@ static void xdg_popup_configure(void *data, struct xdg_popup *xdg_popup, } } -static void popup_destroy() { +static void popup_destroy(void) { wlr_egl_destroy_surface(&egl, popup_egl_surface); wl_egl_window_destroy(popup_egl_window); xdg_popup_destroy(popup); diff --git a/examples/simple.c b/examples/simple.c index 60acd7db..cbe60c98 100644 --- a/examples/simple.c +++ b/examples/simple.c @@ -143,7 +143,7 @@ void new_input_notify(struct wl_listener *listener, void *data) { } } -int main() { +int main(void) { wlr_log_init(L_DEBUG, NULL); struct wl_display *display = wl_display_create(); struct sample_state state = { diff --git a/render/gles2/renderer.c b/render/gles2/renderer.c index e68bb83f..00a5c285 100644 --- a/render/gles2/renderer.c +++ b/render/gles2/renderer.c @@ -84,7 +84,7 @@ static void gles2_scissor(struct wlr_renderer *wlr_renderer, POP_GLES2_DEBUG; } -static void draw_quad() { +static void draw_quad(void) { GLfloat verts[] = { 1, 0, // top right 0, 0, // top left diff --git a/types/wlr_cursor.c b/types/wlr_cursor.c index 9a31fca2..32d990cf 100644 --- a/types/wlr_cursor.c +++ b/types/wlr_cursor.c @@ -56,7 +56,7 @@ struct wlr_cursor_state { struct wl_listener layout_destroy; }; -struct wlr_cursor *wlr_cursor_create() { +struct wlr_cursor *wlr_cursor_create(void) { struct wlr_cursor *cur = calloc(1, sizeof(struct wlr_cursor)); if (!cur) { wlr_log(L_ERROR, "Failed to allocate wlr_cursor"); diff --git a/types/wlr_output_layout.c b/types/wlr_output_layout.c index 38329a48..bb1d399a 100644 --- a/types/wlr_output_layout.c +++ b/types/wlr_output_layout.c @@ -25,7 +25,7 @@ struct wlr_output_layout_output_state { struct wl_listener output_destroy; }; -struct wlr_output_layout *wlr_output_layout_create() { +struct wlr_output_layout *wlr_output_layout_create(void) { struct wlr_output_layout *layout = calloc(1, sizeof(struct wlr_output_layout)); if (layout == NULL) { diff --git a/types/wlr_surface.c b/types/wlr_surface.c index 3949f3e2..61284416 100644 --- a/types/wlr_surface.c +++ b/types/wlr_surface.c @@ -570,7 +570,7 @@ struct wlr_surface *wlr_surface_from_resource(struct wl_resource *resource) { return wl_resource_get_user_data(resource); } -static struct wlr_surface_state *surface_state_create() { +static struct wlr_surface_state *surface_state_create(void) { struct wlr_surface_state *state = calloc(1, sizeof(struct wlr_surface_state)); if (state == NULL) { -- cgit v1.2.3