Re: [PATCH] Remove some useless declarations found by scan-build

"Bryce W. Harrington" <[email protected]>
Newsgroups gmane.comp.lib.cairo
Message-ID <[email protected]>
On Sat, May 03, 2014 at 09:55:06PM +0200, Sylvestre Ledru wrote:
> On 02/05/2014 21:42, Bryce W. Harrington wrote:
> > On Fri, May 02, 2014 at 07:21:37PM +0200, Sylvestre Ledru wrote:
> >> Hello,
> >>
> >> The attached patch removes some useless declarations found by scan-build
> >> http://clang-analyzer.llvm.org/
> >>
> >> Don't hesitate if you want me to split the patch.
> >>
> >> Thanks,
> >> Sylvestre
> > It's fine to have these collected into one patch.
> >
> > These all look like good cleanups.  By chance did you check 'make test'?
> Yes, my changes did not break any test.
> 
> > I have a couple suggestions below after reviewing the changes, but
> > they're minor.
> >
> Thanks. Here is the updated patch.

Thanks, applied.

Bryce
 
> Sylvestre
> 

> >From 57f9cff5ca94dd44815b1aaa8214663c0929730a Mon Sep 17 00:00:00 2001
> From: Sylvestre Ledru <[email protected]>
> Date: Fri, 2 May 2014 18:53:41 +0200
> Subject: [PATCH] Remove some useless declarations found by scan-build, the
>  LLVM/clang static analyzer
> 
> ---
>  src/cairo-contour.c                   |  1 -
>  src/cairo-ft-font.c                   |  2 --
>  src/cairo-path-stroke-polygon.c       | 10 ----------
>  src/cairo-xcb-connection-core.c       |  2 --
>  test/pdiff/lpyramid.c                 |  4 ++--
>  test/tighten-bounds.c                 |  2 +-
>  util/cairo-script/cairo-script-file.c |  1 -
>  7 files changed, 3 insertions(+), 19 deletions(-)
> 
> diff --git a/src/cairo-contour.c b/src/cairo-contour.c
> index d356f4f..9ad75bd 100644
> --- a/src/cairo-contour.c
> +++ b/src/cairo-contour.c
> @@ -332,7 +332,6 @@ _cairo_contour_simplify (cairo_contour_t *contour, double tolerance)
>      }
>  
>      /* stage2: polygon simplification using Douglas-Peucker */
> -    simplified = FALSE;
>      do {
>  	last = &contour->chain.points[0];
>  	iter_init (&furthest, contour);
> diff --git a/src/cairo-ft-font.c b/src/cairo-ft-font.c
> index e0b0f22..59df4fc 100644
> --- a/src/cairo-ft-font.c
> +++ b/src/cairo-ft-font.c
> @@ -741,7 +741,6 @@ _compute_transform (cairo_ft_font_transform_t *sf,
>  	double min_distance = DBL_MAX;
>  	cairo_bool_t magnify = TRUE;
>  	int i;
> -	int best_i = 0;
>  	double best_x_size = 0;
>  	double best_y_size = 0;
>  
> @@ -760,7 +759,6 @@ _compute_transform (cairo_ft_font_transform_t *sf,
>  	    if ((magnify && distance >= 0) || fabs (distance) <= min_distance) {
>  		magnify = distance < 0;
>  		min_distance = fabs (distance);
> -		best_i = i;
>  		best_x_size = x_size;
>  		best_y_size = y_size;
>  	    }
> diff --git a/src/cairo-path-stroke-polygon.c b/src/cairo-path-stroke-polygon.c
> index 2c8fe5e..e5082bb 100644
> --- a/src/cairo-path-stroke-polygon.c
> +++ b/src/cairo-path-stroke-polygon.c
> @@ -1083,7 +1083,6 @@ spline_to (void *closure,
>      _cairo_contour_add_point (&stroker->path, point);
>  #endif
>      if ((tangent->dx | tangent->dy) == 0) {
> -	const cairo_point_t *inpt, *outpt;
>  	struct stroke_contour *outer;
>  	cairo_point_t t;
>  	int clockwise;
> @@ -1101,12 +1100,8 @@ spline_to (void *closure,
>  
>  	clockwise = join_is_clockwise (&stroker->current_face, &face);
>  	if (clockwise) {
> -	    inpt = &stroker->current_face.cw;
> -	    outpt = &face.cw;
>  	    outer = &stroker->cw;
>  	} else {
> -	    inpt = &stroker->current_face.ccw;
> -	    outpt = &face.ccw;
>  	    outer = &stroker->ccw;
>  	}
>  
> @@ -1121,7 +1116,6 @@ spline_to (void *closure,
>  	if ((face.dev_slope.x * stroker->current_face.dev_slope.x +
>  	     face.dev_slope.y * stroker->current_face.dev_slope.y) < stroker->spline_cusp_tolerance)
>  	{
> -	    const cairo_point_t *inpt, *outpt;
>  	    struct stroke_contour *outer;
>  	    int clockwise = join_is_clockwise (&stroker->current_face, &face);
>  
> @@ -1134,12 +1128,8 @@ spline_to (void *closure,
>  	    contour_add_point (stroker, &stroker->ccw, &stroker->current_face.ccw);
>  
>  	    if (clockwise) {
> -		inpt = &stroker->current_face.cw;
> -		outpt = &face.cw;
>  		outer = &stroker->cw;
>  	    } else {
> -		inpt = &stroker->current_face.ccw;
> -		outpt = &face.ccw;
>  		outer = &stroker->ccw;
>  	    }
>  	    add_fan (stroker,
> diff --git a/src/cairo-xcb-connection-core.c b/src/cairo-xcb-connection-core.c
> index 386297d..e01dc1a 100644
> --- a/src/cairo-xcb-connection-core.c
> +++ b/src/cairo-xcb-connection-core.c
> @@ -268,8 +268,6 @@ _cairo_xcb_connection_put_subimage (cairo_xcb_connection_t *connection,
>  		if (rows > height)
>  		    rows = height;
>  
> -		length = rows * cpp * width;
> -
>  		_cairo_xcb_connection_do_put_subimage (connection, dst, gc, src_x, src_y,
>  			width, rows, cpp, stride, dst_x, dst_y, depth, _data);
>  
> diff --git a/test/pdiff/lpyramid.c b/test/pdiff/lpyramid.c
> index aa57ca2..bd402c7 100644
> --- a/test/pdiff/lpyramid.c
> +++ b/test/pdiff/lpyramid.c
> @@ -111,6 +111,6 @@ lpyramid_get_value (lpyramid_t *pyramid, int x, int y, int level)
>      int index = x + y * pyramid->width;
>      int l = level;
>      if (l > MAX_PYR_LEVELS)
> -	l = MAX_PYR_LEVELS;
> -    return pyramid->levels[level][index];
> +        l = MAX_PYR_LEVELS;
> +    return pyramid->levels[l][index];
>  }
> diff --git a/test/tighten-bounds.c b/test/tighten-bounds.c
> index 02fc81a..f5430e4 100644
> --- a/test/tighten-bounds.c
> +++ b/test/tighten-bounds.c
> @@ -72,7 +72,7 @@ static void (* const path_funcs[])(cairo_t *cr, int size) = {
>  static void
>  draw_idx (cairo_t *cr, int i, int j, int type)
>  {
> -    cairo_bool_t little_path = type & (1 << 0);
> +    cairo_bool_t little_path;
>      cairo_bool_t empty_clip;
>      cairo_bool_t little_clip;
>  
> diff --git a/util/cairo-script/cairo-script-file.c b/util/cairo-script/cairo-script-file.c
> index c962fce..0274a3e 100644
> --- a/util/cairo-script/cairo-script-file.c
> +++ b/util/cairo-script/cairo-script-file.c
> @@ -1063,7 +1063,6 @@ _csi_file_as_string (csi_t *ctx,
>      unsigned int allocated;
>      csi_status_t status;
>  
> -    len = 0;
>      allocated = 16384;
>      bytes = _csi_alloc (ctx, allocated);
>      if (bytes == NULL)
> -- 
> 1.9.1
> 
-- 
cairo mailing list
[email protected]
http://lists.cairographics.org/mailman/listinfo/cairo
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.