commit 3816fe4ebb1050ffe8195174d3810573ebfc7dde Author: Adam Richter Date: Sat May 4 16:06:17 2019 -0700 Separate each "assert(a && b)" statement into "assert(a)" and "assert(b)". This should provide more precise diagnostics when an assertion failure is detected, which can sometimes be rare and difficult to generate. diff --git a/src/intel_device.c b/src/intel_device.c index 21955073..ca028e2c 100644 --- a/src/intel_device.c +++ b/src/intel_device.c @@ -669,7 +669,8 @@ int __intel_peek_fd(ScrnInfoPtr scrn) struct intel_device *dev; dev = intel_device(scrn); - assert(dev && dev->fd != -1); + assert(dev); + assert(dev->fd != -1); return dev->fd; } @@ -678,7 +679,8 @@ int intel_has_render_node(struct intel_device *dev) { struct stat st; - assert(dev && dev->fd != -1); + assert(dev); + assert(dev->fd != -1); return is_render_node(dev->fd, &st); } @@ -730,13 +732,15 @@ struct intel_device *intel_get_device(ScrnInfoPtr scrn, int *fd) const char *intel_get_master_name(struct intel_device *dev) { - assert(dev && dev->master_node); + assert(dev); + assert(dev->master_node); return dev->master_node; } const char *intel_get_client_name(struct intel_device *dev) { - assert(dev && dev->render_node); + assert(dev); + assert(dev->render_node); return dev->render_node; } @@ -755,7 +759,8 @@ int intel_get_client_fd(struct intel_device *dev) { int fd = -1; - assert(dev && dev->fd != -1); + assert(dev); + assert(dev->fd != -1); assert(dev->render_node); #ifdef O_CLOEXEC @@ -778,7 +783,8 @@ int intel_get_client_fd(struct intel_device *dev) int intel_get_device_id(struct intel_device *dev) { - assert(dev && dev->fd != -1); + assert(dev); + assert(dev->fd != -1); return dev->device_id; } @@ -786,7 +792,8 @@ int intel_get_master(struct intel_device *dev) { int ret; - assert(dev && dev->fd != -1); + assert(dev); + assert(dev->fd != -1); ret = 0; if (dev->master_count++ == 0) { @@ -808,7 +815,8 @@ int intel_put_master(struct intel_device *dev) { int ret; - assert(dev && dev->fd != -1); + assert(dev); + assert(dev->fd != -1); ret = 0; assert(dev->master_count); @@ -823,7 +831,8 @@ int intel_put_master(struct intel_device *dev) void intel_put_device(struct intel_device *dev) { - assert(dev && dev->fd != -1); + assert(dev); + assert(dev->fd != -1); assert(dev->open_count); if (--dev->open_count) diff --git a/src/sna/blt.c b/src/sna/blt.c index cb90437a..2c2f89a0 100644 --- a/src/sna/blt.c +++ b/src/sna/blt.c @@ -647,7 +647,8 @@ memcpy_blt(const void *src, void *dst, int bpp, assert(src); assert(dst); - assert(width && height); + assert(width); + assert(height); assert(bpp >= 8); assert(width*bpp <= 8*src_stride); assert(width*bpp <= 8*dst_stride); @@ -1372,7 +1373,8 @@ memcpy_xor(const void *src, void *dst, int bpp, uint8_t *dst_bytes; int i, w; - assert(width && height); + assert(width); + assert(height); assert(bpp >= 8); assert(width*bpp <= 8*src_stride); assert(width*bpp <= 8*dst_stride); diff --git a/src/sna/brw/brw_eu_emit.c b/src/sna/brw/brw_eu_emit.c index 154f939a..8c09b7df 100644 --- a/src/sna/brw/brw_eu_emit.c +++ b/src/sna/brw/brw_eu_emit.c @@ -181,10 +181,14 @@ validate_reg(struct brw_instruction *insn, struct brw_reg reg) reg.nr == BRW_ARF_NULL) return; - assert(reg.hstride >= 0 && reg.hstride < ARRAY_SIZE(hstride_for_reg)); - assert(reg.vstride >= 0 && reg.vstride < ARRAY_SIZE(vstride_for_reg)); - assert(reg.width >= 0 && reg.width < ARRAY_SIZE(width_for_reg)); - assert(insn->header.execution_size >= 0 && insn->header.execution_size < ARRAY_SIZE(execsize_for_reg)); + assert(reg.hstride >= 0); + assert(reg.hstride < ARRAY_SIZE(hstride_for_reg)); + assert(reg.vstride >= 0); + assert(reg.vstride < ARRAY_SIZE(vstride_for_reg)); + assert(reg.width >= 0); + assert(reg.width < ARRAY_SIZE(width_for_reg)); + assert(insn->header.execution_size >= 0); + assert(insn->header.execution_size < ARRAY_SIZE(execsize_for_reg)); hstride = hstride_for_reg[reg.hstride]; @@ -787,7 +791,8 @@ convert_IF_ELSE_to_ADD(struct brw_compile *p, struct brw_instruction *next_inst = &p->store[p->nr_insn]; assert(p->single_program_flow); - assert(if_inst != NULL && if_inst->header.opcode == BRW_OPCODE_IF); + assert(if_inst != NULL); + assert(if_inst->header.opcode == BRW_OPCODE_IF); assert(else_inst == NULL || else_inst->header.opcode == BRW_OPCODE_ELSE); assert(if_inst->header.execution_size == BRW_EXECUTE_1); @@ -827,7 +832,8 @@ patch_IF_ELSE(struct brw_compile *p, unsigned br = 1; assert(!p->single_program_flow); - assert(if_inst != NULL && if_inst->header.opcode == BRW_OPCODE_IF); + assert(if_inst != NULL); + assert(if_inst->header.opcode == BRW_OPCODE_IF); assert(endif_inst != NULL); assert(else_inst == NULL || else_inst->header.opcode == BRW_OPCODE_ELSE); diff --git a/src/sna/gen2_render.c b/src/sna/gen2_render.c index e03c4401..6b7abb0d 100644 --- a/src/sna/gen2_render.c +++ b/src/sna/gen2_render.c @@ -607,7 +607,8 @@ static void gen2_emit_target(struct sna *sna, int format) { assert(!too_large(width, height)); - assert(bo->pitch >= 8 && bo->pitch <= MAX_3D_PITCH); + assert(bo->pitch >= 8); + assert(bo->pitch <= MAX_3D_PITCH); assert(sna->render.vertex_offset == 0); assert(bo->unique_id); @@ -3415,7 +3416,8 @@ gen2_render_copy_setup_source(struct sna_composite_channel *channel, const DrawableRec *draw, struct kgem_bo *bo) { - assert(draw->width && draw->height); + assert(draw->width); + assert(draw->height); channel->filter = PictFilterNearest; channel->repeat = RepeatNone; diff --git a/src/sna/gen7_render.c b/src/sna/gen7_render.c index 0a3bda76..a224f9f7 100644 --- a/src/sna/gen7_render.c +++ b/src/sna/gen7_render.c @@ -2189,7 +2189,8 @@ gen7_composite_set_target(struct sna *sna, op->dst.height = op->dst.pixmap->drawable.height; if (w | h) { - assert(w && h); + assert(w); + assert(h); box.x1 = x; box.y1 = y; box.x2 = x + w; diff --git a/src/sna/gen8_eu.c b/src/sna/gen8_eu.c index 71338c06..7eaa0436 100644 --- a/src/sna/gen8_eu.c +++ b/src/sna/gen8_eu.c @@ -384,21 +384,24 @@ __gen8_validate_reg(struct gen8_instruction *inst, struct brw_reg reg) if (reg.file == BRW_ARCHITECTURE_REGISTER_FILE) return; - assert(reg.hstride >= 0 && reg.hstride < ARRAY_SIZE(hstride_for_reg)); + assert(reg.hstride >= 0); + assert(reg.hstride < ARRAY_SIZE(hstride_for_reg)); hstride = hstride_for_reg[reg.hstride]; if (reg.vstride == 0xf) { vstride = -1; } else { - assert(reg.vstride >= 0 && reg.vstride < ARRAY_SIZE(vstride_for_reg)); + assert(reg.vstride >= 0); + assert(reg.vstride < ARRAY_SIZE(vstride_for_reg)); vstride = vstride_for_reg[reg.vstride]; } - assert(reg.width >= 0 && reg.width < ARRAY_SIZE(width_for_reg)); + assert(reg.width >= 0); + assert(reg.width < ARRAY_SIZE(width_for_reg)); width = width_for_reg[reg.width]; - assert(__gen8_exec_size(inst) >= 0 && - __gen8_exec_size(inst) < ARRAY_SIZE(execsize_for_reg)); + assert(__gen8_exec_size(inst) >= 0); + assert(__gen8_exec_size(inst) < ARRAY_SIZE(execsize_for_reg)); execsize = execsize_for_reg[__gen8_exec_size(inst)]; /* Restrictions from 3.3.10: Register Region Restrictions. */ diff --git a/src/sna/gen8_render.c b/src/sna/gen8_render.c index 69617da5..b62cc645 100644 --- a/src/sna/gen8_render.c +++ b/src/sna/gen8_render.c @@ -2020,7 +2020,8 @@ gen8_composite_set_target(struct sna *sna, op->dst.height = op->dst.pixmap->drawable.height; if (w | h) { - assert(w && h); + assert(w); + assert(h); box.x1 = x; box.y1 = y; box.x2 = x + w; diff --git a/src/sna/gen9_render.c b/src/sna/gen9_render.c index 3ed2eb3b..e08e3383 100644 --- a/src/sna/gen9_render.c +++ b/src/sna/gen9_render.c @@ -2096,7 +2096,8 @@ gen9_composite_set_target(struct sna *sna, op->dst.height = op->dst.pixmap->drawable.height; if (w | h) { - assert(w && h); + assert(w); + assert(h); box.x1 = x; box.y1 = y; box.x2 = x + w; diff --git a/src/sna/kgem.c b/src/sna/kgem.c index d396f1b4..278a9920 100644 --- a/src/sna/kgem.c +++ b/src/sna/kgem.c @@ -6067,7 +6067,8 @@ struct kgem_bo *kgem_create_cpu_2d(struct kgem *kgem, return bo; } - assert(width > 0 && height > 0); + assert(width > 0); + assert(height > 0); stride = ALIGN(width, 2) * bpp >> 3; stride = ALIGN(stride, 4); size = stride * ALIGN(height, 2); @@ -7869,7 +7870,8 @@ init: done: bo->used = ALIGN(bo->used, UPLOAD_ALIGNMENT); - assert(bo->used && bo->used <= bytes(&bo->base)); + assert(bo->used); + assert(bo->used <= bytes(&bo->base)); assert(bo->mem); *ret = (char *)bo->mem + offset; return kgem_create_proxy(kgem, &bo->base, offset, size); @@ -7889,7 +7891,8 @@ struct kgem_bo *kgem_create_buffer_2d(struct kgem *kgem, struct kgem_bo *bo; int stride; - assert(width > 0 && height > 0); + assert(width > 0); + assert(height > 0); assert(ret != NULL); stride = ALIGN(width, 2) * bpp >> 3; stride = ALIGN(stride, kgem->gen >= 0100 ? 32 : 4); diff --git a/src/sna/kgem.h b/src/sna/kgem.h index 8101ce51..fb065f26 100644 --- a/src/sna/kgem.h +++ b/src/sna/kgem.h @@ -867,8 +867,10 @@ memcpy_to_tiled_x(struct kgem *kgem, uint16_t width, uint16_t height) { assert(kgem->memcpy_to_tiled_x); - assert(src_x >= 0 && src_y >= 0); - assert(dst_x >= 0 && dst_y >= 0); + assert(src_x >= 0); + assert(src_y >= 0); + assert(dst_x >= 0); + assert(dst_y >= 0); assert(8*src_stride >= (src_x+width) * bpp); assert(8*dst_stride >= (dst_x+width) * bpp); return kgem->memcpy_to_tiled_x(src, dst, bpp, @@ -887,8 +889,10 @@ memcpy_from_tiled_x(struct kgem *kgem, uint16_t width, uint16_t height) { assert(kgem->memcpy_from_tiled_x); - assert(src_x >= 0 && src_y >= 0); - assert(dst_x >= 0 && dst_y >= 0); + assert(src_x >= 0); + assert(src_y >= 0); + assert(dst_x >= 0); + assert(dst_y >= 0); assert(8*src_stride >= (src_x+width) * bpp); assert(8*dst_stride >= (dst_x+width) * bpp); return kgem->memcpy_from_tiled_x(src, dst, bpp, diff --git a/src/sna/kgem_debug.c b/src/sna/kgem_debug.c index d90e5439..6a56c277 100644 --- a/src/sna/kgem_debug.c +++ b/src/sna/kgem_debug.c @@ -353,8 +353,8 @@ __decode_2d(struct kgem *kgem, uint32_t offset) kgem_debug_print(data, offset, 0, "%s\n", opcodes[op].name); if (opcodes[op].max_len > 1) { len = (data[0] & 0x000000ff) + 2; - assert(len >= opcodes[op].min_len && - len <= opcodes[op].max_len); + assert(len >= opcodes[op].min_len); + assert(len <= opcodes[op].max_len); } for (i = 1; i < len; i++) @@ -524,8 +524,8 @@ __decode_2d_gen8(struct kgem *kgem, uint32_t offset) kgem_debug_print(data, offset, 0, "%s\n", opcodes[op].name); if (opcodes[op].max_len > 1) { len = (data[0] & 0x000000ff) + 2; - assert(len >= opcodes[op].min_len && - len <= opcodes[op].max_len); + assert(len >= opcodes[op].min_len); + assert(len <= opcodes[op].max_len); } for (i = 1; i < len; i++) diff --git a/src/sna/kgem_debug_gen2.c b/src/sna/kgem_debug_gen2.c index 3f91c29d..33be3565 100644 --- a/src/sna/kgem_debug_gen2.c +++ b/src/sna/kgem_debug_gen2.c @@ -573,8 +573,8 @@ decode_3d_1d(struct kgem *kgem, uint32_t offset) kgem_debug_print(data, offset, 0, "%s\n", opcode_3d_1d->name); if (opcode_3d_1d->max_len > 1) { len = (data[0] & 0x0000ffff) + 2; - assert (len >= opcode_3d_1d->min_len && - len <= opcode_3d_1d->max_len); + assert (len >= opcode_3d_1d->min_len); + assert (len <= opcode_3d_1d->max_len); } for (i = 1; i < len; i++) @@ -666,8 +666,8 @@ int kgem_gen2_decode_3d(struct kgem *kgem, uint32_t offset) kgem_debug_print(data, offset, 0, "%s\n", opcodes[idx].name); if (opcodes[idx].max_len > 1) { len = (data[0] & 0xf) + 2; - assert(len >= opcodes[idx].min_len && - len <= opcodes[idx].max_len); + assert(len >= opcodes[idx].min_len); + assert(len <= opcodes[idx].max_len); } for (i = 1; i < len; i++) diff --git a/src/sna/kgem_debug_gen4.c b/src/sna/kgem_debug_gen4.c index 8e6e47b6..f6e75ebb 100644 --- a/src/sna/kgem_debug_gen4.c +++ b/src/sna/kgem_debug_gen4.c @@ -672,8 +672,8 @@ int kgem_gen4_decode_3d(struct kgem *kgem, uint32_t offset) kgem_debug_print(data, offset, 0, "%s\n", opcodes[i].name); if (opcodes[i].max_len > 1) { len = (data[0] & 0xff) + 2; - assert(len >= opcodes[i].min_len && - len <= opcodes[i].max_len); + assert(len >= opcodes[i].min_len); + assert(len <= opcodes[i].max_len); } for (i = 1; i < len; i++) diff --git a/src/sna/kgem_debug_gen5.c b/src/sna/kgem_debug_gen5.c index f1b1275f..e7a39f00 100644 --- a/src/sna/kgem_debug_gen5.c +++ b/src/sna/kgem_debug_gen5.c @@ -647,8 +647,8 @@ int kgem_gen5_decode_3d(struct kgem *kgem, uint32_t offset) kgem_debug_print(data, offset, 0, "%s\n", opcodes[i].name); if (opcodes[i].max_len > 1) { len = (data[0] & 0xff) + 2; - assert(len >= opcodes[i].min_len && - len <= opcodes[i].max_len); + assert(len >= opcodes[i].min_len); + assert(len <= opcodes[i].max_len); } for (i = 1; i < len; i++) diff --git a/src/sna/kgem_debug_gen6.c b/src/sna/kgem_debug_gen6.c index 579c5d54..0f6acd61 100644 --- a/src/sna/kgem_debug_gen6.c +++ b/src/sna/kgem_debug_gen6.c @@ -1059,8 +1059,8 @@ int kgem_gen6_decode_3d(struct kgem *kgem, uint32_t offset) kgem_debug_print(data, offset, 0, "%s\n", opcodes[i].name); if (opcodes[i].max_len > 1) { len = (data[0] & 0xff) + 2; - assert(len >= opcodes[i].min_len && - len <= opcodes[i].max_len); + assert(len >= opcodes[i].min_len); + assert(len <= opcodes[i].max_len); } for (i = 1; i < len; i++) diff --git a/src/sna/kgem_debug_gen7.c b/src/sna/kgem_debug_gen7.c index 1bc014bf..8078f440 100644 --- a/src/sna/kgem_debug_gen7.c +++ b/src/sna/kgem_debug_gen7.c @@ -700,8 +700,8 @@ int kgem_gen7_decode_3d(struct kgem *kgem, uint32_t offset) } else { kgem_debug_print(data, offset, 0, "%s\n", opcodes[i].name); if (opcodes[i].max_len > 1) { - assert(len >= opcodes[i].min_len && - len <= opcodes[i].max_len); + assert(len >= opcodes[i].min_len); + assert(len <= opcodes[i].max_len); } } for (i = 1; i < len; i++) diff --git a/src/sna/sna.h b/src/sna/sna.h index cf2a7a51..377301bc 100644 --- a/src/sna/sna.h +++ b/src/sna/sna.h @@ -1367,7 +1367,10 @@ extern jmp_buf sigjmp[4]; extern volatile sig_atomic_t sigtrap; #define sigtrap_assert_inactive() assert(sigtrap == 0) -#define sigtrap_assert_active() assert(sigtrap > 0 && sigtrap <= ARRAY_SIZE(sigjmp)) +#define sigtrap_assert_active() do { \ + assert(sigtrap > 0); \ + assert(sigtrap <= ARRAY_SIZE(sigjmp)); \ + } while(0) #define sigtrap_get() sigsetjmp(sigjmp[sigtrap++], 1) static inline void sigtrap_put(void) diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c index 7fd00b9a..e6d90096 100644 --- a/src/sna/sna_accel.c +++ b/src/sna/sna_accel.c @@ -393,7 +393,10 @@ static void assert_pixmap_damage(PixmapPtr p) if (DAMAGE_IS_ALL(priv->gpu_damage) && DAMAGE_IS_ALL(priv->cpu_damage)) { /* special upload buffer */ - assert(priv->gpu_bo && priv->gpu_bo->proxy); + assert(priv->gpu_bo); + assert(priv->gpu_bo->proxy); + assert(priv->gpu_bo); + assert(priv->gpu_bo->proxy); assert(priv->cpu_bo == NULL); return; } @@ -1339,7 +1342,8 @@ static PixmapPtr sna_create_pixmap(ScreenPtr screen, usage = -1; goto fallback; } - assert(width && height); + assert(width); + assert(height); flags = kgem_can_create_2d(&sna->kgem, width, height, depth); if (flags == 0) { @@ -3379,7 +3383,8 @@ sna_pixmap_move_area_to_gpu(PixmapPtr pixmap, const BoxRec *box, unsigned int fl if (priv == NULL) return NULL; - assert(box->x2 > box->x1 && box->y2 > box->y1); + assert(box->x2 > box->x1); + assert(box->y2 > box->y1); assert_pixmap_damage(pixmap); assert_pixmap_contains_box(pixmap, box); assert(priv->gpu_damage == NULL || priv->gpu_bo); @@ -3637,7 +3642,8 @@ sna_drawable_use_bo(DrawablePtr drawable, unsigned flags, const BoxRec *box, box->x1, box->y1, box->x2, box->y2, flags)); - assert(box->x2 > box->x1 && box->y2 > box->y1); + assert(box->x2 > box->x1); + assert(box->y2 > box->y1); assert(pixmap->refcnt); assert_pixmap_damage(pixmap); assert_drawable_contains_box(drawable, box); @@ -12837,11 +12843,27 @@ sna_poly_fill_rect_tiled_nxm_blt(DrawablePtr drawable, DBG(("%s: %dx%d+%d+%d (full tile size %dx%d)\n", __FUNCTION__, tw, th, tx, ty, tile->drawable.width, tile->drawable.height)); - assert(tx < tile->drawable.width && tx >= 0); - assert(ty < tile->drawable.height && ty >= 0); - assert(tw && tw <= 8 && tw <= tile->drawable.width); + assert(tx < tile->drawable.width); + assert(tx >= 0); + assert(tx < tile->drawable.width); + assert(tx >= 0); + assert(tx < tile->drawable.width); + assert(tx >= 0); + assert(tx < tile->drawable.width); + assert(tx >= 0); + assert(tx < tile->drawable.width); + assert(tx >= 0); + assert(tx < tile->drawable.width); + assert(tx >= 0); + assert(ty < tile->drawable.height); + assert(ty >= 0); + assert(tw); + assert(tw <= 8); + assert(tw <= tile->drawable.width); assert(is_power_of_two(tw)); - assert(th && th <= 8 && th <= tile->drawable.height); + assert(th); + assert(th <= 8); + assert(th <= tile->drawable.height); assert(is_power_of_two(th)); if (!sna_pixmap_move_to_cpu(tile, MOVE_READ)) @@ -17008,7 +17030,8 @@ sna_get_image__inplace(PixmapPtr pixmap, if (!USE_INPLACE) return false; - assert(priv && priv->gpu_bo); + assert(priv); + assert(priv->gpu_bo); switch (priv->gpu_bo->tiling) { case I915_TILING_Y: @@ -17097,7 +17120,8 @@ sna_get_image__blt(PixmapPtr pixmap, bool ok = false; int pitch; - assert(priv && priv->gpu_bo); + assert(priv); + assert(priv->gpu_bo); if (!sna->kgem.has_userptr || !USE_USERPTR_DOWNLOADS) return false; diff --git a/src/sna/sna_composite.c b/src/sna/sna_composite.c index 1da8c291..9a22b0ab 100644 --- a/src/sna/sna_composite.c +++ b/src/sna/sna_composite.c @@ -602,7 +602,10 @@ sna_composite_fb(CARD8 op, assert(box->y1 + ty >= 0); assert(box->y2 + ty <= dst_pixmap->drawable.height); - assert(box->x2 > box->x1 && box->y2 > box->y1); + assert(box->x2 > box->x1); + assert(box->y2 > box->y1); + assert(box->x2 > box->x1); + assert(box->y2 > box->y1); sigtrap_assert_active(); memcpy_blt(src_pixmap->devPrivate.ptr, diff --git a/src/sna/sna_damage.c b/src/sna/sna_damage.c index 8824a10b..c00f691b 100644 --- a/src/sna/sna_damage.c +++ b/src/sna/sna_damage.c @@ -303,10 +303,10 @@ static void __sna_damage_reduce(struct sna_damage *damage) pixman_region_init_rects(region, boxes, nboxes); assert(pixman_region_not_empty(region)); - assert(damage->extents.x1 == region->extents.x1 && - damage->extents.y1 == region->extents.y1 && - damage->extents.x2 == region->extents.x2 && - damage->extents.y2 == region->extents.y2); + assert(damage->extents.x1 == region->extents.x1); + assert(damage->extents.y1 == region->extents.y1); + assert(damage->extents.x2 == region->extents.x2); + assert(damage->extents.y2 == region->extents.y2); } else { pixman_region16_t tmp; @@ -315,10 +315,10 @@ static void __sna_damage_reduce(struct sna_damage *damage) pixman_region_subtract(region, region, &tmp); pixman_region_fini(&tmp); - assert(damage->extents.x1 <= region->extents.x1 && - damage->extents.y1 <= region->extents.y1 && - damage->extents.x2 >= region->extents.x2 && - damage->extents.y2 >= region->extents.y2); + assert(damage->extents.x1 <= region->extents.x1); + assert(damage->extents.y1 <= region->extents.y1); + assert(damage->extents.x2 >= region->extents.x2); + assert(damage->extents.y2 >= region->extents.y2); if (pixman_region_not_empty(region)) damage->extents = region->extents; else @@ -609,7 +609,8 @@ static void damage_union(struct sna_damage *damage, const BoxRec *box) damage->extents.x1, damage->extents.y1, damage->extents.x2, damage->extents.y2, box->x1, box->y1, box->x2, box->y2)); - assert(box->x2 > box->x1 && box->y2 > box->y1); + assert(box->x2 > box->x1); + assert(box->y2 > box->y1); if (damage->extents.x2 < damage->extents.x1) { damage->extents = *box; } else { @@ -766,10 +767,12 @@ __sna_damage_add_boxes(struct sna_damage *damage, break; } - assert(box[0].x2 > box[0].x1 && box[0].y2 > box[0].y1); + assert(box[0].x2 > box[0].x1); + assert(box[0].y2 > box[0].y1); extents = box[0]; for (i = 1; i < n; i++) { - assert(box[i].x2 > box[i].x1 && box[i].y2 > box[i].y1); + assert(box[i].x2 > box[i].x1); + assert(box[i].y2 > box[i].y1); if (extents.x1 > box[i].x1) extents.x1 = box[i].x1; if (extents.x2 < box[i].x2) @@ -780,7 +783,8 @@ __sna_damage_add_boxes(struct sna_damage *damage, extents.y2 = box[i].y2; } - assert(extents.y2 > extents.y1 && extents.x2 > extents.x1); + assert(extents.y2 > extents.y1); + assert(extents.x2 > extents.x1); extents.x1 += dx; extents.x2 += dx; @@ -839,13 +843,15 @@ __sna_damage_add_rectangles(struct sna_damage *damage, assert(n); - assert(r[0].width && r[0].height); + assert(r[0].width); + assert(r[0].height); extents.x1 = r[0].x; extents.x2 = r[0].x + r[0].width; extents.y1 = r[0].y; extents.y2 = r[0].y + r[0].height; for (i = 1; i < n; i++) { - assert(r[i].width && r[i].height); + assert(r[i].width); + assert(r[i].height); if (extents.x1 > r[i].x) extents.x1 = r[i].x; if (extents.x2 < r[i].x + r[i].width) @@ -856,7 +862,8 @@ __sna_damage_add_rectangles(struct sna_damage *damage, extents.y2 = r[i].y + r[i].height; } - assert(extents.y2 > extents.y1 && extents.x2 > extents.x1); + assert(extents.y2 > extents.y1); + assert(extents.x2 > extents.x1); extents.x1 += dx; extents.x2 += dx; @@ -1062,10 +1069,10 @@ struct sna_damage *_sna_damage_is_all(struct sna_damage *damage, damage->extents.x2, damage->extents.y2)); assert(damage->mode == DAMAGE_ADD); - assert(damage->extents.x1 == 0 && - damage->extents.y1 == 0 && - damage->extents.x2 == width && - damage->extents.y2 == height); + assert(damage->extents.x1 == 0); + assert(damage->extents.y1 == 0); + assert(damage->extents.x2 == width); + assert(damage->extents.y2 == height); if (damage->dirty) { __sna_damage_reduce(damage); @@ -1077,10 +1084,10 @@ struct sna_damage *_sna_damage_is_all(struct sna_damage *damage, return damage; } - assert(damage->extents.x1 == 0 && - damage->extents.y1 == 0 && - damage->extents.x2 == width && - damage->extents.y2 == height); + assert(damage->extents.x1 == 0); + assert(damage->extents.y1 == 0); + assert(damage->extents.x2 == width); + assert(damage->extents.y2 == height); return __sna_damage_all(damage, width, height); } @@ -1190,7 +1197,8 @@ fastcall struct sna_damage *_sna_damage_subtract(struct sna_damage *damage, inline static struct sna_damage *__sna_damage_subtract_box(struct sna_damage *damage, const BoxRec *box) { - assert(box->x2 > box->x1 && box->y2 > box->y1); + assert(box->x2 > box->x1); + assert(box->y2 > box->y1); if (damage == NULL) return NULL; @@ -1274,10 +1282,12 @@ static struct sna_damage *__sna_damage_subtract_boxes(struct sna_damage *damage, assert(n); - assert(box[0].x2 > box[0].x1 && box[0].y2 > box[0].y1); + assert(box[0].x2 > box[0].x1); + assert(box[0].y2 > box[0].y1); extents = box[0]; for (i = 1; i < n; i++) { - assert(box[i].x2 > box[i].x1 && box[i].y2 > box[i].y1); + assert(box[i].x2 > box[i].x1); + assert(box[i].y2 > box[i].y1); if (extents.x1 > box[i].x1) extents.x1 = box[i].x1; if (extents.x2 < box[i].x2) @@ -1288,7 +1298,8 @@ static struct sna_damage *__sna_damage_subtract_boxes(struct sna_damage *damage, extents.y2 = box[i].y2; } - assert(extents.y2 > extents.y1 && extents.x2 > extents.x1); + assert(extents.y2 > extents.y1); + assert(extents.x2 > extents.x1); extents.x1 += dx; extents.x2 += dx; @@ -1437,7 +1448,8 @@ bool _sna_damage_contains_box__no_reduce(const struct sna_damage *damage, int n, count; const BoxRec *b; - assert(damage && damage->mode != DAMAGE_ALL); + assert(damage); + assert(damage->mode != DAMAGE_ALL); if (!box_contains(&damage->extents, box)) return false; @@ -1481,7 +1493,8 @@ bool _sna_damage_contains_box__no_reduce(const struct sna_damage *damage, static bool __sna_damage_intersect(struct sna_damage *damage, RegionPtr region, RegionPtr result) { - assert(damage && damage->mode != DAMAGE_ALL); + assert(damage); + assert(damage->mode != DAMAGE_ALL); assert(RegionNotEmpty(region)); if (region->extents.x2 <= damage->extents.x1 || @@ -1535,7 +1548,8 @@ bool _sna_damage_intersect(struct sna_damage *damage, static int __sna_damage_get_boxes(struct sna_damage *damage, const BoxRec **boxes) { - assert(damage && damage->mode != DAMAGE_ALL); + assert(damage); + assert(damage->mode != DAMAGE_ALL); if (damage->dirty) __sna_damage_reduce(damage); @@ -1880,10 +1894,10 @@ void _sna_damage_debug_get_region(struct sna_damage *damage, RegionRec *r) pixman_region_init_rects(r, boxes, nboxes); assert(pixman_region_not_empty(r)); - assert(damage->extents.x1 == r->extents.x1 && - damage->extents.y1 == r->extents.y1 && - damage->extents.x2 == r->extents.x2 && - damage->extents.y2 == r->extents.y2); + assert(damage->extents.x1 == r->extents.x1); + assert(damage->extents.y1 == r->extents.y1); + assert(damage->extents.x2 == r->extents.x2); + assert(damage->extents.y2 == r->extents.y2); } else { pixman_region16_t tmp; @@ -1891,10 +1905,10 @@ void _sna_damage_debug_get_region(struct sna_damage *damage, RegionRec *r) pixman_region_subtract(r, r, &tmp); pixman_region_fini(&tmp); - assert(damage->extents.x1 <= r->extents.x1 && - damage->extents.y1 <= r->extents.y1 && - damage->extents.x2 >= r->extents.x2 && - damage->extents.y2 >= r->extents.y2); + assert(damage->extents.x1 <= r->extents.x1); + assert(damage->extents.y1 <= r->extents.y1); + assert(damage->extents.x2 >= r->extents.x2); + assert(damage->extents.y2 >= r->extents.y2); } free(boxes); diff --git a/src/sna/sna_display.c b/src/sna/sna_display.c index 119ea981..28b71e73 100644 --- a/src/sna/sna_display.c +++ b/src/sna/sna_display.c @@ -566,7 +566,8 @@ static void assert_scanout(struct kgem *kgem, struct kgem_bo *bo, assert(drmIoctl(kgem->fd, DRM_IOCTL_MODE_GETFB, &info) == 0); gem_close(kgem->fd, info.handle); - assert(width <= info.width && height <= info.height); + assert(width <= info.width); + assert(height <= info.height); } #else #define assert_scanout(k, b, w, h) @@ -2035,7 +2036,8 @@ static void sna_crtc_slave_damage(DamagePtr damage, RegionPtr region, void *clos static bool sna_crtc_enable_shadow(struct sna *sna, struct sna_crtc *crtc) { if (crtc->shadow) { - assert(sna->mode.shadow_damage && sna->mode.shadow_active); + assert(sna->mode.shadow_damage); + assert(sna->mode.shadow_active); return true; } @@ -2370,7 +2372,8 @@ static bool use_shadow(struct sna *sna, xf86CrtcPtr crtc) unsigned pitch_limit; BoxRec b; - assert(sna->scrn->virtualX && sna->scrn->virtualY); + assert(sna->scrn->virtualX); + assert(sna->scrn->virtualY); if (sna->flags & SNA_FORCE_SHADOW) { DBG(("%s: forcing shadow\n", __FUNCTION__)); @@ -2956,7 +2959,8 @@ sna_crtc_damage(xf86CrtcPtr crtc) region.extents.x1, region.extents.y1, region.extents.x2, region.extents.y2)); - assert(sna->mode.shadow_damage && sna->mode.shadow_active); + assert(sna->mode.shadow_damage); + assert(sna->mode.shadow_active); damage = DamageRegion(sna->mode.shadow_damage); RegionUnion(damage, damage, ®ion); to_sna_crtc(crtc)->crtc_damage = region; @@ -3145,8 +3149,8 @@ sna_crtc_set_mode_major(xf86CrtcPtr crtc, DisplayModePtr mode, outputs_for_crtc(crtc, outputs, sizeof(outputs)), __sna_crtc_pipe(sna_crtc), x, y, rotation_to_str(rotation), reflection_to_str(rotation)); - assert(mode->HDisplay <= sna->mode.max_crtc_width && - mode->VDisplay <= sna->mode.max_crtc_height); + assert(mode->HDisplay <= sna->mode.max_crtc_width); + assert(mode->VDisplay <= sna->mode.max_crtc_height); #if HAS_GAMMA drmModeCrtcSetGamma(sna->kgem.fd, __sna_crtc_id(sna_crtc), diff --git a/src/sna/sna_glyphs.c b/src/sna/sna_glyphs.c index 6ee40336..020de8e0 100644 --- a/src/sna/sna_glyphs.c +++ b/src/sna/sna_glyphs.c @@ -685,7 +685,8 @@ glyphs_to_dst(struct sna *sna, if (y2 > rects[i].y2) y2 = rects[i].y2; - assert(dx >= 0 && dy >= 0); + assert(dx >= 0); + assert(dy >= 0); if (r.dst.x < x2 && r.dst.y < y2) { DBG(("%s: blt=(%d, %d), (%d, %d)\n", @@ -834,7 +835,8 @@ glyphs0_to_dst(struct sna *sna, if (y2 > rects[i].y2) y2 = rects[i].y2; - assert(dx >= 0 && dy >= 0); + assert(dx >= 0); + assert(dy >= 0); if (r.dst.x < x2 && r.dst.y < y2) { DBG(("%s: blt=(%d, %d), (%d, %d)\n", @@ -1076,7 +1078,8 @@ __sna_glyph_get_image(GlyphPtr g, ScreenPtr s) if (!image) return NULL; - assert(dx == 0 && dy == 0); + assert(dx == 0); + assert(dy == 0); return sna_glyph(g)->image = image; } diff --git a/src/sna/sna_render.c b/src/sna/sna_render.c index 1787ffae..e1502a3b 100644 --- a/src/sna/sna_render.c +++ b/src/sna/sna_render.c @@ -755,7 +755,8 @@ static int sna_render_picture_downsample(struct sna *sna, goto fixup; priv = sna_pixmap(tmp); - assert(priv && priv->gpu_bo); + assert(priv); + assert(priv->gpu_bo); if (!sna_pixmap_move_to_gpu(pixmap, MOVE_ASYNC_HINT | MOVE_SOURCE_HINT | MOVE_READ)) { fixup: @@ -1325,7 +1326,8 @@ sna_render_picture_convolve(struct sna *sna, assert(picture->pDrawable); assert(picture->filter == PictFilterConvolution); - assert(w <= sna->render.max_3d_size && h <= sna->render.max_3d_size); + assert(w <= sna->render.max_3d_size); + assert(h <= sna->render.max_3d_size); if (PICT_FORMAT_RGB(picture->format) == 0) { channel->pict_format = PIXMAN_a8; @@ -1413,7 +1415,8 @@ sna_render_picture_flatten(struct sna *sna, assert(picture->pDrawable); assert(picture->alphaMap); - assert(w <= sna->render.max_3d_size && h <= sna->render.max_3d_size); + assert(w <= sna->render.max_3d_size); + assert(h <= sna->render.max_3d_size); /* XXX shortcut a8? */ DBG(("%s: %dx%d\n", __FUNCTION__, w, h)); diff --git a/src/sna/sna_render_inline.h b/src/sna/sna_render_inline.h index f2d9c226..a3854848 100644 --- a/src/sna/sna_render_inline.h +++ b/src/sna/sna_render_inline.h @@ -252,7 +252,8 @@ sna_render_picture_extents(PicturePtr p, BoxRec *box) if (box->y2 > p->pCompositeClip->extents.y2) box->y2 = p->pCompositeClip->extents.y2; - assert(box->x2 > box->x1 && box->y2 > box->y1); + assert(box->x2 > box->x1); + assert(box->y2 > box->y1); } static inline void diff --git a/src/sna/sna_threads.c b/src/sna/sna_threads.c index f9c6b1e8..2db4e108 100644 --- a/src/sna/sna_threads.c +++ b/src/sna/sna_threads.c @@ -176,7 +176,8 @@ void sna_threads_run(int id, void (*func)(void *arg), void *arg) { assert(max_threads > 0); assert(pthread_self() == threads[0].thread); - assert(id > 0 && id < max_threads); + assert(id > 0); + assert(id < max_threads); assert(threads[id].func == NULL); diff --git a/src/sna/sna_trapezoids_imprecise.c b/src/sna/sna_trapezoids_imprecise.c index 8bc7c8a8..69144024 100644 --- a/src/sna/sna_trapezoids_imprecise.c +++ b/src/sna/sna_trapezoids_imprecise.c @@ -531,7 +531,8 @@ polygon_add_edge(struct polygon *polygon, ++e->x.quo; e->x.rem -= Ey; } - assert(e->x.rem >= 0 && e->x.rem < Ey); + assert(e->x.rem >= 0); + assert(e->x.rem < Ey); e->cell = e->x.quo + (e->x.rem >= Ey/2); e->dy = Ey; @@ -1232,7 +1233,8 @@ tor_render(struct sna *sna, do_full_step -= FAST_SAMPLES_Y; j++; } - assert(j >= i + 1 && j <= h); + assert(j >= i + 1); + assert(j <= h); if (j != i + 1) step_edges(active, j - (i + 1)); @@ -1624,7 +1626,8 @@ tor_inplace(struct tor *converter, PixmapPtr scratch, int mono, uint8_t *buf) inplace_subrow(active, ptr, width, &min, &max); } - assert(min >= 0 && max <= width); + assert(min >= 0); + assert(max <= width); memset(row, 0, min); if (max > min) { inplace_end_subrows(active, row+min, (int8_t*)ptr+min, max-min); diff --git a/src/sna/sna_trapezoids_precise.c b/src/sna/sna_trapezoids_precise.c index 242b4acb..2f1d7e7f 100644 --- a/src/sna/sna_trapezoids_precise.c +++ b/src/sna/sna_trapezoids_precise.c @@ -500,7 +500,8 @@ static inline int edge_advance(struct edge *e) e->x.quo++; e->x.rem -= e->dy; } - assert(e->x.rem >= 0 && e->x.rem < e->dy); + assert(e->x.rem >= 0); + assert(e->x.rem < e->dy); return edge_to_cell(e); } @@ -583,7 +584,8 @@ polygon_add_edge(struct polygon *polygon, e->x.quo++; e->x.rem -= Ey; } - assert(e->x.rem >= 0 && e->x.rem < Ey); + assert(e->x.rem >= 0); + assert(e->x.rem < Ey); e->dy = Ey; e->cell = edge_to_cell(e); @@ -685,7 +687,8 @@ polygon_add_line(struct polygon *polygon, e->x.quo++; e->x.rem -= Ey; } - assert(e->x.rem >= 0 && e->x.rem < Ey); + assert(e->x.rem >= 0); + assert(e->x.rem < Ey); e->dy = Ey; e->cell = edge_to_cell(e); @@ -1240,7 +1243,8 @@ tor_render(struct sna *sna, do_full_step -= SAMPLES_Y; j++; } - assert(j >= i + 1 && j <= h); + assert(j >= i + 1); + assert(j <= h); if (j != i + 1) step_edges(active, j - (i + 1)); diff --git a/src/sna/sna_video.c b/src/sna/sna_video.c index b7aa6624..0a6106f6 100644 --- a/src/sna/sna_video.c +++ b/src/sna/sna_video.c @@ -213,7 +213,8 @@ sna_video_frame_init(struct sna_video *video, { DBG(("%s: id=%d [planar? %d], width=%d, height=%d, align=%d\n", __FUNCTION__, id, is_planar_fourcc(id), width, height, video->alignment)); - assert(width && height); + assert(width); + assert(height); frame->bo = NULL; frame->id = id; @@ -677,7 +678,8 @@ sna_video_copy_data(struct sna_video *video, __FUNCTION__, frame->image.x1, frame->image.y1, frame->image.x2, frame->image.y2, frame->src.x1, frame->src.y1, frame->src.x2, frame->src.y2)); - assert(frame->width && frame->height); + assert(frame->width); + assert(frame->height); assert(frame->rotation); assert(frame->size);