diff options
author | Tor Andersson <tor.andersson@artifex.com> | 2011-12-08 23:36:20 +0100 |
---|---|---|
committer | Tor Andersson <tor.andersson@artifex.com> | 2011-12-08 23:36:20 +0100 |
commit | 2af3baffb58f22ddf3ac5944d2677b981763e03d (patch) | |
tree | 70d1dfc4ea490b053072b2ea68ad250b8a96972e /draw | |
parent | 62ff8552500694c96b998d2aac6fbc47ab2d9395 (diff) | |
download | mupdf-2af3baffb58f22ddf3ac5944d2677b981763e03d.tar.xz |
Stylistic changes when testing pointer values for NULL.
Also: use 'cannot' instead of 'failed to' in error messages.
Diffstat (limited to 'draw')
-rw-r--r-- | draw/draw_affine.c | 2 | ||||
-rw-r--r-- | draw/draw_device.c | 28 | ||||
-rw-r--r-- | draw/draw_scale.c | 20 | ||||
-rw-r--r-- | draw/draw_simple_scale.c | 20 |
4 files changed, 35 insertions, 35 deletions
diff --git a/draw/draw_affine.c b/draw/draw_affine.c index c1ee88f8..936f4a7f 100644 --- a/draw/draw_affine.c +++ b/draw/draw_affine.c @@ -679,7 +679,7 @@ fz_paint_image_imp(fz_pixmap *dst, fz_bbox scissor, fz_pixmap *shape, fz_pixmap if (dst->n == 4 && img->n == 2) { - assert(color == NULL); + assert(!color); if (dolerp) paintfn = fz_paint_affine_g2rgb_lerp; else diff --git a/draw/draw_device.c b/draw/draw_device.c index cb6760ea..cc8f5474 100644 --- a/draw/draw_device.c +++ b/draw/draw_device.c @@ -74,7 +74,7 @@ static void fz_dump_blend(fz_pixmap *pix, const char *s) { char name[80]; - if (pix == NULL) + if (!pix) return; sprintf(name, "dump%02d.png", group_dump_count); @@ -139,7 +139,7 @@ static void fz_knockout_begin(fz_draw_device *dev) int i = dev->top; do prev = dev->stack[--i].dest; - while (prev == NULL); + while (!prev); fz_copy_pixmap_rect(dest, prev, bbox); } @@ -206,7 +206,7 @@ static void fz_knockout_end(fz_draw_device *dev) printf(" (isolated)"); printf(" (knockout)"); #endif - if ((blendmode == 0) && (shape == NULL)) + if ((blendmode == 0) && (!shape)) fz_paint_pixmap(dev->dest, group, 255); else fz_blend_pixmap(dev->dest, group, 255, blendmode, isolated, shape); @@ -871,7 +871,7 @@ fz_transform_pixmap(fz_context *ctx, fz_pixmap *image, fz_matrix *ctm, int x, in if (gridfit) fz_gridfit_matrix(&m); scaled = fz_scale_pixmap(ctx, image, m.e, m.f, m.a, m.d); - if (scaled == NULL) + if (!scaled) return NULL; ctm->a = scaled->w; ctm->d = scaled->h; @@ -887,7 +887,7 @@ fz_transform_pixmap(fz_context *ctx, fz_pixmap *image, fz_matrix *ctm, int x, in if (gridfit) fz_gridfit_matrix(&m); scaled = fz_scale_pixmap(ctx, image, m.f, m.e, m.b, m.c); - if (scaled == NULL) + if (!scaled) return NULL; ctm->b = scaled->w; ctm->c = scaled->h; @@ -949,7 +949,7 @@ fz_draw_fill_image(fz_device *devp, fz_pixmap *image, fz_matrix ctm, float alpha { int gridfit = alpha == 1.0f && !(dev->flags & FZ_DRAWDEV_FLAGS_TYPE3); scaled = fz_transform_pixmap(dev->ctx, image, &ctm, dev->dest->x, dev->dest->y, dx, dy, gridfit); - if (scaled == NULL) + if (!scaled) { if (dx < 1) dx = 1; @@ -957,7 +957,7 @@ fz_draw_fill_image(fz_device *devp, fz_pixmap *image, fz_matrix ctm, float alpha dy = 1; scaled = fz_scale_pixmap(dev->ctx, image, image->x, image->y, dx, dy); } - if (scaled != NULL) + if (scaled) image = scaled; } @@ -1011,7 +1011,7 @@ fz_draw_fill_image_mask(fz_device *devp, fz_pixmap *image, fz_matrix ctm, { int gridfit = alpha == 1.0f && !(dev->flags & FZ_DRAWDEV_FLAGS_TYPE3); scaled = fz_transform_pixmap(dev->ctx, image, &ctm, dev->dest->x, dev->dest->y, dx, dy, gridfit); - if (scaled == NULL) + if (!scaled) { if (dx < 1) dx = 1; @@ -1019,7 +1019,7 @@ fz_draw_fill_image_mask(fz_device *devp, fz_pixmap *image, fz_matrix ctm, dy = 1; scaled = fz_scale_pixmap(dev->ctx, image, image->x, image->y, dx, dy); } - if (scaled != NULL) + if (scaled) image = scaled; } @@ -1089,7 +1089,7 @@ fz_draw_clip_image_mask(fz_device *devp, fz_pixmap *image, fz_rect *rect, fz_mat { int gridfit = !(dev->flags & FZ_DRAWDEV_FLAGS_TYPE3); scaled = fz_transform_pixmap(dev->ctx, image, &ctm, dev->dest->x, dev->dest->y, dx, dy, gridfit); - if (scaled == NULL) + if (!scaled) { if (dx < 1) dx = 1; @@ -1097,7 +1097,7 @@ fz_draw_clip_image_mask(fz_device *devp, fz_pixmap *image, fz_rect *rect, fz_mat dy = 1; scaled = fz_scale_pixmap(dev->ctx, image, image->x, image->y, dx, dy); } - if (scaled != NULL) + if (scaled) image = scaled; } @@ -1151,7 +1151,7 @@ fz_draw_pop_clip(fz_device *devp) fz_dump_blend(mask, " with "); #endif fz_paint_pixmap_with_mask(dest, dev->dest, mask); - if (shape != NULL) + if (shape) { assert(shape != dev->shape); fz_paint_pixmap_with_mask(shape, dev->shape, mask); @@ -1173,7 +1173,7 @@ fz_draw_pop_clip(fz_device *devp) #ifdef DUMP_GROUP_BLENDS dump_spaces(dev->top, "Clip End\n"); #endif - assert(dest == NULL); + assert(!dest); assert(shape == dev->shape); } } @@ -1393,7 +1393,7 @@ fz_draw_end_group(fz_device *devp) if (blendmode & FZ_BLEND_KNOCKOUT) printf(" (knockout)"); #endif - if ((blendmode == 0) && (shape == NULL)) + if ((blendmode == 0) && (!shape)) fz_paint_pixmap(dev->dest, group, alpha * 255); else fz_blend_pixmap(dev->dest, group, alpha * 255, blendmode, isolated, shape); diff --git a/draw/draw_scale.c b/draw/draw_scale.c index fd3c3798..578a1d1e 100644 --- a/draw/draw_scale.c +++ b/draw/draw_scale.c @@ -298,7 +298,7 @@ new_weights(fz_context *ctx, fz_scale_filter *filter, int src_w, float dst_w, in * plus room for an extra set of weights for reordering. */ weights = fz_malloc(ctx, sizeof(*weights)+(max_len+3)*(dst_w_i+1)*sizeof(int)); - if (weights == NULL) + if (!weights) return NULL; weights->count = -1; weights->max_len = max_len; @@ -527,7 +527,7 @@ make_weights(fz_context *ctx, int src_w, float x, float dst_w, fz_scale_filter * window = filter->width / F; DBUG(("make_weights src_w=%d x=%g dst_w=%g dst_w_int=%d F=%g window=%g\n", src_w, x, dst_w, dst_w_int, F, window)); weights = new_weights(ctx, filter, src_w, dst_w, dst_w_int, n, flip); - if (weights == NULL) + if (!weights) return NULL; for (j = 0; j < dst_w_int; j++) { @@ -1291,7 +1291,7 @@ fz_scale_pixmap(fz_context *ctx, fz_pixmap *src, float x, float y, float w, floa #endif /* SINGLE_PIXEL_SPECIALS */ { contrib_cols = make_weights(ctx, src->w, x, w, filter, 0, dst_w_int, src->n, flip_x); - if (contrib_cols == NULL) + if (!contrib_cols) goto cleanup; } #ifdef SINGLE_PIXEL_SPECIALS @@ -1303,22 +1303,22 @@ fz_scale_pixmap(fz_context *ctx, fz_pixmap *src, float x, float y, float w, floa #endif /* SINGLE_PIXEL_SPECIALS */ { contrib_rows = make_weights(ctx, src->h, y, h, filter, 1, dst_h_int, src->n, flip_y); - if (contrib_rows == NULL) + if (!contrib_rows) goto cleanup; } - assert(contrib_cols == NULL || contrib_cols->count == dst_w_int); - assert(contrib_rows == NULL || contrib_rows->count == dst_h_int); + assert(!contrib_cols || contrib_cols->count == dst_w_int); + assert(!contrib_rows || contrib_rows->count == dst_h_int); output = fz_new_pixmap(ctx, src->colorspace, dst_w_int, dst_h_int); output->x = dst_x_int; output->y = dst_y_int; /* Step 2: Apply the weights */ #ifdef SINGLE_PIXEL_SPECIALS - if (contrib_rows == NULL) + if (!contrib_rows) { /* Only 1 source pixel high. */ - if (contrib_cols == NULL) + if (!contrib_cols) { /* Only 1 pixel in the entire image! */ duplicate_single_pixel(output->samples, src->samples, src->n, dst_w_int, dst_h_int); @@ -1329,7 +1329,7 @@ fz_scale_pixmap(fz_context *ctx, fz_pixmap *src, float x, float y, float w, floa scale_single_row(output->samples, src->samples, contrib_cols, src->w, dst_h_int); } } - else if (contrib_cols == NULL) + else if (!contrib_cols) { /* Only 1 source pixel wide. Scale the col and duplicate. */ scale_single_col(output->samples, src->samples, contrib_rows, src->h, src->n, dst_w_int, flip_y); @@ -1344,7 +1344,7 @@ fz_scale_pixmap(fz_context *ctx, fz_pixmap *src, float x, float y, float w, floa if (temp_span <= 0 || temp_rows > INT_MAX / temp_span) goto cleanup; temp = fz_malloc_array(ctx, temp_span*temp_rows, sizeof(int)); - if (temp == NULL) + if (!temp) goto cleanup; switch (src->n) { diff --git a/draw/draw_simple_scale.c b/draw/draw_simple_scale.c index dcd5cd68..cd8ac2b9 100644 --- a/draw/draw_simple_scale.c +++ b/draw/draw_simple_scale.c @@ -254,7 +254,7 @@ new_weights(fz_context *ctx, fz_scale_filter *filter, int src_w, float dst_w, in * plus room for an extra set of weights for reordering. */ weights = fz_malloc(ctx, sizeof(*weights)+(max_len+3)*(dst_w_i+1)*sizeof(int)); - if (weights == NULL) + if (!weights) return NULL; weights->count = -1; weights->max_len = max_len; @@ -465,7 +465,7 @@ make_weights(fz_context *ctx, int src_w, float x, float dst_w, fz_scale_filter * window = filter->width / F; DBUG(("make_weights src_w=%d x=%g dst_w=%g dst_w_int=%d F=%g window=%g\n", src_w, x, dst_w, dst_w_int, F, window)); weights = new_weights(ctx, filter, src_w, dst_w, dst_w_int, n, flip); - if (weights == NULL) + if (!weights) return NULL; for (j = 0; j < dst_w_int; j++) { @@ -1250,7 +1250,7 @@ fz_scale_pixmap(fz_context *ctx, fz_pixmap *src, float x, float y, float w, floa #endif /* SINGLE_PIXEL_SPECIALS */ { contrib_cols = make_weights(ctx, src->w, x, w, filter, 0, dst_w_int, src->n, flip_x); - if (contrib_cols == NULL) + if (!contrib_cols) goto cleanup; } #ifdef SINGLE_PIXEL_SPECIALS @@ -1262,22 +1262,22 @@ fz_scale_pixmap(fz_context *ctx, fz_pixmap *src, float x, float y, float w, floa #endif /* SINGLE_PIXEL_SPECIALS */ { contrib_rows = make_weights(ctx, src->h, y, h, filter, 1, dst_h_int, src->n, flip_y); - if (contrib_rows == NULL) + if (!contrib_rows) goto cleanup; } - assert(contrib_cols == NULL || contrib_cols->count == dst_w_int); - assert(contrib_rows == NULL || contrib_rows->count == dst_h_int); + assert(!contrib_cols || contrib_cols->count == dst_w_int); + assert(!contrib_rows || contrib_rows->count == dst_h_int); output = fz_new_pixmap(ctx, src->colorspace, dst_w_int, dst_h_int); output->x = dst_x_int; output->y = dst_y_int; /* Step 2: Apply the weights */ #ifdef SINGLE_PIXEL_SPECIALS - if (contrib_rows == NULL) + if (!contrib_rows) { /* Only 1 source pixel high. */ - if (contrib_cols == NULL) + if (!contrib_cols) { /* Only 1 pixel in the entire image! */ duplicate_single_pixel(output->samples, src->samples, src->n, dst_w_int, dst_h_int); @@ -1288,7 +1288,7 @@ fz_scale_pixmap(fz_context *ctx, fz_pixmap *src, float x, float y, float w, floa scale_single_row(output->samples, src->samples, contrib_cols, src->w, dst_h_int); } } - else if (contrib_cols == NULL) + else if (!contrib_cols) { /* Only 1 source pixel wide. Scale the col and duplicate. */ scale_single_col(output->samples, src->samples, contrib_rows, src->h, src->n, dst_w_int, flip_y); @@ -1303,7 +1303,7 @@ fz_scale_pixmap(fz_context *ctx, fz_pixmap *src, float x, float y, float w, floa if (temp_span <= 0 || temp_rows > INT_MAX / temp_span) goto cleanup; temp = fz_calloc(ctx, temp_span*temp_rows, sizeof(unsigned char)); - if (temp == NULL) + if (!temp) goto cleanup; switch (src->n) { |