[PATCH 3/5] Weston: use unsigned int, iterators

Andreas Ericsson ae at op5.se
Sat Mar 31 06:56:53 PDT 2012


Why does this matter? I'm assuming it's because they're matched agains
unsigned ints in the loops, but it would be good to say so in the
commit message so people aren't left guessing.

Useless changes are confusing for people who need to do actual changes
to the same code later, so keep them to a minimum, please.

On 03/31/2012 12:53 PM, Martin Minarik wrote:
> diff --git a/clients/dnd.c b/clients/dnd.c
> index 66ba2ce..a99fbec 100644
> --- a/clients/dnd.c
> +++ b/clients/dnd.c
> @@ -167,7 +167,7 @@ dnd_redraw_handler(struct widget *widget, void *data)
>   	struct rectangle allocation;
>   	cairo_t *cr;
>   	cairo_surface_t *surface;
> -	int i;
> +	unsigned int i;
> 
>   	surface = window_get_surface(dnd->window);
>   	cr = cairo_create(surface);
> @@ -205,7 +205,7 @@ keyboard_focus_handler(struct window *window,
>   static int
>   dnd_add_item(struct dnd *dnd, struct item *item)
>   {
> -	int i;
> +	unsigned int i;
> 
>   	for (i = 0; i<  ARRAY_LENGTH(dnd->items); i++) {
>   		if (dnd->items[i] == 0) {
> @@ -221,7 +221,7 @@ dnd_get_item(struct dnd *dnd, int32_t x, int32_t y)
>   {
>   	struct item *item;
>   	struct rectangle allocation;
> -	int i;
> +	unsigned int i;
> 
>   	widget_get_allocation(dnd->widget,&allocation);
> 
> @@ -266,7 +266,7 @@ data_source_send(void *data, struct wl_data_source
> *source,
>   {
>   	struct dnd_flower_message dnd_flower_message;
>   	struct dnd_drag *dnd_drag = data;
> -
> +
>   	dnd_flower_message.seed = dnd_drag->item->seed;
>   	dnd_flower_message.x_offset = dnd_drag->x_offset;
>   	dnd_flower_message.y_offset = dnd_drag->y_offset;
> @@ -285,7 +285,7 @@ data_source_cancelled(void *data, struct
> wl_data_source *source)
>   	 * up the drag object created and the local state. */
> 
>   	wl_data_source_destroy(dnd_drag->data_source);
> -
> +
>   	/* Destroy the item that has been dragged out */
>   	cairo_surface_destroy(dnd_drag->item->surface);
>   	free(dnd_drag->item);
> @@ -366,7 +366,7 @@ dnd_button_handler(struct widget *widget,
>   	struct display *display;
>   	struct wl_compositor *compositor;
>   	struct wl_buffer *buffer;
> -	int i;
> +	unsigned int i;
> 
>   	widget_get_allocation(dnd->widget,&allocation);
>   	input_get_position(input,&x,&y);
> @@ -513,7 +513,8 @@ static struct dnd *
>   dnd_create(struct display *display)
>   {
>   	struct dnd *dnd;
> -	int i, x, y;
> +	unsigned int i;
> +	int x, y;
>   	int32_t width, height;
> 
>   	dnd = malloc(sizeof *dnd);
> diff --git a/src/compositor-drm.c b/src/compositor-drm.c
> index 4305cd5..f43f652 100644
> --- a/src/compositor-drm.c
> +++ b/src/compositor-drm.c
> @@ -81,7 +81,7 @@ struct drm_output {
>   	uint32_t fb_id[2];
>   	EGLImageKHR image[2];
>   	struct gbm_bo *bo[2];
> -	uint32_t current;
> +	uint32_t current;
> 
>   	uint32_t fs_surf_fb_id;
>   	uint32_t pending_fs_surf_fb_id;
> @@ -355,7 +355,7 @@ page_flip_handler(int fd, unsigned int frame,
>   static int
>   drm_surface_format_supported(struct drm_sprite *s, uint32_t format)
>   {
> -	int i;
> +	unsigned int i;
> 
>   	for (i = 0; i<  s->count_formats; i++)
>   		if (s->formats[i] == format)
> @@ -1189,7 +1190,7 @@ create_sprites(struct drm_compositor *ec)
>   	struct drm_sprite *sprite;
>   	drmModePlaneRes *plane_res;
>   	drmModePlane *plane;
> -	int i;
> +	unsigned int i;
> 
>   	plane_res = drmModeGetPlaneResources(ec->drm.fd);
>   	if (!plane_res) {
> diff --git a/src/compositor-x11.c b/src/compositor-x11.c
> index 119c456..3eea5b4 100644
> --- a/src/compositor-x11.c
> +++ b/src/compositor-x11.c
> @@ -545,7 +545,8 @@ x11_compositor_handle_event(int fd, uint32_t mask,
> void *data)
>   	xcb_focus_in_event_t *focus_in;
>   	xcb_atom_t atom;
>   	uint32_t *k;
> -	int i, set;
> +	unsigned int i;
> +	int set;
> 
>   	prev = NULL;
>   	while (x11_compositor_next_event(c,&event, mask)) {
> @@ -731,7 +732,7 @@ x11_compositor_get_resources(struct x11_compositor *c)
>   	xcb_intern_atom_reply_t *reply;
>   	xcb_pixmap_t pixmap;
>   	xcb_gc_t gc;
> -	int i;
> +	unsigned int i;
>   	uint8_t data[] = { 0, 0, 0, 0 };
> 
>   	for (i = 0; i<  ARRAY_LENGTH(atoms); i++)
> diff --git a/src/shell.c b/src/shell.c
> index ea3d0bf..8a3db87 100644
> --- a/src/shell.c
> +++ b/src/shell.c
> @@ -1165,7 +1165,7 @@ static void
>   surface_opacity_binding(struct wl_input_device *device, uint32_t time,
>   	       uint32_t key, uint32_t button, uint32_t axis, int32_t value, void
> *data)
>   {
> -	int step = 15;
> +	unsigned int step = 15;
>   	struct shell_surface *shsurf;
>   	struct weston_surface *surface =
>   		(struct weston_surface *) device->pointer_focus;
> diff --git a/src/xserver-launcher.c b/src/xserver-launcher.c
> index 7fc79d8..ed0194e 100644
> --- a/src/xserver-launcher.c
> +++ b/src/xserver-launcher.c
> @@ -155,7 +155,8 @@ dump_property(struct weston_wm *wm, xcb_atom_t property,
>   	int32_t *incr_value;
>   	const char *text_value, *name;
>   	xcb_atom_t *atom_value;
> -	int i, width, len;
> +	unsigned int i;
> +	int width, len;
> 
>   	width = fprintf(stderr, "  %s: ", get_atom_name(wm->conn, property));
>   	if (reply == NULL) {
> @@ -295,7 +296,7 @@ weston_wm_get_selection_targets(struct weston_wm *wm)
>   	xcb_get_property_reply_t *reply;
>   	xcb_atom_t *value;
>   	char **p;
> -	int i;
> +	unsigned int i;
> 
>   	cookie = xcb_get_property(wm->conn,
>   				  1, /* delete */
> @@ -609,7 +610,7 @@ weston_wm_handle_map_notify(struct weston_wm *wm,
> xcb_generic_event_t *event)
>   	void *p;
>   	uint32_t *xid;
>   	xcb_atom_t *atom;
> -	int i;
> +	unsigned int i;
> 
>   	fprintf(stderr, "XCB_MAP_NOTIFY (window %d)\n", map_notify->window);
> 
> @@ -668,7 +669,7 @@ weston_wm_handle_map_notify(struct weston_wm *wm,
> xcb_generic_event_t *event)
>   	weston_wm_activate(wm, window, XCB_TIME_CURRENT_TIME);
>   }
> 
> -static const int incr_chunk_size = 64 * 1024;
> +static const unsigned int incr_chunk_size = 64 * 1024;
> 
>   static void
>   weston_wm_send_selection_notify(struct weston_wm *wm, xcb_atom_t property)
> @@ -1174,7 +1175,7 @@ wxs_wm_get_resources(struct weston_wm *wm)
>   	xcb_xfixes_query_version_reply_t *xfixes_reply;
>   	xcb_intern_atom_cookie_t cookies[ARRAY_LENGTH(atoms)];
>   	xcb_intern_atom_reply_t *reply;
> -	int i;
> +	unsigned int i;
> 
>   	xcb_prefetch_extension_data (wm->conn,&xcb_xfixes_id);
> 
> 
> _______________________________________________
> wayland-devel mailing list
> wayland-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/wayland-devel


-- 
Andreas Ericsson                   andreas.ericsson at op5.se
OP5 AB                             www.op5.se
Tel: +46 8-230225                  Fax: +46 8-230231

Considering the successes of the wars on alcohol, poverty, drugs and
terror, I think we should give some serious thought to declaring war
on peace.


More information about the wayland-devel mailing list