[1/2] Fix warning: '*' in boolean context

Submitted by Uli Schlachter on Dec. 23, 2017, 1:16 p.m.

Details

Message ID 20171223131608.19011-1-psychon@znc.in
State New
Series "Series without cover letter"
Headers show

Commit Message

Uli Schlachter Dec. 23, 2017, 1:16 p.m.
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@znc.in>
---
 src/cairo-malloc-private.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Patch hide | download patch | download mbox

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:

Comments

Bryce Harrington Jan. 5, 2018, 1:51 a.m.
On Sat, Dec 23, 2017 at 02:16:07PM +0100, Uli Schlachter wrote:
> 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@znc.in>

Ah, tricky.

Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>

> ---
>  src/cairo-malloc-private.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> 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:
> -- 
> 2.15.1
> 
> -- 
> cairo mailing list
> cairo@cairographics.org
> https://lists.cairographics.org/mailman/listinfo/cairo