summaryrefslogtreecommitdiff
path: root/fitz
diff options
context:
space:
mode:
authorTor Andersson <tor.andersson@artifex.com>2011-12-08 23:36:20 +0100
committerTor Andersson <tor.andersson@artifex.com>2011-12-08 23:36:20 +0100
commit2af3baffb58f22ddf3ac5944d2677b981763e03d (patch)
tree70d1dfc4ea490b053072b2ea68ad250b8a96972e /fitz
parent62ff8552500694c96b998d2aac6fbc47ab2d9395 (diff)
downloadmupdf-2af3baffb58f22ddf3ac5944d2677b981763e03d.tar.xz
Stylistic changes when testing pointer values for NULL.
Also: use 'cannot' instead of 'failed to' in error messages.
Diffstat (limited to 'fitz')
-rw-r--r--fitz/base_context.c2
-rw-r--r--fitz/base_error.c6
-rw-r--r--fitz/base_getopt.c4
-rw-r--r--fitz/base_memory.c12
-rw-r--r--fitz/base_object.c6
-rw-r--r--fitz/base_string.c4
-rw-r--r--fitz/dev_list.c8
-rw-r--r--fitz/filt_basic.c8
-rw-r--r--fitz/filt_faxd.c2
-rw-r--r--fitz/filt_lzwd.c2
-rw-r--r--fitz/memento.c6
-rw-r--r--fitz/res_font.c10
-rw-r--r--fitz/res_halftone.c2
-rw-r--r--fitz/res_path.c2
-rw-r--r--fitz/stm_buffer.c2
-rw-r--r--fitz/stm_open.c2
16 files changed, 39 insertions, 39 deletions
diff --git a/fitz/base_context.c b/fitz/base_context.c
index 0eacd6eb..3d9df6aa 100644
--- a/fitz/base_context.c
+++ b/fitz/base_context.c
@@ -11,7 +11,7 @@ fz_obj *(*fz_resolve_indirect)(fz_obj*) = fz_resolve_indirect_null;
void
fz_free_context(fz_context *ctx)
{
- if (ctx == NULL)
+ if (!ctx)
return;
/* Other finalisation calls go here (in reverse order) */
diff --git a/fitz/base_error.c b/fitz/base_error.c
index 3373016f..1184981c 100644
--- a/fitz/base_error.c
+++ b/fitz/base_error.c
@@ -51,7 +51,7 @@ static void throw(fz_error_context *ex)
void fz_push_try(fz_error_context *ex)
{
- assert(ex != NULL);
+ assert(ex);
if (ex->top + 1 >= nelem(ex->stack))
{
fprintf(stderr, "exception stack overflow!\n");
@@ -62,8 +62,8 @@ void fz_push_try(fz_error_context *ex)
char *fz_caught(fz_context *ctx)
{
- assert(ctx != NULL);
- assert(ctx->error != NULL);
+ assert(ctx);
+ assert(ctx->error);
return ctx->error->message;
}
diff --git a/fitz/base_getopt.c b/fitz/base_getopt.c
index 2c198ba1..2a6e5ac4 100644
--- a/fitz/base_getopt.c
+++ b/fitz/base_getopt.c
@@ -25,7 +25,7 @@ getopt(int argc, char *argv[], char *optstring)
optarg = NULL;
- if (scan == NULL || *scan == '\0') {
+ if (!scan || *scan == '\0') {
if (optind == 0)
optind++;
@@ -43,7 +43,7 @@ getopt(int argc, char *argv[], char *optstring)
c = *scan++;
place = strchr(optstring, c);
- if (place == NULL || c == ':') {
+ if (!place || c == ':') {
fprintf(stderr, "%s: unknown option -%c\n", argv[0], c);
return '?';
}
diff --git a/fitz/base_memory.c b/fitz/base_memory.c
index 43ec0dd9..79ae38b0 100644
--- a/fitz/base_memory.c
+++ b/fitz/base_memory.c
@@ -4,7 +4,7 @@ void *
fz_malloc(fz_context *ctx, unsigned int size)
{
void *p = ctx->alloc->malloc(ctx->alloc->user, size);
- if (p == NULL)
+ if (!p)
fz_throw(ctx, "malloc of %d bytes failed", size);
return p;
}
@@ -27,7 +27,7 @@ fz_malloc_array(fz_context *ctx, unsigned int count, unsigned int size)
fz_throw(ctx, "malloc of array (%d x %d bytes) failed (integer overflow)", count, size);
p = ctx->alloc->malloc(ctx->alloc->user, count * size);
- if (p == NULL)
+ if (!p)
fz_throw(ctx, "malloc of array (%d x %d bytes) failed", count, size);
return p;
}
@@ -61,7 +61,7 @@ fz_calloc(fz_context *ctx, unsigned int count, unsigned int size)
}
p = ctx->alloc->malloc(ctx->alloc->user, count * size);
- if (p == NULL)
+ if (!p)
{
fz_throw(ctx, "calloc (%d x %d bytes) failed", count, size);
}
@@ -84,7 +84,7 @@ fz_calloc_no_throw(fz_context *ctx, unsigned int count, unsigned int size)
}
p = ctx->alloc->malloc(ctx->alloc->user, count * size);
- if (p != NULL)
+ if (p)
{
memset(p, 0, count*size);
}
@@ -106,7 +106,7 @@ fz_resize_array(fz_context *ctx, void *p, unsigned int count, unsigned int size)
fz_throw(ctx, "resize array (%d x %d bytes) failed (integer overflow)", count, size);
np = ctx->alloc->realloc(ctx->alloc->user, p, count * size);
- if (np == NULL)
+ if (!np)
fz_throw(ctx, "resize array (%d x %d bytes) failed", count, size);
return np;
}
@@ -149,7 +149,7 @@ fz_strdup_no_throw(fz_context *ctx, char *s)
{
int len = strlen(s) + 1;
char *ns = fz_malloc_no_throw(ctx, len);
- if (ns != NULL)
+ if (ns)
memcpy(ns, s, len);
return ns;
}
diff --git a/fitz/base_object.c b/fitz/base_object.c
index 8c79e4c6..957396ea 100644
--- a/fitz/base_object.c
+++ b/fitz/base_object.c
@@ -136,7 +136,7 @@ fz_new_indirect(fz_context *ctx, int num, int gen, void *xref)
fz_obj *
fz_keep_obj(fz_obj *obj)
{
- assert(obj != NULL);
+ assert(obj);
obj->refs ++;
return obj;
}
@@ -358,7 +358,7 @@ fz_objcmp(fz_obj *a, fz_obj *b)
static char *
fz_objkindstr(fz_obj *obj)
{
- if (obj == NULL)
+ if (!obj)
return "<NULL>";
switch (obj->kind)
{
@@ -834,7 +834,7 @@ fz_free_dict(fz_obj *obj)
void
fz_drop_obj(fz_obj *obj)
{
- if (obj == NULL)
+ if (!obj)
return;
if (--obj->refs)
return;
diff --git a/fitz/base_string.c b/fitz/base_string.c
index 76748e20..dd9f8ea2 100644
--- a/fitz/base_string.c
+++ b/fitz/base_string.c
@@ -11,8 +11,8 @@ char *
fz_strsep(char **stringp, const char *delim)
{
char *ret = *stringp;
- if (ret == NULL) return NULL;
- if ((*stringp = strpbrk(*stringp, delim)) != NULL)
+ if (!ret) return NULL;
+ if ((*stringp = strpbrk(*stringp, delim)))
*((*stringp)++) = '\0';
return ret;
}
diff --git a/fitz/dev_list.c b/fitz/dev_list.c
index 63e9eee0..cbb988df 100644
--- a/fitz/dev_list.c
+++ b/fitz/dev_list.c
@@ -154,7 +154,7 @@ fz_append_display_node(fz_display_list *list, fz_display_node *node)
update = list->stack[list->top].update;
if (list->tiled == 0)
{
- if (update != NULL)
+ if (update)
{
*update = fz_intersect_rect(*update, list->stack[list->top].rect);
node->rect = *update;
@@ -255,7 +255,7 @@ fz_list_clip_path(fz_device *dev, fz_path *path, fz_rect *rect, int even_odd, fz
fz_display_node *node;
node = fz_new_display_node(dev->ctx, FZ_CMD_CLIP_PATH, ctm, NULL, NULL, 0);
node->rect = fz_bound_path(path, NULL, ctm);
- if (rect != NULL)
+ if (rect)
node->rect = fz_intersect_rect(node->rect, *rect);
node->item.path = fz_clone_path(dev->ctx, path);
node->flag = even_odd;
@@ -268,7 +268,7 @@ fz_list_clip_stroke_path(fz_device *dev, fz_path *path, fz_rect *rect, fz_stroke
fz_display_node *node;
node = fz_new_display_node(dev->ctx, FZ_CMD_CLIP_STROKE_PATH, ctm, NULL, NULL, 0);
node->rect = fz_bound_path(path, stroke, ctm);
- if (rect != NULL)
+ if (rect)
node->rect = fz_intersect_rect(node->rect, *rect);
node->item.path = fz_clone_path(dev->ctx, path);
node->stroke = fz_clone_stroke_state(dev->ctx, stroke);
@@ -378,7 +378,7 @@ fz_list_clip_image_mask(fz_device *dev, fz_pixmap *image, fz_rect *rect, fz_matr
fz_display_node *node;
node = fz_new_display_node(dev->ctx, FZ_CMD_CLIP_IMAGE_MASK, ctm, NULL, NULL, 0);
node->rect = fz_transform_rect(ctm, fz_unit_rect);
- if (rect != NULL)
+ if (rect)
node->rect = fz_intersect_rect(node->rect, *rect);
node->item.image = fz_keep_pixmap(image);
fz_append_display_node(dev->user, node);
diff --git a/fitz/filt_basic.c b/fitz/filt_basic.c
index 1ab70f7f..3d211645 100644
--- a/fitz/filt_basic.c
+++ b/fitz/filt_basic.c
@@ -40,7 +40,7 @@ fz_open_null(fz_stream *chain, int len)
{
struct null_filter *state;
- assert(chain != NULL);
+ assert(chain);
state = fz_malloc(chain->ctx, sizeof(struct null_filter));
state->chain = chain;
state->remain = len;
@@ -282,7 +282,7 @@ fz_open_a85d(fz_stream *chain)
{
fz_a85d *state;
- assert(chain != NULL);
+ assert(chain);
state = fz_malloc(chain->ctx, sizeof(fz_a85d));
state->chain = chain;
state->rp = state->bp;
@@ -370,7 +370,7 @@ fz_open_rld(fz_stream *chain)
{
fz_rld *state;
- assert(chain != NULL);
+ assert(chain);
state = fz_malloc(chain->ctx, sizeof(fz_rld));
state->chain = chain;
state->run = 0;
@@ -496,7 +496,7 @@ fz_open_aesd(fz_stream *chain, unsigned char *key, unsigned keylen)
{
fz_aesd *state;
- assert(chain != NULL);
+ assert(chain);
state = fz_malloc(chain->ctx, sizeof(fz_aesd));
state->chain = chain;
aes_setkey_dec(&state->aes, key, keylen * 8);
diff --git a/fitz/filt_faxd.c b/fitz/filt_faxd.c
index f94a2cd6..98430e0d 100644
--- a/fitz/filt_faxd.c
+++ b/fitz/filt_faxd.c
@@ -666,7 +666,7 @@ fz_open_faxd(fz_stream *chain, fz_obj *params)
fz_obj *obj;
fz_context *ctx;
- assert(chain != NULL);
+ assert(chain);
ctx = chain->ctx;
fax = fz_malloc(ctx, sizeof(fz_faxd));
fax->chain = chain;
diff --git a/fitz/filt_lzwd.c b/fitz/filt_lzwd.c
index 76cad305..7ca78fc3 100644
--- a/fitz/filt_lzwd.c
+++ b/fitz/filt_lzwd.c
@@ -170,7 +170,7 @@ fz_open_lzwd(fz_stream *chain, fz_obj *params)
fz_obj *obj;
int i;
- assert(chain != NULL);
+ assert(chain);
lzw = fz_malloc(chain->ctx, sizeof(fz_lzwd));
lzw->chain = chain;
lzw->eod = 0;
diff --git a/fitz/memento.c b/fitz/memento.c
index 24e19e3a..c6677a0f 100644
--- a/fitz/memento.c
+++ b/fitz/memento.c
@@ -423,7 +423,7 @@ static void Memento_fin(void)
globals.numFrees, globals.numReallocs);
fprintf(stderr, "Average allocation size %d bytes\n",
globals.totalAlloc/globals.numMallocs);
- if (globals.used.head != NULL) {
+ if (globals.used.head) {
Memento_listBlocks();
Memento_breakpoint();
}
@@ -937,7 +937,7 @@ int Memento_find(void *a)
data.blk = NULL;
data.flags = 0;
Memento_appBlocks(&globals.used, Memento_containsAddr, &data);
- if (data.blk != NULL) {
+ if (data.blk) {
fprintf(stderr, "Address 0x%p is in %sallocated block 0x%p(size=%d,num=%d)\n",
data.addr,
(data.flags == 1 ? "" : (data.flags == 2 ?
@@ -948,7 +948,7 @@ int Memento_find(void *a)
data.blk = NULL;
data.flags = 0;
Memento_appBlocks(&globals.free, Memento_containsAddr, &data);
- if (data.blk != NULL) {
+ if (data.blk) {
fprintf(stderr, "Address 0x%p is in %sfreed block 0x%p(size=%d,num=%d)\n",
data.addr,
(data.flags == 1 ? "" : (data.flags == 2 ?
diff --git a/fitz/res_font.c b/fitz/res_font.c
index 3fea732a..60374746 100644
--- a/fitz/res_font.c
+++ b/fitz/res_font.c
@@ -131,9 +131,9 @@ void fz_new_font_context(fz_context *ctx)
void fz_free_font_context(fz_context *ctx)
{
- if (ctx->font == NULL)
+ if (!ctx->font)
return;
- /* assert(ctx->ftlib == NULL); */
+ /* assert(!ctx->ftlib); */
/* assert(ctx->ftlib_refs == 0); */
fz_free(ctx, ctx->font);
}
@@ -147,7 +147,7 @@ char *ft_error_string(int err)
{
const struct ft_error *e;
- for (e = ft_errors; e->str != NULL; e++)
+ for (e = ft_errors; e->str; e++)
if (e->err == err)
return e->str;
@@ -553,7 +553,7 @@ fz_render_t3_glyph(fz_context *ctx, fz_font *font, int gid, fz_matrix trm, fz_co
}
else if (dev->flags & FZ_CHARPROC_COLOR)
{
- if (model == NULL)
+ if (!model)
fz_warn(ctx, "colored type3 glyph wanted in masked context");
}
else
@@ -579,7 +579,7 @@ fz_render_t3_glyph(fz_context *ctx, fz_font *font, int gid, fz_matrix trm, fz_co
fz_free_device(dev);
fz_free_glyph_cache(ctx, cache);
- if (model == NULL)
+ if (!model)
{
result = fz_alpha_from_gray(ctx, glyph, 0);
fz_drop_pixmap(ctx, glyph);
diff --git a/fitz/res_halftone.c b/fitz/res_halftone.c
index ad2ab694..b1b8d7b4 100644
--- a/fitz/res_halftone.c
+++ b/fitz/res_halftone.c
@@ -162,7 +162,7 @@ fz_bitmap *fz_halftone_pixmap(fz_context *ctx, fz_pixmap *pix, fz_halftone *ht)
unsigned char *ht_line, *o, *p;
int w, h, x, y, n, pstride, ostride;
- if (pix == NULL || ht == NULL)
+ if (!pix || !ht)
return NULL;
assert(pix->n == 2); /* Mono + Alpha */
diff --git a/fitz/res_path.c b/fitz/res_path.c
index cea720e9..894e25a8 100644
--- a/fitz/res_path.c
+++ b/fitz/res_path.c
@@ -19,7 +19,7 @@ fz_clone_path(fz_context *ctx, fz_path *old)
{
fz_path *path;
- assert(old != NULL);
+ assert(old);
path = fz_malloc(ctx, sizeof(fz_path));
path->len = old->len;
path->cap = old->len;
diff --git a/fitz/stm_buffer.c b/fitz/stm_buffer.c
index 8eb2bedf..2722be1a 100644
--- a/fitz/stm_buffer.c
+++ b/fitz/stm_buffer.c
@@ -26,7 +26,7 @@ fz_keep_buffer(fz_buffer *buf)
void
fz_drop_buffer(fz_context *ctx, fz_buffer *buf)
{
- if (buf == NULL)
+ if (!buf)
return;
if (--buf->refs == 0)
{
diff --git a/fitz/stm_open.c b/fitz/stm_open.c
index 9f657f27..eade9788 100644
--- a/fitz/stm_open.c
+++ b/fitz/stm_open.c
@@ -41,7 +41,7 @@ fz_keep_stream(fz_stream *stm)
void
fz_close(fz_stream *stm)
{
- if (stm == NULL)
+ if (!stm)
return;
stm->refs --;
if (stm->refs == 0)