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