changeset 33041:ebc26cef3096

eliminate more obsolete volatile declarations Affected files: mex.cc, oct-hist.cc, oct-procbuf.cc, sighandlers.cc, sighandlers.h, profiler.cc, CMatrix.cc, CSparse.cc, dMatrix.cc, fCMatrix.cc, fMatrix.cc, fEIG.cc, schur.cc, and sparse-chol.cc.
author John W. Eaton <jwe@octave.org>
date Sat, 17 Feb 2024 11:51:15 -0500
parents c5057009c134
children 4c9dc46fae39 147c69ad945d
files libinterp/corefcn/mex.cc libinterp/corefcn/oct-hist.cc libinterp/corefcn/oct-procbuf.cc libinterp/corefcn/sighandlers.cc libinterp/corefcn/sighandlers.h libinterp/parse-tree/profiler.cc liboctave/array/CMatrix.cc liboctave/array/CSparse.cc liboctave/array/dMatrix.cc liboctave/array/fCMatrix.cc liboctave/array/fMatrix.cc liboctave/numeric/fEIG.cc liboctave/numeric/schur.cc liboctave/numeric/sparse-chol.cc
diffstat 14 files changed, 46 insertions(+), 53 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/corefcn/mex.cc	Fri Feb 16 22:58:13 2024 -0500
+++ b/libinterp/corefcn/mex.cc	Sat Feb 17 11:51:15 2024 -0500
@@ -4473,7 +4473,7 @@
   // Use at least 1 for nargout since even for zero specified args,
   // still want to be able to return an ans.
 
-  volatile int nargout = nargout_arg;
+  int nargout = nargout_arg;
 
   int nargin = args.length ();
   OCTAVE_LOCAL_BUFFER (mxArray *, argin, nargin);
--- a/libinterp/corefcn/oct-hist.cc	Fri Feb 16 22:58:13 2024 -0500
+++ b/libinterp/corefcn/oct-hist.cc	Sat Feb 17 11:51:15 2024 -0500
@@ -463,8 +463,7 @@
   // Ignore interrupts while we are off editing commands.  Should we
   // maybe avoid using system()?
 
-  volatile interrupt_handler old_interrupt_handler
-    = ignore_interrupts ();
+  interrupt_handler old_interrupt_handler = ignore_interrupts ();
 
   int status = sys::system (cmd);
 
--- a/libinterp/corefcn/oct-procbuf.cc	Fri Feb 16 22:58:13 2024 -0500
+++ b/libinterp/corefcn/oct-procbuf.cc	Sat Feb 17 11:51:15 2024 -0500
@@ -103,9 +103,9 @@
 
   int pipe_fds[2];
 
-  volatile int child_std_end = (mode & std::ios::in) ? 1 : 0;
+  int child_std_end = (mode & std::ios::in) ? 1 : 0;
 
-  volatile int parent_end, child_end;
+  int parent_end, child_end;
 
   if (is_open ())
     return nullptr;
--- a/libinterp/corefcn/sighandlers.cc	Fri Feb 16 22:58:13 2024 -0500
+++ b/libinterp/corefcn/sighandlers.cc	Sat Feb 17 11:51:15 2024 -0500
@@ -203,8 +203,7 @@
               || (have_sigcld && sig == sigcld))
             {
               // FIXME: should we block or ignore?
-              volatile interrupt_handler saved_interrupt_handler
-                = ignore_interrupts ();
+              interrupt_handler saved_interrupt_handler = ignore_interrupts ();
 
               void *context = octave_block_child ();
 
@@ -346,8 +345,7 @@
 }
 
 interrupt_handler
