[cairo-commit] 2 commits - src/cairo-bentley-ottmann-rectangular.c src/cairo-malloc-private.h src/cairo-png.c

Uli Schlachter psychon at kemper.freedesktop.org
Sat Jan 13 10:31:49 UTC 2018


 src/cairo-bentley-ottmann-rectangular.c |    4 +++-
 src/cairo-malloc-private.h              |    2 +-
 src/cairo-png.c                         |    6 +++---
 3 files changed, 7 insertions(+), 5 deletions(-)

New commits:
commit b7f313a8d2a3049e77b3497dd6040fcfab3b3c9b
Author: Uli Schlachter <psychon at znc.in>
Date:   Sat Dec 23 14:09:27 2017 +0100

    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 at znc.in>
    Acked-by: Bryce Harrington <bryce at osg.samsung.com>

diff --git a/src/cairo-bentley-ottmann-rectangular.c b/src/cairo-bentley-ottmann-rectangular.c
index 29f902c1a..65f95d797 100644
--- a/src/cairo-bentley-ottmann-rectangular.c
+++ b/src/cairo-bentley-ottmann-rectangular.c
@@ -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) {
diff --git a/src/cairo-png.c b/src/cairo-png.c
index 596b506ab..ab0b9d0c5 100644
--- a/src/cairo-png.c
+++ b/src/cairo-png.c
@@ -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;
commit 62f2037bc06a8eda1aa5ff66b45ce9e8bafe0a9c
Author: Uli Schlachter <psychon at znc.in>
Date:   Sat Dec 23 13:22:59 2017 +0100

    Fix warning: '*' in boolean context
    
    The full message is:
    
      warning: ‘*’ in boolean context, suggest ‘&&’ instead
          _cairo_malloc((unsigned) (a) * (unsigned) (size)))
                                       ^
      note: in definition of macro ‘_cairo_malloc’
          ((size) ? malloc((unsigned) (size)) : NULL)
            ^~~~
    
    Signed-off-by: Uli Schlachter <psychon at znc.in>
    Reviewed-by: Bryce Harrington <bryce at osg.samsung.com>

diff --git a/src/cairo-malloc-private.h b/src/cairo-malloc-private.h
index 1e2c67f8d..570f7cb0e 100644
--- a/src/cairo-malloc-private.h
+++ b/src/cairo-malloc-private.h
@@ -60,7 +60,7 @@
  **/
 
 #define _cairo_malloc(size) \
-   ((size) ? malloc((unsigned) (size)) : NULL)
+   ((size) > 0 ? malloc((unsigned) (size)) : NULL)
 
 /**
  * _cairo_malloc_ab:


More information about the cairo-commit mailing list