summaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2009-08-16 14:20:35 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2009-08-29 08:08:39 +0100
commit8d1bf830c0137eac837091bda92a636c0fcb0456 (patch)
tree2ecde17e863ad39bb7a010007c5af1046b470c26 /util
parentd8dbce021a4493330864154e67ca6e4a1f2f50b2 (diff)
Fix errors found by clang
Shadowed variables, unused writes and some dead code.
Diffstat (limited to 'util')
-rw-r--r--util/cairo-script/cairo-script-file.c10
-rw-r--r--util/cairo-script/cairo-script-operators.c23
-rw-r--r--util/cairo-trace/trace.c14
3 files changed, 27 insertions, 20 deletions
diff --git a/util/cairo-script/cairo-script-file.c b/util/cairo-script/cairo-script-file.c
index 9ebfdafb..5779db59 100644
--- a/util/cairo-script/cairo-script-file.c
+++ b/util/cairo-script/cairo-script-file.c
@@ -316,8 +316,7 @@ _ascii85_decode (csi_file_t *file)
data->buf[n+2] = 0;
data->buf[n+3] = 0;
} else if (v == '~') {
- v = _getc_skip_whitespace (file->src);
- /* c == '>' || IO_ERROR */
+ _getc_skip_whitespace (file->src); /* == '>' || IO_ERROR */
data->eod = TRUE;
break;
} else if (v < '!' || v > 'u') {
@@ -331,8 +330,7 @@ _ascii85_decode (csi_file_t *file)
for (i = 1; i < 5; i++) {
int c = _getc_skip_whitespace (file->src);
if (c == '~') { /* short tuple */
- c = _getc_skip_whitespace (file->src);
- /* c == '>' || IO_ERROR */
+ _getc_skip_whitespace (file->src); /* == '>' || IO_ERROR */
data->eod = TRUE;
switch (i) {
case 0:
@@ -958,14 +956,12 @@ csi_file_putc (csi_file_t *file, int c)
void
csi_file_flush (csi_file_t *file)
{
- int c;
-
if (file->src == NULL)
return;
switch ((int) file->type) {
case FILTER: /* need to eat EOD */
- while ((c = csi_file_getc (file)) != EOF)
+ while (csi_file_getc (file) != EOF)
;
break;
default:
diff --git a/util/cairo-script/cairo-script-operators.c b/util/cairo-script/cairo-script-operators.c
index 9d55d871..a11c7c60 100644
--- a/util/cairo-script/cairo-script-operators.c
+++ b/util/cairo-script/cairo-script-operators.c
@@ -1937,6 +1937,9 @@ _ft_type42_create (csi_t *ctx,
/* two basic sub-types, either an FcPattern or embedded font */
status = csi_name_new_static (ctx, &key, "pattern");
+ if (_csi_unlikely (status))
+ return status;
+
if (csi_dictionary_has (font, key.datum.name)) {
csi_object_t obj;
int type;
@@ -2512,7 +2515,7 @@ _glyph_path (csi_t *ctx)
/* count glyphs */
nglyphs = 0;
for (i = 0; i < array->stack.len; i++) {
- csi_object_t *obj = obj = &array->stack.objects[i];
+ csi_object_t *obj = &array->stack.objects[i];
int type = csi_object_get_type (obj);
switch (type) {
case CSI_OBJECT_TYPE_ARRAY:
@@ -2700,11 +2703,10 @@ _image_read_raw (csi_file_t *src,
case CAIRO_FORMAT_RGB24:
len = 3 * width * height;
break;
+ default:
case CAIRO_FORMAT_ARGB32:
len = 4 * width * height;
break;
- default:
- break;
}
stride = cairo_image_surface_get_stride (image);
@@ -2973,8 +2975,11 @@ _image_load_from_dictionary (csi_t *ctx,
return status;
status = csi_name_new_static (ctx, &key, "source");
+ if (_csi_unlikely (status))
+ return status;
+
if (csi_dictionary_has (dict, key.datum.name)) {
- enum mime_type type;
+ enum mime_type mime_type;
csi_object_t file;
status = csi_dictionary_get (ctx, dict, key.datum.name, &obj);
@@ -2985,7 +2990,7 @@ _image_load_from_dictionary (csi_t *ctx,
if (_csi_unlikely (status))
return status;
- type = MIME_TYPE_NONE;
+ mime_type = MIME_TYPE_NONE;
if (csi_dictionary_has (dict, key.datum.name)) {
csi_object_t type_obj;
const char *type_str;
@@ -3008,7 +3013,7 @@ _image_load_from_dictionary (csi_t *ctx,
}
if (strcmp (type_str, CAIRO_MIME_TYPE_PNG) == 0)
- type = MIME_TYPE_PNG;
+ mime_type = MIME_TYPE_PNG;
}
status = csi_object_as_file (ctx, &obj, &file);
@@ -3017,7 +3022,7 @@ _image_load_from_dictionary (csi_t *ctx,
/* XXX hook for general mime-type decoder */
- switch (type) {
+ switch (mime_type) {
case MIME_TYPE_NONE:
status = _image_read_raw (file.datum.file,
format, width, height, &image);
@@ -5406,6 +5411,10 @@ _surface (csi_t *ctx)
}
if (csi_dictionary_has (dict, key.datum.name)) {
status = csi_dictionary_get (ctx, dict, key.datum.name, &obj);
+ if (_csi_unlikely (status)) {
+ cairo_surface_destroy (surface);
+ return status;
+ }
if (csi_object_get_type (&obj) == CSI_OBJECT_TYPE_ARRAY) {
csi_array_t *array = obj.datum.array;
if (array->stack.len == 2) {
diff --git a/util/cairo-trace/trace.c b/util/cairo-trace/trace.c
index 20c85557..8298b943 100644
--- a/util/cairo-trace/trace.c
+++ b/util/cairo-trace/trace.c
@@ -2565,7 +2565,7 @@ cairo_get_font_face (cairo_t *cr)
ret = DLCALL (cairo_get_font_face, cr);
font_face_id = _create_font_face_id (ret);
- _emit_cairo_op (cr, "/font-face get\n");
+ _emit_cairo_op (cr, "/font-face get %% f%ld\n", font_face_id);
_push_operand (FONT_FACE, ret);
return ret;
@@ -3164,10 +3164,11 @@ cairo_surface_create_similar (cairo_surface_t *other,
_trace_printf ("dup ");
else
_trace_printf ("%d index ", current_stack_depth - obj->operand - 1);
- _trace_printf ("%d %d //%s similar\n",
+ _trace_printf ("%d %d //%s similar %% s%ld\n",
width,
height,
- _content_to_string (content));
+ _content_to_string (content),
+ surface_id);
_push_operand (SURFACE, ret);
_write_unlock ();
@@ -3575,7 +3576,8 @@ cairo_ft_font_face_create_for_pattern (FcPattern *pattern)
" /pattern ");
_emit_string_literal ((char *) parsed, -1);
_trace_printf (" set\n"
- " font\n");
+ " font %% f%ld\n",
+ font_face_id);
_push_operand (FONT_FACE, ret);
_write_unlock ();
@@ -3627,8 +3629,8 @@ cairo_ft_font_face_create_for_ft_face (FT_Face face, int load_flags)
_trace_printf ("<< /type 42 /source ");
_emit_data (data->data, data->size);
- _trace_printf (" /index %lu /flags %d >> font\n",
- data->index, load_flags);
+ _trace_printf (" /index %lu /flags %d >> font %% f%ld\n",
+ data->index, load_flags, font_face_id);
_push_operand (FONT_FACE, ret);
_write_unlock ();
}