Merge pull request #362 from emersion/types-allocs-and-style

Fix remaining unchecked allocs in types and code style
This commit is contained in:
Tony Crisci 2017-10-31 07:06:14 -04:00 committed by GitHub
commit f7f02cc331
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
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 = struct wlr_seat_client *seat_client =
calloc(1, sizeof(struct wlr_seat_client)); calloc(1, sizeof(struct wlr_seat_client));
if (seat_client == NULL) {
wl_client_post_no_memory(client);
return;
}
seat_client->wl_resource = seat_client->wl_resource =
wl_resource_create(client, &wl_seat_interface, version, id); wl_resource_create(client, &wl_seat_interface, version, id);
seat_client->client = client; 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, static void surface_frame(struct wl_client *client,
struct wl_resource *resource, uint32_t callback) { struct wl_resource *resource, uint32_t callback) {
struct wlr_frame_callback *cb;
struct wlr_surface *surface = wl_resource_get_user_data(resource); 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) { if (cb == NULL) {
wl_resource_post_no_memory(resource); wl_resource_post_no_memory(resource);
return; return;
} }
cb->resource = wl_resource_create(client, cb->resource = wl_resource_create(client, &wl_callback_interface, 1,
&wl_callback_interface, 1, callback); callback);
if (cb->resource == NULL) { if (cb->resource == NULL) {
free(cb); free(cb);
wl_resource_post_no_memory(resource); 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() { 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->scale = 1;
state->transform = WL_OUTPUT_TRANSFORM_NORMAL; 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_surface *wlr_surface_create(struct wl_resource *res,
struct wlr_renderer *renderer) { struct wlr_renderer *renderer) {
struct wlr_surface *surface; struct wlr_surface *surface = calloc(1, sizeof(struct wlr_surface));
if (!(surface = calloc(1, sizeof(struct wlr_surface)))) { if (!surface) {
wl_resource_post_no_memory(res); wl_resource_post_no_memory(res);
return NULL; 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) { void wlr_tablet_tool_destroy(struct wlr_tablet_tool *tool) {
if (!tool) return; if (!tool) {
return;
}
if (tool->impl && tool->impl->destroy) { if (tool->impl && tool->impl->destroy) {
tool->impl->destroy(tool); tool->impl->destroy(tool);
} else { } 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) { if (grab->seat->pointer_state.grab == grab) {
wlr_seat_pointer_end_grab(grab->seat); wlr_seat_pointer_end_grab(grab->seat);
} }