diff libinterp/corefcn/variables.cc @ 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 096b38cac97f
children 00f796120a6d f1a8a4aac3d4
line wrap: on
line diff
--- 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)