commit 03c7432

Michael Forney  ·  2017-06-05 07:48:02 +0000 UTC
parent 2fdd227
sizeof style
21 files changed,  +49, -49
+2, -2
 1@@ -191,7 +191,7 @@ new_screen(struct swc_screen *swc)
 2 {
 3 	struct screen *screen;
 4 
 5-	screen = malloc(sizeof *screen);
 6+	screen = malloc(sizeof(*screen));
 7 
 8 	if (!screen)
 9 		return;
10@@ -208,7 +208,7 @@ new_window(struct swc_window *swc)
11 {
12 	struct window *window;
13 
14-	window = malloc(sizeof *window);
15+	window = malloc(sizeof(*window));
16 
17 	if (!window)
18 		return;
+4, -4
 1@@ -157,7 +157,7 @@ activate(void)
 2 	struct swc_launch_event event = {.type = SWC_LAUNCH_EVENT_ACTIVATE };
 3 
 4 	start_devices();
 5-	send(launcher.socket, &event, sizeof event, 0);
 6+	send(launcher.socket, &event, sizeof(event), 0);
 7 	launcher.active = true;
 8 }
 9 
10@@ -166,7 +166,7 @@ deactivate(void)
11 {
12 	struct swc_launch_event event = {.type = SWC_LAUNCH_EVENT_DEACTIVATE };
13 
14-	send(launcher.socket, &event, sizeof event, 0);
15+	send(launcher.socket, &event, sizeof(event), 0);
16 	stop_devices(true);
17 	launcher.active = false;
18 }
19@@ -213,7 +213,7 @@ handle_socket_data(int socket)
20 	struct stat st;
21 	ssize_t size;
22 
23-	size = receive_fd(socket, &fd, buffer, sizeof buffer);
24+	size = receive_fd(socket, &fd, buffer, sizeof(buffer));
25 
26 	if (size == -1 || size == 0)
27 		return;
28@@ -290,7 +290,7 @@ fail:
29 	response.success = false;
30 	fd = -1;
31 done:
32-	send_fd(socket, fd, &response, sizeof response);
33+	send_fd(socket, fd, &response, sizeof(response));
34 }
35 
36 static void
+1, -1
1@@ -173,7 +173,7 @@ swc_add_binding(enum swc_binding_type type, uint32_t modifiers, uint32_t value,
2 		return -EINVAL;
3 	}
4 
5-	if (!(binding = wl_array_add(bindings, sizeof *binding)))
6+	if (!(binding = wl_array_add(bindings, sizeof(*binding))))
7 		return -ENOMEM;
8 
9 	binding->value = value;
+2, -2
 1@@ -149,7 +149,7 @@ target_new(struct screen *screen)
 2 	struct target *target;
 3 	struct swc_rectangle *geom = &screen->base.geometry;
 4 
 5-	if (!(target = malloc(sizeof *target)))
 6+	if (!(target = malloc(sizeof(*target))))
 7 		goto error0;
 8 
 9 	target->surface = wld_create_surface(swc.drm->context, geom->width, geom->height, WLD_FORMAT_XRGB8888, WLD_DRM_FLAG_SCANOUT);
