Fix bugs reported by scan-build

This commit is contained in:
project-repo 2022-09-30 18:28:49 +02:00
commit ebe4826d12
7 changed files with 15 additions and 52 deletions

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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);
}

View file

@ -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)) {

View file

@ -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 <setting> <value>'");
return NULL;

View file

@ -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);

View file

@ -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;