fix warning: variable X might be clobbered by 'longjmp'

According to "man setjmp", one possible way to avoid variable clobbering
is to declare them as volatile. Thus, this commit turns the variables
that are changed between setjmp() and longjmp() and whose values are
still needed after setjmp() returned the second time into volatile
variables.

The warning in cairo-bentley-ottmann-rectangular.c is worked around by
not initializing the variable before setjmp(). To be honest, I don't
understand why the compiler warns here at all since the value of update
is clearly not used after setjmp()'s second return.

This commit re-fixes the warnings that were reintroduced in commit
82f40285 which reverted b092b63.

Signed-off-by: Uli Schlachter <psychon@znc.in>
Acked-by: Bryce Harrington <bryce@osg.samsung.com>
This commit is contained in:
Uli Schlachter 2017-12-23 14:09:27 +01:00
parent 62f2037bc0
commit b7f313a8d2
2 changed files with 6 additions and 4 deletions

View file

@ -603,7 +603,7 @@ _cairo_bentley_ottmann_tessellate_rectangular (rectangle_t **rectangles,
sweep_line_t sweep_line;
rectangle_t *rectangle;
cairo_status_t status;
cairo_bool_t update = FALSE;
cairo_bool_t update;
sweep_line_init (&sweep_line,
rectangles, num_rectangles,
@ -612,6 +612,8 @@ _cairo_bentley_ottmann_tessellate_rectangular (rectangle_t **rectangles,
if ((status = setjmp (sweep_line.unwind)))
return status;
update = FALSE;
rectangle = rectangle_pop_start (&sweep_line);
do {
if (rectangle->top != sweep_line.current_y) {

View file

@ -544,11 +544,11 @@ stream_read_func (png_structp png, png_bytep data, png_size_t size)
static cairo_surface_t *
read_png (struct png_read_closure_t *png_closure)
{
cairo_surface_t *surface;
cairo_surface_t * volatile surface;
png_struct *png = NULL;
png_info *info;
png_byte *data = NULL;
png_byte **row_pointers = NULL;
png_byte * volatile data = NULL;
png_byte ** volatile row_pointers = NULL;
png_uint_32 png_width, png_height;
int depth, color_type, interlace, stride;
unsigned int i;