icoutils/0013-common-common.h-Introduce-more-hygenic-definitions-o.patch
Richard W.M. Jones 86a1ed311e Add a series of upstream patches to enable compiler warnings and
fix multiple issues.

Revert one of the checks which breaks processing of PE binaries.

Removed the 'Group' line, not needed with modern Fedora/RPM.
2017-03-10 12:18:04 +00:00

72 lines
2.7 KiB
Diff
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

From 7cfc16ecf4727dd0eef1b2d7bfc385435f917c06 Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Thu, 9 Mar 2017 13:57:27 +0000
Subject: [PATCH 13/26] common/common.h: Introduce (more) hygenic definitions
of SWAP, min and max macros.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
These contained declarations of variables which shadowed other
variable declarations in the main code, leading to warnings like those
shown below. I also modified the macros to use parens around all
expanded parameters, and added a comment explaining why the values are
copied to local variables.
In file included from ../common/string-utils.h:26:0,
from extract.c:46:
../common/common.h:29:31: error: declaration of c shadows a previous local [-Werror=shadow]
#define max(a,b) ({ typeof(a) c = a; typeof(b) d = b; MAX(c,d); })
^
extract.c:250:40: note: in expansion of macro max
if (abs(bitmap.width) > INT32_MAX/max(4, bitmap.bit_count)) {
^~~
extract.c:103:11: note: shadowed declaration is here
uint32_t c, d;
^
In file included from ../common/string-utils.h:26:0,
from extract.c:46:
../common/common.h:29:48: error: declaration of d shadows a previous local [-Werror=shadow]
#define max(a,b) ({ typeof(a) c = a; typeof(b) d = b; MAX(c,d); })
^
extract.c:250:40: note: in expansion of macro max
if (abs(bitmap.width) > INT32_MAX/max(4, bitmap.bit_count)) {
^~~
extract.c:103:14: note: shadowed declaration is here
uint32_t c, d;
^
Signed-off-by: Richard W.M. Jones <rjones@redhat.com>
Thanks: Dan Berrange
---
common/common.h | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/common/common.h b/common/common.h
index 5b9af14..e51455c 100644
--- a/common/common.h
+++ b/common/common.h
@@ -19,14 +19,16 @@
#ifndef COMMON_COMMON_H
#define COMMON_COMMON_H
-#define SWAP(a,b) ({ typeof(a) t = a; a = b; b = t; })
+#define SWAP(a,b) ({ typeof(a) _t = (a); a = (b); (b) = _t; })
+/* Variant of MIN which evaluates each parameter only once. */
#ifndef min
-#define min(a,b) ({ typeof(a) c = a; typeof(b) d = b; MIN(c,d); })
+#define min(a,b) ({ typeof(a) _c = (a); typeof(b) _d = (b); MIN(_c,_d); })
#endif
+/* Variant of MAX which evaluates each parameter only once. */
#ifndef max
-#define max(a,b) ({ typeof(a) c = a; typeof(b) d = b; MAX(c,d); })
+#define max(a,b) ({ typeof(a) _c = (a); typeof(b) _d = (b); MAX(_c,_d); })
#endif
#define RETURN_IF_DIFFERENT(i1,i2) \
--
2.10.2