changeset 24116:e1020353fff5

qz: initialize optional ordering flag safely * qz.cc (Fqz): Initialize optional ordering flag safely so it always has a valid value. Add input validation check for empty string. Silences clang compiler warning -Wsometimes-uninitialized.
author Mike Miller <mtmiller@octave.org>
date Thu, 28 Sep 2017 15:55:21 -0700
parents 8e3aeaf49551
children 01df6b5209f4
files libinterp/corefcn/qz.cc
diffstat 1 files changed, 7 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/corefcn/qz.cc	Thu Sep 28 15:51:20 2017 -0700
+++ b/libinterp/corefcn/qz.cc	Thu Sep 28 15:55:21 2017 -0700
@@ -252,17 +252,17 @@
 
   // Determine ordering option.
   // declared volatile to avoid compiler warnings about long jumps vforks.
-  volatile char ord_job;
-  double safmin;
+  volatile char ord_job = 'N';
+  double safmin = 0.0;
 
-  if (nargin == 2)
-    ord_job = 'N';
-  else
+  if (nargin == 3)
     {
       std::string opt = args(2).xstring_value ("qz: OPT must be a string");
 
-      if (! opt.empty ())
-        ord_job = std::toupper (opt[0]);
+      if (opt.empty ())
+        error ("qz: OPT must be a non-empty string");
+
+      ord_job = std::toupper (opt[0]);
 
       std::string valid_opts = "NSB+-";