From ebe4826d121cfb5ee21cdb966b04bceddd9ef007 Mon Sep 17 00:00:00 2001 From: project-repo Date: Fri, 30 Sep 2022 18:28:49 +0200 Subject: [PATCH] Fix bugs reported by scan-build --- cagebreak.c | 3 +++ input_manager.c | 1 + keybinding.c | 6 +++++- libinput.c | 50 ------------------------------------------------- parse.c | 3 +++ server.c | 3 ++- workspace.c | 1 + 7 files changed, 15 insertions(+), 52 deletions(-) diff --git a/cagebreak.c b/cagebreak.c index b5e1f9f..954649a 100644 --- a/cagebreak.c +++ b/cagebreak.c @@ -274,12 +274,14 @@ main(int argc, char *argv[]) { /* Wayland requires XDG_RUNTIME_DIR to be set. */ if(!getenv("XDG_RUNTIME_DIR")) { wlr_log(WLR_ERROR, "XDG_RUNTIME_DIR is not set in the environment"); + free(server.modes); return 1; } server.wl_display = wl_display_create(); if(!server.wl_display) { wlr_log(WLR_ERROR, "Cannot allocate a Wayland display"); + free(server.modes); return 1; } @@ -292,6 +294,7 @@ main(int argc, char *argv[]) { if(server.modes[0] == NULL || server.modes[1] == NULL || server.modes[2] == NULL) { wlr_log(WLR_ERROR, "Error allocating default modes"); + free(server.modes); return 1; } diff --git a/input_manager.c b/input_manager.c index 2157b43..0eeb253 100644 --- a/input_manager.c +++ b/input_manager.c @@ -64,6 +64,7 @@ input_device_get_identifier(struct wlr_input_device *device) { char *identifier = malloc(len); if(!identifier) { wlr_log(WLR_ERROR, "Unable to allocate unique input device name"); + free(name); return NULL; } diff --git a/keybinding.c b/keybinding.c index afe5609..c1a882f 100644 --- a/keybinding.c +++ b/keybinding.c @@ -1090,10 +1090,14 @@ keybinding_move_view_to_cycle_output(struct cg_server *server, bool reverse) { view_maximize(view, view->tile); seat_set_focus(server->seat, view); } + int id=-1; + if(view != NULL) { + id=view->id; + } ipc_send_event(server, "{\"event_name\":\"move_view_cycle_output\",\"view_id\":\"%" "d\",\"old_output\":\"%s\",\"new_output\":\"%s\"}", - view->id, old_outp->wlr_output->name, + id, old_outp->wlr_output->name, server->curr_output->wlr_output->name); } diff --git a/libinput.c b/libinput.c index f6dd957..6d9aff4 100644 --- a/libinput.c +++ b/libinput.c @@ -368,56 +368,6 @@ cg_input_configure_libinput_device(struct cg_input_device *input_device) { } } -void -cg_input_reset_libinput_device(struct cg_input_device *input_device) { - if(!wlr_input_device_is_libinput(input_device->wlr_device)) { - return; - } - - struct libinput_device *device = - wlr_libinput_get_device_handle(input_device->wlr_device); - wlr_log(WLR_DEBUG, "cg_input_reset_libinput_device(%s)", - input_device->identifier); - bool changed = false; - - changed |= set_send_events( - device, libinput_device_config_send_events_get_default_mode(device)); - changed |= - set_tap(device, libinput_device_config_tap_get_default_enabled(device)); - changed |= set_tap_button_map( - device, libinput_device_config_tap_get_default_button_map(device)); - changed |= set_tap_drag( - device, libinput_device_config_tap_get_default_drag_enabled(device)); - changed |= set_tap_drag_lock( - device, - libinput_device_config_tap_get_default_drag_lock_enabled(device)); - changed |= set_accel_speed( - device, libinput_device_config_accel_get_default_speed(device)); - changed |= set_accel_profile( - device, libinput_device_config_accel_get_default_profile(device)); - changed |= set_natural_scroll( - device, - libinput_device_config_scroll_get_default_natural_scroll_enabled( - device)); - changed |= set_left_handed( - device, libinput_device_config_left_handed_get_default(device)); - changed |= set_click_method( - device, libinput_device_config_click_get_default_method(device)); - changed |= set_middle_emulation( - device, - libinput_device_config_middle_emulation_get_default_enabled(device)); - changed |= set_scroll_method( - device, libinput_device_config_scroll_get_default_method(device)); - changed |= set_scroll_button( - device, libinput_device_config_scroll_get_default_button(device)); - changed |= - set_dwt(device, libinput_device_config_dwt_get_default_enabled(device)); - - float matrix[6]; - libinput_device_config_calibration_get_default_matrix(device, matrix); - changed |= set_calibration_matrix(device, matrix); -} - bool cg_libinput_device_is_builtin(struct cg_input_device *cg_device) { if(!wlr_input_device_is_libinput(cg_device->wlr_device)) { diff --git a/parse.c b/parse.c index 9cf68c2..8f5bddf 100644 --- a/parse.c +++ b/parse.c @@ -691,6 +691,9 @@ parse_message_config(char **saveptr, char **errstr) { return cfg; error: + if(cfg!=NULL) { + free(cfg); + } wlr_log(WLR_ERROR, "Message configuration must be of the form " "'configure_message '"); return NULL; diff --git a/server.c b/server.c index e554a3c..16253d8 100644 --- a/server.c +++ b/server.c @@ -58,14 +58,15 @@ server_show_info(struct cg_server *server) { struct cg_input_device *input; wl_list_for_each(input, &server->input->devices, link) { if(!input_str) { + free(output_str); return NULL; } input_str_tmp = input_str; if(strcmp(input->identifier, "") != 0) { input_str = malloc_vsprintf("%s\t * %s\n", input_str, input->identifier); + free(input_str_tmp); } - free(input_str_tmp); } char *ret = malloc_vsprintf("Outputs:\n%sInputs:\n%s", output_str, input_str); diff --git a/workspace.c b/workspace.c index 7bfe929..f35b4e4 100644 --- a/workspace.c +++ b/workspace.c @@ -59,6 +59,7 @@ full_screen_workspace(struct cg_output *output) { } struct wlr_scene_output *scene_output=wlr_scene_get_scene_output(output->server->scene,output->wlr_output); if(scene_output == NULL) { + free(workspace); return NULL; } workspace->server = output->server;