changeset 26372:2d9ae06f621b stable

Fix static analyzer detected V1003 issues with expansions in macros (bug #55347). * Table.cc (AUTO_HEIGHT): Wrap entire macro expression in parentheses. * ls-oct-text.cc: (SUBSTRING_COMPARE_EQ): Wrap parameter "t" in parentheses. * variables.cc (GET_IDX): Wrap parameter "LEN" in parentheses. * mx-inlines.cc (OP_RED_SUMSQ): Wrap expression "el*el" in parentheses.
author Rik <rik@octave.org>
date Wed, 02 Jan 2019 11:44:09 -0800
parents 87f11da73b19
children 5b4b46f7e9ec
files libgui/graphics/Table.cc libinterp/corefcn/ls-oct-text.cc libinterp/corefcn/variables.cc liboctave/operators/mx-inlines.cc
diffstat 4 files changed, 4 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/libgui/graphics/Table.cc	Wed Jan 02 10:54:48 2019 -0800
+++ b/libgui/graphics/Table.cc	Wed Jan 02 11:44:09 2019 -0800
@@ -56,7 +56,7 @@
 
   static const int AUTO_WIDTH = 75;
 
-#define AUTO_HEIGHT tp.get_fontsize () * 2 - 1
+#define AUTO_HEIGHT (tp.get_fontsize () * 2 - 1)
 
   static QSize realQSizeForTable (QTableWidget *t)
   {
--- a/libinterp/corefcn/ls-oct-text.cc	Wed Jan 02 10:54:48 2019 -0800
+++ b/libinterp/corefcn/ls-oct-text.cc	Wed Jan 02 11:44:09 2019 -0800
@@ -232,7 +232,7 @@
 // Ugh.  The signature of the compare method is not standard in older
 // versions of the GNU libstdc++.  Do this instead:
 
-#define SUBSTRING_COMPARE_EQ(s, pos, n, t) (s.substr (pos, n) == t)
+#define SUBSTRING_COMPARE_EQ(s, pos, n, t) (s.substr (pos, n) == (t))
 
 std::string
 read_text_data (std::istream& is, const std::string& filename, bool& global,
--- a/libinterp/corefcn/variables.cc	Wed Jan 02 10:54:48 2019 -0800
+++ b/libinterp/corefcn/variables.cc	Wed Jan 02 11:44:09 2019 -0800
@@ -333,7 +333,7 @@
 
 
 #define GET_IDX(LEN)                                                    \
-  static_cast<int> ((LEN-1) * static_cast<double> (rand ()) / RAND_MAX)
+  static_cast<int> (((LEN)-1) * static_cast<double> (rand ()) / RAND_MAX)
 
 std::string
 unique_symbol_name (const std::string& basename)
--- a/liboctave/operators/mx-inlines.cc	Wed Jan 02 10:54:48 2019 -0800
+++ b/liboctave/operators/mx-inlines.cc	Wed Jan 02 11:44:09 2019 -0800
@@ -672,7 +672,7 @@
 
 #define OP_RED_SUM(ac, el) ac += el
 #define OP_RED_PROD(ac, el) ac *= el
-#define OP_RED_SUMSQ(ac, el) ac += el*el
+#define OP_RED_SUMSQ(ac, el) ac += (el*el)
 #define OP_RED_SUMSQC(ac, el) ac += cabsq (el)
 
 inline void