Fix errors found by clang

Shadowed variables, unused writes and some dead code.
This commit is contained in:
Chris Wilson 2009-08-16 14:20:35 +01:00
parent d8dbce021a
commit 8d1bf830c0
5 changed files with 29 additions and 25 deletions

View file

@ -1963,8 +1963,6 @@ _cairo_pdf_surface_emit_image (cairo_pdf_surface_t *surface,
#undef IMAGE_DICTIONARY
if (image_res == NULL)
*image_res = surface->pdf_stream.self;
_cairo_output_stream_write (surface->output, rgb, rgb_size);
status = _cairo_pdf_surface_close_stream (surface);

View file

@ -822,7 +822,7 @@ _get_image_surface (cairo_xlib_surface_t *surface,
int a_width=0, r_width=0, g_width=0, b_width=0;
int a_shift=0, r_shift=0, g_shift=0, b_shift=0;
int x, y, x0, y0, x_off, y_off;
cairo_xlib_visual_info_t *visual_info;
cairo_xlib_visual_info_t *visual_info = NULL;
if (surface->visual == NULL || surface->visual->class == TrueColor) {
cairo_bool_t has_alpha;
@ -888,7 +888,7 @@ _get_image_surface (cairo_xlib_surface_t *surface,
int dither_adjustment = dither_row[x_off];
in_pixel = XGetPixel (ximage, x, y);
if (surface->visual == NULL || surface->visual->class == TrueColor) {
if (visual_info == NULL) {
out_pixel = (
_field_to_8 (in_pixel & a_mask, a_width, a_shift) << 24 |
_field_to_8_undither (in_pixel & r_mask, r_width, r_shift, dither_adjustment) << 16 |
@ -4141,7 +4141,6 @@ _emit_glyphs_chunk (cairo_xlib_surface_t *dst,
if (n) {
elts[nelt].nchars = n;
nelt++;
n = 0;
}
/* Check that we agree with _cairo_xlib_surface_emit_glyphs() on the

View file

@ -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:

View file

@ -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) {

View file

@ -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 ();
}