From 989438a1cbb2b4d013a2a1daab25858e455b07be Mon Sep 17 00:00:00 2001 From: project-repo Date: Thu, 21 May 2020 19:36:35 +0200 Subject: [PATCH] Fix compilation under clang --- cagebreak.c | 4 ++++ config.h.in | 1 + idle_inhibit_v1.c | 4 ++++ meson.build | 7 +++++++ message.c | 4 ++++ output.c | 4 ++++ parse.c | 4 ++++ workspace.c | 4 ++++ xdg_shell.c | 4 ++++ 9 files changed, 36 insertions(+) diff --git a/cagebreak.c b/cagebreak.c index 63bb000..e9690a1 100644 --- a/cagebreak.c +++ b/cagebreak.c @@ -545,8 +545,10 @@ main(int argc, char *argv[]) { wl_display_destroy_clients(server.wl_display); end: +#if CG_HAS_FANALYZE #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wanalyzer-double-free" +#endif for(unsigned int i = 0; server.modes[i] != NULL; ++i) { free(server.modes[i]); } @@ -577,4 +579,6 @@ end: return ret; } +#if CG_HAS_FANALYZE #pragma GCC diagnostic pop +#endif diff --git a/config.h.in b/config.h.in index cf6bcbc..8495284 100644 --- a/config.h.in +++ b/config.h.in @@ -2,6 +2,7 @@ #define CG_CONFIG_H #mesondefine CG_HAS_XWAYLAND +#mesondefine CG_HAS_FANALYZE #mesondefine CG_VERSION diff --git a/idle_inhibit_v1.c b/idle_inhibit_v1.c index e73915d..17c0041 100644 --- a/idle_inhibit_v1.c +++ b/idle_inhibit_v1.c @@ -22,8 +22,10 @@ struct cg_idle_inhibitor_v1 { struct wl_listener destroy; }; +#if CG_HAS_FANALYZE #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wanalyzer-malloc-leak" +#endif static void idle_inhibit_v1_check_active(struct cg_server *server) { /* As of right now, this does not check whether the inhibitor @@ -31,7 +33,9 @@ idle_inhibit_v1_check_active(struct cg_server *server) { bool inhibited = !wl_list_empty(&server->inhibitors); wlr_idle_set_enabled(server->idle, NULL, !inhibited); } +#if CG_HAS_FANALYZE #pragma GCC diagnostic pop +#endif static void handle_destroy(struct wl_listener *listener, void *data) { diff --git a/meson.build b/meson.build index 40c09d7..b9ff4ed 100644 --- a/meson.build +++ b/meson.build @@ -100,6 +100,12 @@ else have_xwayland = false endif +if cc.get_id() == 'gcc' and cc.version().version_compare('>=10') + have_fanalyze=true +else + have_fanalyze=false +endif + if get_option('version_override') != '' version = '@0@'.format(get_option('version_override')) else @@ -108,6 +114,7 @@ endif conf_data = configuration_data() conf_data.set10('CG_HAS_XWAYLAND', have_xwayland) +conf_data.set10('CG_HAS_FANALYZE', have_fanalyze) conf_data.set_quoted('CG_VERSION', version) diff --git a/message.c b/message.c index bd6eed0..8ada1f8 100644 --- a/message.c +++ b/message.c @@ -95,8 +95,10 @@ create_message_texture(const char *string, const struct cg_output *output) { return texture; } +#if CG_HAS_FANALYZE #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wanalyzer-malloc-leak" +#endif void message_set_output(struct cg_output *output, const char *string, struct wlr_box *box, enum cg_message_align align) { @@ -172,7 +174,9 @@ message_printf(struct cg_output *output, const char *fmt, ...) { free(buffer); alarm(output->server->message_timeout); } +#if CG_HAS_FANALYZE #pragma GCC diagnostic pop +#endif void message_printf_pos(struct cg_output *output, struct wlr_box *position, diff --git a/output.c b/output.c index 388471d..4f40050 100644 --- a/output.c +++ b/output.c @@ -550,8 +550,10 @@ output_configure(struct cg_server *server, struct cg_output *output) { } } +#if CG_HAS_FANALYZE #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wanalyzer-malloc-leak" +#endif void handle_new_output(struct wl_listener *listener, void *data) { struct cg_server *server = wl_container_of(listener, server, new_output); @@ -629,7 +631,9 @@ handle_new_output(struct wl_listener *listener, void *data) { DEFAULT_XCURSOR, server->seat->cursor); wlr_cursor_warp(server->seat->cursor, NULL, 0, 0); } +#if CG_HAS_FANALYZE #pragma GCC diagnostic pop +#endif void output_set_window_title(struct cg_output *output, const char *title) { diff --git a/parse.c b/parse.c index 043f843..82cc0f2 100644 --- a/parse.c +++ b/parse.c @@ -325,12 +325,16 @@ parse_output_config(struct wl_list *config_list, char **saveptr) { goto error; } +#if CG_HAS_FANALYZE #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wanalyzer-malloc-leak" +#endif cfg->output_name = strdup(name); wl_list_insert(config_list, &cfg->link); return 0; +#if CG_HAS_FANALYZE #pragma GCC diagnostic pop +#endif error: free(cfg); diff --git a/workspace.c b/workspace.c index c7688ab..fcc7650 100644 --- a/workspace.c +++ b/workspace.c @@ -20,8 +20,10 @@ #include "view.h" #include "workspace.h" +#if CG_HAS_FANALYZE #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wanalyzer-malloc-leak" +#endif int full_screen_workspace_tiles(struct wlr_output_layout *layout, struct wlr_output *output, @@ -41,7 +43,9 @@ full_screen_workspace_tiles(struct wlr_output_layout *layout, workspace->focused_tile->view = NULL; return 0; } +#if CG_HAS_FANALYZE #pragma GCC diagnostic pop +#endif struct cg_workspace * full_screen_workspace(struct cg_output *output) { diff --git a/xdg_shell.c b/xdg_shell.c index 00af384..fd9ef3d 100644 --- a/xdg_shell.c +++ b/xdg_shell.c @@ -32,8 +32,10 @@ xdg_decoration_handle_destroy(struct wl_listener *listener, void *_data) { free(xdg_decoration); } +#if CG_HAS_FANALYZE #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wanalyzer-malloc-leak" +#endif static void xdg_decoration_handle_request_mode(struct wl_listener *listener, void *_data) { struct cg_xdg_decoration *xdg_decoration = @@ -44,7 +46,9 @@ xdg_decoration_handle_request_mode(struct wl_listener *listener, void *_data) { wlr_xdg_toplevel_decoration_v1_set_mode(xdg_decoration->wlr_decoration, mode); } +#if CG_HAS_FANALYZE #pragma GCC diagnostic pop +#endif static void xdg_popup_destroy(struct cg_view_child *child) {