-set_interrupt_handler (const volatile interrupt_handler& h,
-                       bool restart_syscalls)
+set_interrupt_handler (const interrupt_handler& h, bool restart_syscalls)
 {
   interrupt_handler retval;
 
--- a/libinterp/corefcn/sighandlers.h	Fri Feb 16 22:58:13 2024 -0500
+++ b/libinterp/corefcn/sighandlers.h	Sat Feb 17 11:51:15 2024 -0500
@@ -77,7 +77,7 @@
 extern OCTINTERP_API interrupt_handler ignore_interrupts ();
 
 extern OCTINTERP_API interrupt_handler
-set_interrupt_handler (const volatile interrupt_handler& h,
+set_interrupt_handler (const interrupt_handler& h,
                        bool restart_syscalls = true);
 
 // TRUE means we should try to enter the debugger on SIGINT.
--- a/libinterp/parse-tree/profiler.cc	Fri Feb 16 22:58:13 2024 -0500
+++ b/libinterp/parse-tree/profiler.cc	Sat Feb 17 11:51:15 2024 -0500
@@ -364,11 +364,7 @@
 {
   sys::time now;
 
-  // FIXME: is this volatile declaration really needed?
-  // See bug #34210 for additional details.
-  volatile double dnow = now.double_value ();
-
-  return dnow;
+  return now.double_value ();
 }
 
 void
--- a/liboctave/array/CMatrix.cc	Fri Feb 16 22:58:13 2024 -0500
+++ b/liboctave/array/CMatrix.cc	Sat Feb 17 11:51:15 2024 -0500
@@ -1206,7 +1206,7 @@
   if (nr != nc)
     (*current_liboctave_error_handler) ("matrix must be square");
 
-  volatile int typ = mattype.type ();
+  int typ = mattype.type ();
 
   // Even though the matrix is marked as singular (Rectangular), we may
   // still get a useful number from the LU factorization, because it always
@@ -1367,7 +1367,7 @@
     rcon = octave::numeric_limits<double>::Inf ();
   else
     {
-      volatile int typ = mattype.type ();
+      int typ = mattype.type ();
 
       if (typ == MatrixType::Unknown)
         typ = mattype.type (*this);
@@ -1544,7 +1544,7 @@
     retval = ComplexMatrix (nc, b_nc, Complex (0.0, 0.0));
   else
     {
-      volatile int typ = mattype.type ();
+      int typ = mattype.type ();
 
       if (typ != MatrixType::Permuted_Upper && typ != MatrixType::Upper)
         (*current_liboctave_error_handler) ("incorrect matrix type");
@@ -1642,7 +1642,7 @@
     retval = ComplexMatrix (nc, b_nc, Complex (0.0, 0.0));
   else
     {
-      volatile int typ = mattype.type ();
+      int typ = mattype.type ();
 
       if (typ != MatrixType::Permuted_Lower && typ != MatrixType::Lower)
         (*current_liboctave_error_handler) ("incorrect matrix type");
@@ -1740,7 +1740,7 @@
     retval = ComplexMatrix (nc, b_nc, Complex (0.0, 0.0));
   else
     {
-      volatile int typ = mattype.type ();
+      int typ = mattype.type ();
 
       // Calculate the norm of the matrix for later use when determining rcon.
       double anorm = -1.0;
@@ -2294,7 +2294,7 @@
     retval = ComplexMatrix (n, b_nc, Complex (0.0, 0.0));
   else
     {
-      volatile F77_INT minmn = (m < n ? m : n);
+      F77_INT minmn = (m < n ? m : n);
       F77_INT maxmn = (m > n ? m : n);
       rcon = -1.0;
 
@@ -2521,7 +2521,7 @@
     retval = ComplexColumnVector (n, Complex (0.0, 0.0));
   else
     {
-      volatile F77_INT minmn = (m < n ? m : n);
+      F77_INT minmn = (m < n ? m : n);
       F77_INT maxmn = (m > n ? m : n);
       rcon = -1.0;
 
--- a/liboctave/array/CSparse.cc	Fri Feb 16 22:58:13 2024 -0500
+++ b/liboctave/array/CSparse.cc	Sat Feb 17 11:51:15 2024 -0500
@@ -3661,7 +3661,7 @@
   else
     {
       // Print spparms("spumoni") info if requested
-      volatile int typ = mattype.type ();
+      int typ = mattype.type ();
       mattype.info ();
 
       if (typ == MatrixType::Tridiagonal_Hermitian)
--- a/liboctave/array/dMatrix.cc	Fri Feb 16 22:58:13 2024 -0500
+++ b/liboctave/array/dMatrix.cc	Sat Feb 17 11:51:15 2024 -0500
@@ -891,7 +891,7 @@
   if (nr != nc)
     (*current_liboctave_error_handler) ("matrix must be square");
 
-  volatile int typ = mattype.type ();
+  int typ = mattype.type ();
 
   // Even though the matrix is marked as singular (Rectangular), we may still
   // get a useful number from the LU factorization, because it always completes.
@@ -1046,7 +1046,7 @@
     rcon = octave::numeric_limits<double>::Inf ();
   else
     {
-      volatile int typ = mattype.type ();
+      int typ = mattype.type ();
 
       if (typ == MatrixType::Unknown)
         typ = mattype.type (*this);
@@ -1215,7 +1215,7 @@
     retval = Matrix (nc, b_nc, 0.0);
   else
     {
-      volatile int typ = mattype.type ();
+      int typ = mattype.type ();
 
       if (typ != MatrixType::Permuted_Upper && typ != MatrixType::Upper)
         (*current_liboctave_error_handler) ("incorrect matrix type");
@@ -1313,7 +1313,7 @@
     retval = Matrix (nc, b_nc, 0.0);
   else
     {
-      volatile int typ = mattype.type ();
+      int typ = mattype.type ();
 
       if (typ != MatrixType::Permuted_Lower && typ != MatrixType::Lower)
         (*current_liboctave_error_handler) ("incorrect matrix type");
@@ -1407,7 +1407,7 @@
     retval = Matrix (nc, b.cols (), 0.0);
   else
     {
-      volatile int typ = mattype.type ();
+      int typ = mattype.type ();
 
       // Calculate the norm of the matrix for later use when determining rcon.
       double anorm = -1.0;
@@ -1944,7 +1944,7 @@
     retval = Matrix (n, b_nc, 0.0);
   else
     {
-      volatile F77_INT minmn = (m < n ? m : n);
+      F77_INT minmn = (m < n ? m : n);
       F77_INT maxmn = (m > n ? m : n);
       rcon = -1.0;
       if (m != n)
@@ -2166,7 +2166,7 @@
     retval = ColumnVector (n, 0.0);
   else
     {
-      volatile F77_INT minmn = (m < n ? m : n);
+      F77_INT minmn = (m < n ? m : n);
       F77_INT maxmn = (m > n ? m : n);
       rcon = -1.0;
 
--- a/liboctave/array/fCMatrix.cc	Fri Feb 16 22:58:13 2024 -0500
+++ b/liboctave/array/fCMatrix.cc	Sat Feb 17 11:51:15 2024 -0500
@@ -1209,7 +1209,7 @@
   if (nr != nc)
     (*current_liboctave_error_handler) ("matrix must be square");
 
-  volatile int typ = mattype.type ();
+  int typ = mattype.type ();
 
   // Even though the matrix is marked as singular (Rectangular), we may
   // still get a useful number from the LU factorization, because it always
@@ -1370,7 +1370,7 @@
     rcon = octave::numeric_limits<float>::Inf ();
   else
     {
-      volatile int typ = mattype.type ();
+      int typ = mattype.type ();
 
       if (typ == MatrixType::Unknown)
         typ = mattype.type (*this);
@@ -1546,7 +1546,7 @@
     retval = FloatComplexMatrix (nc, b_nc, FloatComplex (0.0, 0.0));
   else
     {
-      volatile int typ = mattype.type ();
+      int typ = mattype.type ();
 
       if (typ == MatrixType::Permuted_Upper || typ == MatrixType::Upper)
         {
@@ -1648,7 +1648,7 @@
     retval = FloatComplexMatrix (nc, b_nc, FloatComplex (0.0, 0.0));
   else
     {
-      volatile int typ = mattype.type ();
+      int typ = mattype.type ();
 
       if (typ == MatrixType::Permuted_Lower || typ == MatrixType::Lower)
         {
@@ -1750,7 +1750,7 @@
     retval = FloatComplexMatrix (nc, b_nc, FloatComplex (0.0, 0.0));
   else
     {
-      volatile int typ = mattype.type ();
+      int typ = mattype.type ();
 
       // Calculate the norm of the matrix for later use when determining rcon.
       float anorm = -1.0;
@@ -2320,7 +2320,7 @@
     retval = FloatComplexMatrix (n, b_nc, FloatComplex (0.0, 0.0));
   else
     {
-      volatile F77_INT minmn = (m < n ? m : n);
+      F77_INT minmn = (m < n ? m : n);
       F77_INT maxmn = (m > n ? m : n);
       rcon = -1.0;
 
@@ -2550,7 +2550,7 @@
     retval = FloatComplexColumnVector (n, FloatComplex (0.0, 0.0));
   else
     {
-      volatile F77_INT minmn = (m < n ? m : n);
+      F77_INT minmn = (m < n ? m : n);
       F77_INT maxmn = (m > n ? m : n);
       rcon = -1.0;
 
--- a/liboctave/array/fMatrix.cc	Fri Feb 16 22:58:13 2024 -0500
+++ b/liboctave/array/fMatrix.cc	Sat Feb 17 11:51:15 2024 -0500
@@ -899,7 +899,7 @@
   if (nr != nc)
     (*current_liboctave_error_handler) ("matrix must be square");
 
-  volatile int typ = mattype.type ();
+  int typ = mattype.type ();
 
   // Even though the matrix is marked as singular (Rectangular), we may
   // still get a useful number from the LU factorization, because it always
@@ -1055,7 +1055,7 @@
     rcon = octave::numeric_limits<float>::Inf ();
   else
     {
-      volatile int typ = mattype.type ();
+      int typ = mattype.type ();
 
       if (typ == MatrixType::Unknown)
         typ = mattype.type (*this);
@@ -1225,7 +1225,7 @@
     retval = FloatMatrix (nc, b_nc, 0.0);
   else
     {
-      volatile int typ = mattype.type ();
+      int typ = mattype.type ();
 
       if (typ == MatrixType::Permuted_Upper || typ == MatrixType::Upper)
         {
@@ -1328,7 +1328,7 @@
     retval = FloatMatrix (nc, b_nc, 0.0);
   else
     {
-      volatile int typ = mattype.type ();
+      int typ = mattype.type ();
 
       if (typ == MatrixType::Permuted_Lower || typ == MatrixType::Lower)
         {
@@ -1430,7 +1430,7 @@
     retval = FloatMatrix (nc, b_nc, 0.0);
   else
     {
-      volatile int typ = mattype.type ();
+      int typ = mattype.type ();
 
       // Calculate the norm of the matrix for later use when determining rcon.
       float anorm = -1.0;
@@ -1970,7 +1970,7 @@
     retval = FloatMatrix (n, b_nc, 0.0);
   else
     {
-      volatile F77_INT minmn = (m < n ? m : n);
+      F77_INT minmn = (m < n ? m : n);
       F77_INT maxmn = (m > n ? m : n);
       rcon = -1.0;
       if (m != n)
@@ -2191,7 +2191,7 @@
     retval = FloatColumnVector (n, 0.0);
   else
     {
-      volatile F77_INT minmn = (m < n ? m : n);
+      F77_INT minmn = (m < n ? m : n);
       F77_INT maxmn = (m > n ? m : n);
       rcon = -1.0;
 
--- a/liboctave/numeric/fEIG.cc	Fri Feb 16 22:58:13 2024 -0500
+++ b/liboctave/numeric/fEIG.cc	Sat Feb 17 11:51:15 2024 -0500
@@ -62,11 +62,11 @@
   Array<float> wi (dim_vector (n, 1));
   float *pwi = wi.rwdata ();
 
-  volatile F77_INT nvr = (calc_rev ? n : 0);
+  F77_INT nvr = (calc_rev ? n : 0);
   FloatMatrix vr (nvr, nvr);
   float *pvr = vr.rwdata ();
 
-  volatile F77_INT nvl = (calc_lev ? n : 0);
+  F77_INT nvl = (calc_lev ? n : 0);
   FloatMatrix vl (nvl, nvl);
   float *pvl = vl.rwdata ();
 
@@ -434,11 +434,11 @@
   Array<float> beta (dim_vector (n, 1));
   float *pbeta = beta.rwdata ();
 
-  volatile F77_INT nvr = (calc_rev ? n : 0);
+  F77_INT nvr = (calc_rev ? n : 0);
   FloatMatrix vr (nvr, nvr);
   float *pvr = vr.rwdata ();
 
-  volatile F77_INT nvl = (calc_lev ? n : 0);
+  F77_INT nvl = (calc_lev ? n : 0);
   FloatMatrix vl (nvl, nvl);
   float *pvl = vl.rwdata ();
 
--- a/liboctave/numeric/schur.cc	Fri Feb 16 22:58:13 2024 -0500
+++ b/liboctave/numeric/schur.cc	Sat Feb 17 11:51:15 2024 -0500
@@ -133,7 +133,7 @@
       || ord_char == 'a' || ord_char == 'd')
     sort = 'S';
 
-  volatile double_selector selector = nullptr;
+  double_selector selector = nullptr;
   if (ord_char == 'A' || ord_char == 'a')
     selector = select_ana;
   else if (ord_char == 'D' || ord_char == 'd')
@@ -221,7 +221,7 @@
       || ord_char == 'a' || ord_char == 'd')
     sort = 'S';
 
-  volatile float_selector selector = nullptr;
+  float_selector selector = nullptr;
   if (ord_char == 'A' || ord_char == 'a')
     selector = select_ana;
   else if (ord_char == 'D' || ord_char == 'd')
@@ -309,7 +309,7 @@
       || ord_char == 'a' || ord_char == 'd')
     sort = 'S';
 
-  volatile complex_selector selector = nullptr;
+  complex_selector selector = nullptr;
   if (ord_char == 'A' || ord_char == 'a')
     selector = select_ana;
   else if (ord_char == 'D' || ord_char == 'd')
@@ -420,7 +420,7 @@
       || ord_char == 'a' || ord_char == 'd')
     sort = 'S';
 
-  volatile float_complex_selector selector = nullptr;
+  float_complex_selector selector = nullptr;
   if (ord_char == 'A' || ord_char == 'a')
     selector = select_ana;
   else if (ord_char == 'D' || ord_char == 'd')
--- a/liboctave/numeric/sparse-chol.cc	Fri Feb 16 22:58:13 2024 -0500
+++ b/liboctave/numeric/sparse-chol.cc	Sat Feb 17 11:51:15 2024 -0500
@@ -211,7 +211,7 @@
 sparse_chol<chol_type>::sparse_chol_rep::init (const chol_type& a,
     bool natural, bool force)
 {
-  volatile octave_idx_type info = 0;
+  octave_idx_type info = 0;
 
 #if defined (HAVE_CHOLMOD)