Fix remaining unchecked allocs in types and code style

This commit is contained in:
emersion 2017-10-31 11:58:39 +01:00
parent 37b1e8bd25
commit 816d6890ee
No known key found for this signature in database
GPG Key ID: 0FDE7BE0E88F5E48
4 changed files with 18 additions and 9 deletions

View File

@ -206,6 +206,10 @@ static void wl_seat_bind(struct wl_client *client, void *_wlr_seat,
struct wlr_seat_client *seat_client =
calloc(1, sizeof(struct wlr_seat_client));
if (seat_client == NULL) {
wl_client_post_no_memory(client);
return;
}
seat_client->wl_resource =
wl_resource_create(client, &wl_seat_interface, version, id);
seat_client->client = client;

View File

@ -78,17 +78,17 @@ static void destroy_frame_callback(struct wl_resource *resource) {
static void surface_frame(struct wl_client *client,
struct wl_resource *resource, uint32_t callback) {
struct wlr_frame_callback *cb;
struct wlr_surface *surface = wl_resource_get_user_data(resource);
cb = malloc(sizeof(struct wlr_frame_callback));
struct wlr_frame_callback *cb =
calloc(1, sizeof(struct wlr_frame_callback));
if (cb == NULL) {
wl_resource_post_no_memory(resource);
return;
}
cb->resource = wl_resource_create(client,
&wl_callback_interface, 1, callback);
cb->resource = wl_resource_create(client, &wl_callback_interface, 1,
callback);
if (cb->resource == NULL) {
free(cb);
wl_resource_post_no_memory(resource);
@ -555,7 +555,11 @@ const struct wl_surface_interface surface_interface = {
};
static struct wlr_surface_state *wlr_surface_state_create() {
struct wlr_surface_state *state = calloc(1, sizeof(struct wlr_surface_state));
struct wlr_surface_state *state =
calloc(1, sizeof(struct wlr_surface_state));
if (state == NULL) {
return NULL;
}
state->scale = 1;
state->transform = WL_OUTPUT_TRANSFORM_NORMAL;
@ -619,8 +623,8 @@ static void destroy_surface(struct wl_resource *resource) {
struct wlr_surface *wlr_surface_create(struct wl_resource *res,
struct wlr_renderer *renderer) {
struct wlr_surface *surface;
if (!(surface = calloc(1, sizeof(struct wlr_surface)))) {
struct wlr_surface *surface = calloc(1, sizeof(struct wlr_surface));
if (!surface) {
wl_resource_post_no_memory(res);
return NULL;
}

View File

@ -14,7 +14,9 @@ void wlr_tablet_tool_init(struct wlr_tablet_tool *tool,
}
void wlr_tablet_tool_destroy(struct wlr_tablet_tool *tool) {
if (!tool) return;
if (!tool) {
return;
}
if (tool->impl && tool->impl->destroy) {
tool->impl->destroy(tool);
} else {

View File

@ -22,7 +22,6 @@ static void shell_pointer_grab_end(struct wlr_seat_pointer_grab *grab) {
}
}
if (grab->seat->pointer_state.grab == grab) {
wlr_seat_pointer_end_grab(grab->seat);
}