[cairo] [PATCH] Remove some useless declarations found by scan-build
Bryce W. Harrington
b.harrington at samsung.com
Fri May 2 12:42:33 PDT 2014
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'?
I have a couple suggestions below after reviewing the changes, but
they're minor.
Reviewed-by: Bryce Harrington <b.harrington at samsung.com>
> 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 | 3 ---
> test/tighten-bounds.c | 2 +-
> util/cairo-script/cairo-script-file.c | 1 -
> 7 files changed, 1 insertion(+), 20 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..fbe10c0 100644
> --- a/test/pdiff/lpyramid.c
> +++ b/test/pdiff/lpyramid.c
> @@ -109,8 +109,5 @@ float
> 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];
I suspect the intention here was to use l rather than level on the
return line. Let's make this code:
float
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[l][index];
}
Although I wonder if it'd be better to just stick an assert in there.
> }
> 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..85ce533 100644
> --- a/util/cairo-script/cairo-script-file.c
> +++ b/util/cairo-script/cairo-script-file.c
> @@ -1069,7 +1069,6 @@ _csi_file_as_string (csi_t *ctx,
> if (bytes == NULL)
> return _csi_error (CAIRO_STATUS_NO_MEMORY);
> - len = 0;
> do {
> int ret;
There are two `len = 0;` and I agree they're redundant. But let's keep
this one and drop the earlier one on line 1066. This initialization is
closer to where len is actually used.
--
2.0.0.rc0
More information about the cairo
mailing list