10@@ -449,7 +449,7 @@ compositor_create_view(struct surface *surface)
11 {
12 	struct compositor_view *view;
13 
14-	view = malloc(sizeof *view);
15+	view = malloc(sizeof(*view));
16 
17 	if (!view)
18 		return NULL;
+2, -2
 1@@ -78,7 +78,7 @@ source_offer(struct wl_client *client, struct wl_resource *source, const char *m
 2 	struct data *data = wl_resource_get_user_data(source);
 3 	char **destination;
 4 
 5-	destination = wl_array_add(&data->mime_types, sizeof *destination);
 6+	destination = wl_array_add(&data->mime_types, sizeof(*destination));
 7 	*destination = strdup(mime_type);
 8 }
 9 
10@@ -125,7 +125,7 @@ data_new(void)
11 {
12 	struct data *data;
13 
14-	data = malloc(sizeof *data);
15+	data = malloc(sizeof(*data));
16 
17 	if (!data)
18 		return NULL;
+2, -2
 1@@ -254,7 +254,7 @@ drm_initialize(void)
 2 {
 3 	struct stat master, render;
 4 
 5-	if (!find_primary_drm_device(drm.path, sizeof drm.path)) {
 6+	if (!find_primary_drm_device(drm.path, sizeof(drm.path))) {
 7 		ERROR("Could not find DRM device\n");
 8 		goto error0;
 9 	}
10@@ -272,7 +272,7 @@ drm_initialize(void)
11 		goto error1;
12 	}
13 
14-	if (snprintf(drm.path, sizeof drm.path, "/dev/dri/renderD%d", minor(master.st_rdev) + 0x80) >= sizeof drm.path) {
15+	if (snprintf(drm.path, sizeof(drm.path), "/dev/dri/renderD%d", minor(master.st_rdev) + 0x80) >= sizeof(drm.path)) {
16 		ERROR("Render node path is too long");
17 		goto error1;
18 	}
+5, -5
 1@@ -74,14 +74,14 @@ client_handle_key(struct keyboard *keyboard, uint32_t time, struct key *key, uin
 2 	uint32_t *value;
 3 
 4 	if (state == WL_KEYBOARD_KEY_STATE_PRESSED) {
 5-		if (!(value = wl_array_add(&keyboard->client_keys, sizeof *value)))
 6+		if (!(value = wl_array_add(&keyboard->client_keys, sizeof(*value))))
 7 			return false;
 8 
 9 		*value = key->press.value;
10 	} else {
11 		wl_array_for_each (value, &keyboard->client_keys) {
12 			if (*value == key->press.value) {
13-				array_remove(&keyboard->client_keys, value, sizeof *value);
14+				array_remove(&keyboard->client_keys, value, sizeof(*value));
15 				break;
16 			}
17 		}
18@@ -120,7 +120,7 @@ update_keymap(struct xkb *xkb)
19 	if (!(keymap_directory = getenv("XDG_RUNTIME_DIR")))
20 		keymap_directory = "/tmp";
21 
22-	char keymap_path[strlen(keymap_directory) + 1 + sizeof keymap_file_template];
23+	char keymap_path[strlen(keymap_directory) + 1 + sizeof(keymap_file_template)];
24 
25 	xkb->indices.ctrl = xkb_keymap_mod_get_index(xkb->keymap.map, XKB_MOD_NAME_CTRL);
26 	xkb->indices.alt = xkb_keymap_mod_get_index(xkb->keymap.map, XKB_MOD_NAME_ALT);
27@@ -342,7 +342,7 @@ keyboard_handle_key(struct keyboard *keyboard, uint32_t time, uint32_t value, ui
28 				key->handler->key(keyboard, time, key, state);
29 			}
30 
31-			array_remove(&keyboard->keys, key, sizeof *key);
32+			array_remove(&keyboard->keys, key, sizeof(*key));
33 			goto update_xkb_state;
34 		}
35 	}
36@@ -351,7 +351,7 @@ keyboard_handle_key(struct keyboard *keyboard, uint32_t time, uint32_t value, ui
37 	if (state == WL_KEYBOARD_KEY_STATE_RELEASED)
38 		return;
39 
40-	if (!(key = wl_array_add(&keyboard->keys, sizeof *key)))
41+	if (!(key = wl_array_add(&keyboard->keys, sizeof(*key))))
42 		goto update_xkb_state;
43 
44 	key->press.value = value;
+4, -4
 1@@ -59,7 +59,7 @@ handle_data(int fd, uint32_t mask, void *data)
 2 {
 3 	struct swc_launch_event event;
 4 
 5-	if (receive_fd(fd, NULL, &event, sizeof event) != -1)
 6+	if (receive_fd(fd, NULL, &event, sizeof(event)) != -1)
 7 		handle_event(&event);
 8 	return 1;
 9 }
10@@ -102,7 +102,7 @@ send_request(struct swc_launch_request *request, size_t size, struct swc_launch_
11 	if (send_fd(launch.socket, out_fd, request, size) == -1)
12 		return false;
13 
14-	while (receive_fd(launch.socket, in_fd, event, sizeof *event) != -1) {
15+	while (receive_fd(launch.socket, in_fd, event, sizeof(*event)) != -1) {
16 		if (event->type == SWC_LAUNCH_EVENT_RESPONSE && event->serial == request->serial)
17 			return true;
18 		handle_event(event);
19@@ -124,7 +124,7 @@ launch_open_device(const char *path, int flags)
20 	request->flags = flags;
21 	strcpy(request->path, path);
22 
23-	if (!send_request(request, sizeof buffer, &response, -1, &fd))
24+	if (!send_request(request, sizeof(buffer), &response, -1, &fd))
25 		return -1;
26 
27 	return fd;
28@@ -139,7 +139,7 @@ launch_activate_vt(unsigned vt)
29 	request.type = SWC_LAUNCH_REQUEST_ACTIVATE_VT;
30 	request.vt = vt;
31 
32-	if (!send_request(&request, sizeof request, &response, -1, NULL))
33+	if (!send_request(&request, sizeof(request), &response, -1, NULL))
34 		return false;
35 
36 	return response.success;
+2, -2
 1@@ -58,7 +58,7 @@ output_new(drmModeConnectorPtr connector)
 2 	struct mode *modes;
 3 	uint32_t i;
 4 
 5-	if (!(output = malloc(sizeof *output))) {
 6+	if (!(output = malloc(sizeof(*output)))) {
 7 		ERROR("Failed to allocated output\n");
 8 		goto error0;
 9 	}
10@@ -84,7 +84,7 @@ output_new(drmModeConnectorPtr connector)
11 	if (connector->count_modes == 0)
12 		goto error2;
13 
14-	modes = wl_array_add(&output->modes, connector->count_modes * sizeof *modes);
15+	modes = wl_array_add(&output->modes, connector->count_modes * sizeof(*modes));
16 	if (!modes)
17 		goto error2;
18 
+1, -1
1@@ -223,7 +223,7 @@ panel_new(struct wl_client *client, uint32_t version, uint32_t id, struct surfac
2 {
3 	struct panel *panel;
4 
5-	panel = malloc(sizeof *panel);
6+	panel = malloc(sizeof(*panel));
7 
8 	if (!panel)
9 		goto error0;
+2, -2
 1@@ -378,12 +378,12 @@ pointer_handle_button(struct pointer *pointer, uint32_t time, uint32_t value, ui
 2 					button->handler->button(button->handler, time, button, state);
 3 				}
 4 
 5-				array_remove(&pointer->buttons, button, sizeof *button);
 6+				array_remove(&pointer->buttons, button, sizeof(*button));
 7 				break;
 8 			}
 9 		}
10 	} else {
11-		button = wl_array_add(&pointer->buttons, sizeof *button);
12+		button = wl_array_add(&pointer->buttons, sizeof(*button));
13 
14 		if (!button)
15 			return;
+3, -3
 1@@ -98,7 +98,7 @@ attach(struct view *view, struct wld_buffer *buffer)
 2 			return -EINVAL;
 3 		}
 4 
 5-		if (!(framebuffer = malloc(sizeof *framebuffer)))
 6+		if (!(framebuffer = malloc(sizeof(*framebuffer))))
 7 			return -ENOMEM;
 8 
 9 		ret = drmModeAddFB(swc.drm->fd, buffer->width, buffer->height, 24, 32, buffer->pitch, object.u32, &framebuffer->id);
10@@ -182,14 +182,14 @@ primary_plane_initialize(struct primary_plane *plane, uint32_t crtc, struct mode
11 	}
12 
13 	wl_array_init(&plane->connectors);
14-	plane_connectors = wl_array_add(&plane->connectors, num_connectors * sizeof connectors[0]);
15+	plane_connectors = wl_array_add(&plane->connectors, num_connectors * sizeof(connectors[0]));
16 
17 	if (!plane_connectors) {
18 		ERROR("Failed to allocate connector array\n");
19 		goto error1;
20 	}
21 
22-	memcpy(plane_connectors, connectors, num_connectors * sizeof connectors[0]);
23+	memcpy(plane_connectors, connectors, num_connectors * sizeof(connectors[0]));
24 	plane->crtc = crtc;
25 	plane->need_modeset = true;
26 	view_initialize(&plane->view, &view_impl);
+1, -1
1@@ -46,7 +46,7 @@ region_new(struct wl_client *client, uint32_t version, uint32_t id)
2 {
3 	struct region *region;
4 
5-	region = malloc(sizeof *region);
6+	region = malloc(sizeof(*region));
7 
8 	if (!region)
9 		return NULL;
+1, -1
1@@ -107,7 +107,7 @@ screen_new(uint32_t crtc, struct output *output)
2 	wl_list_for_each (screen, &swc.screens, link)
3 		x = MAX(x, screen->base.geometry.x + screen->base.geometry.width);
4 
5-	if (!(screen = malloc(sizeof *screen)))
6+	if (!(screen = malloc(sizeof(*screen))))
7 		goto error0;
8 
9 	screen->global = wl_global_create(swc.display, &swc_screen_interface, 1, screen, &bind_screen);
+1, -1
1@@ -217,7 +217,7 @@ shell_surface_new(struct wl_client *client, uint32_t version, uint32_t id, struc
2 {
3 	struct shell_surface *shell_surface;
4 
5-	shell_surface = malloc(sizeof *shell_surface);
6+	shell_surface = malloc(sizeof(*shell_surface));
7 
8 	if (!shell_surface)
9 		goto error0;
+2, -2
 1@@ -119,7 +119,7 @@ create_buffer(struct wl_client *client, struct wl_resource *resource,
 2 	if (!buffer_resource)
 3 		goto error1;
 4 
 5-	if (!(reference = malloc(sizeof *reference)))
 6+	if (!(reference = malloc(sizeof(*reference))))
 7 		goto error2;
 8 
 9 	reference->pool = pool;
10@@ -171,7 +171,7 @@ create_pool(struct wl_client *client, struct wl_resource *resource, uint32_t id,
11 {
12 	struct pool *pool;
13 
14-	if (!(pool = malloc(sizeof *pool))) {
15+	if (!(pool = malloc(sizeof(*pool)))) {
16 		wl_resource_post_no_memory(resource);
17 		goto error0;
18 	}
+1, -1
1@@ -83,7 +83,7 @@ subsurface_new(struct wl_client *client, uint32_t version, uint32_t id)
2 {
3 	struct subsurface *subsurface;
4 
5-	if (!(subsurface = malloc(sizeof *subsurface)))
6+	if (!(subsurface = malloc(sizeof(*subsurface))))
7 		goto error0;
8 
9 	subsurface->resource = wl_resource_create(client, &wl_subsurface_interface, version, id);
+1, -1
1@@ -317,7 +317,7 @@ surface_new(struct wl_client *client, uint32_t version, uint32_t id)
2 {
3 	struct surface *surface;
4 
5-	if (!(surface = malloc(sizeof *surface)))
6+	if (!(surface = malloc(sizeof(*surface))))
7 		return NULL;
8 
9 	/* Initialize the surface. */
+1, -1
1@@ -73,7 +73,7 @@ xdg_popup_new(struct wl_client *client, uint32_t version,
2 	if (!parent)
3 		goto error0;
4 
5-	popup = malloc(sizeof *popup);
6+	popup = malloc(sizeof(*popup));
7 
8 	if (!popup)
9 		goto error0;
+3, -3
 1@@ -51,7 +51,7 @@ add_state(struct xdg_surface *xdg_surface, uint32_t state)
 2 			return false;
 3 	}
 4 
 5-	if (!(current_state = wl_array_add(&xdg_surface->states, sizeof state))) {
 6+	if (!(current_state = wl_array_add(&xdg_surface->states, sizeof(state)))) {
 7 		WARNING("xdg_surface: Failed to allocate new state\n");
 8 		return false;
 9 	}
10@@ -67,7 +67,7 @@ remove_state(struct xdg_surface *xdg_surface, uint32_t state)
11 
12 	wl_array_for_each (current_state, &xdg_surface->states) {
13 		if (*current_state == state) {
14-			array_remove(&xdg_surface->states, current_state, sizeof state);
15+			array_remove(&xdg_surface->states, current_state, sizeof(state));
16 			return true;
17 		}
18 	}
19@@ -308,7 +308,7 @@ xdg_surface_new(struct wl_client *client, uint32_t version, uint32_t id, struct
20 {
21 	struct xdg_surface *xdg_surface;
22 
23-	xdg_surface = malloc(sizeof *xdg_surface);
24+	xdg_surface = malloc(sizeof(*xdg_surface));
25 
26 	if (!xdg_surface)
27 		goto error0;
+8, -8
 1@@ -108,7 +108,7 @@ retry0:
 2 	}
 3 
 4 begin:
 5-	snprintf(lock_name, sizeof lock_name, LOCK_FMT, xserver.display);
 6+	snprintf(lock_name, sizeof(lock_name), LOCK_FMT, xserver.display);
 7 	lock_fd = open(lock_name, O_WRONLY | O_CREAT | O_EXCL | O_CLOEXEC, 0444);
 8 
 9 	if (lock_fd == -1) {
10@@ -119,7 +119,7 @@ begin:
11 		if ((lock_fd = open(lock_name, O_RDONLY)) == -1)
12 			goto retry0;
13 
14-		if (read(lock_fd, pid, sizeof pid - 1) != sizeof pid - 1)
15+		if (read(lock_fd, pid, sizeof(pid) - 1) != sizeof(pid) - 1)
16 			goto retry0;
17 
18 		owner = strtol(pid, &end, 10);
19@@ -136,8 +136,8 @@ begin:
20 		goto begin;
21 	}
22 
23-	snprintf(pid, sizeof pid, "%10d\n", getpid());
24-	if (write(lock_fd, pid, sizeof pid - 1) != sizeof pid - 1) {
25+	snprintf(pid, sizeof(pid), "%10d\n", getpid());
26+	if (write(lock_fd, pid, sizeof(pid) - 1) != sizeof(pid) - 1) {
27 		ERROR("Failed to write PID file\n");
28 		unlink(lock_name);
29 		close(lock_fd);
30@@ -158,7 +158,7 @@ begin:
31 	if ((xserver.unix_fd = open_socket(&addr)) < 0)
32 		goto retry2;
33 
34-	snprintf(xserver.display_name, sizeof xserver.display_name, ":%d", xserver.display);
35+	snprintf(xserver.display_name, sizeof(xserver.display_name), ":%d", xserver.display);
36 	setenv("DISPLAY", xserver.display_name, true);
37 
38 	return true;
39@@ -172,9 +172,9 @@ close_display(void)
40 	close(xserver.abstract_fd);
41 	close(xserver.unix_fd);
42 
43-	snprintf(path, sizeof path, SOCKET_FMT, xserver.display);
44+	snprintf(path, sizeof(path), SOCKET_FMT, xserver.display);
45 	unlink(path);
46-	snprintf(path, sizeof path, LOCK_FMT, xserver.display);
47+	snprintf(path, sizeof(path), LOCK_FMT, xserver.display);
48 	unlink(path);
49 
50 	unsetenv("DISPLAY");
51@@ -255,7 +255,7 @@ xserver_initialize(void)
52 				goto fail;
53 			}
54 
55-			if (snprintf(strings[index], sizeof strings[index], "%d", fds[index]) >= sizeof strings[index]) {
56+			if (snprintf(strings[index], sizeof(strings[index]), "%d", fds[index]) >= sizeof(strings[index])) {
57 				ERROR("FD is too large\n");
58 				goto fail;
59 			}