summaryrefslogtreecommitdiff
path: root/cord
diff options
context:
space:
mode:
authorIvan Maidanski <ivmai@mail.ru>2019-10-04 23:43:09 +0300
committerIvan Maidanski <ivmai@mail.ru>2019-10-04 23:43:09 +0300
commitb0d0fafc346fd2b205f268ec6c40413dfdca9934 (patch)
treef28ce7c4646c4e6a9f06cf740de7d362676b451b /cord
parent890ad2c9930458392e19bba7964c69a405b6d3e0 (diff)
downloadbdwgc-b0d0fafc346fd2b205f268ec6c40413dfdca9934.tar.gz
Workaround 'condition is redundant or null deref is possible' cppcheck FP
* cord/cordprnt.c (MACRO_BLKSTMT_BEGIN, MACRO_BLKSTMT_END): New macro. * cord/tests/de.c (MACRO_BLKSTMT_BEGIN, MACRO_BLKSTMT_END): Likewise. * include/private/gc_priv.h (MACRO_BLKSTMT_BEGIN, MACRO_BLKSTMT_END): Likewise. * cord/cordprnt.c (OUT_OF_MEMORY): Use MACRO_BLKSTMT_BEGIN/END instead of "do {" and "} while (0)". * cord/tests/de.c (OUT_OF_MEMORY): Likewise. * include/private/gc_priv.h (ABORT_ARG1, ABORT_ARG2, ABORT_ARG3): Likewise.
Diffstat (limited to 'cord')
-rw-r--r--cord/cordprnt.c11
-rw-r--r--cord/tests/de.c12
2 files changed, 19 insertions, 4 deletions
diff --git a/cord/cordprnt.c b/cord/cordprnt.c
index 7eaf3723..70972af8 100644
--- a/cord/cordprnt.c
+++ b/cord/cordprnt.c
@@ -43,12 +43,19 @@
#define CONV_RESULT_LEN 50 /* Maximum length of any */
/* conversion with default */
/* width and prec. */
+#if defined(CPPCHECK)
+# define MACRO_BLKSTMT_BEGIN {
+# define MACRO_BLKSTMT_END }
+#else
+# define MACRO_BLKSTMT_BEGIN do {
+# define MACRO_BLKSTMT_END } while (0)
+#endif
-#define OUT_OF_MEMORY do { \
+#define OUT_OF_MEMORY MACRO_BLKSTMT_BEGIN \
if (CORD_oom_fn != 0) (*CORD_oom_fn)(); \
fprintf(stderr, "Out of memory\n"); \
abort(); \
- } while (0)
+ MACRO_BLKSTMT_END
static int ec_len(CORD_ec x)
{
diff --git a/cord/tests/de.c b/cord/tests/de.c
index f69edde2..9f554d19 100644
--- a/cord/tests/de.c
+++ b/cord/tests/de.c
@@ -75,10 +75,18 @@
#endif
#include "de_cmds.h"
-#define OUT_OF_MEMORY do { \
+#if defined(CPPCHECK)
+# define MACRO_BLKSTMT_BEGIN {
+# define MACRO_BLKSTMT_END }
+#else
+# define MACRO_BLKSTMT_BEGIN do {
+# define MACRO_BLKSTMT_END } while (0)
+#endif
+
+#define OUT_OF_MEMORY MACRO_BLKSTMT_BEGIN \
fprintf(stderr, "Out of memory\n"); \
exit(3); \
- } while (0)
+ MACRO_BLKSTMT_END
/* List of line number to position mappings, in descending order. */
/* There may be holes. */