From d6da23efd2adf2c94b62569b4161161438edce5f Mon Sep 17 00:00:00 2001
From: donker <donker@astron.nl>
Date: Mon, 16 Aug 2021 15:42:02 +0200
Subject: [PATCH] L2SDP-261, cleanup.

---
 src/opcua/ua_server.cpp |  4 +---
 src/periph/fpga.cpp     |  2 +-
 src/sdptr.cpp           | 22 ++--------------------
 3 files changed, 4 insertions(+), 24 deletions(-)

diff --git a/src/opcua/ua_server.cpp b/src/opcua/ua_server.cpp
index 9cc9cef8..e29b9f68 100644
--- a/src/opcua/ua_server.cpp
+++ b/src/opcua/ua_server.cpp
@@ -236,7 +236,6 @@ static UA_StatusCode ua_write_DataSource(UA_Server *server,
                     // UA_LOG_INFO(UA_Log_Stdout, UA_LOGCATEGORY_USERLAND,"ua_write_DataSource: for fpga class");
                     SD.unb->write(termout, regname, data_sdp, data->value.arrayLength);
                 }
-                delete[] data_sdp;
             } catch (runtime_error& e) {
                 cerr << "ua_write_DataSource error: " << e.what() << endl;
                 retval = false;
@@ -244,10 +243,9 @@ static UA_StatusCode ua_write_DataSource(UA_Server *server,
         }
         else {
             cerr << "ua_write no retval" << endl;
-            delete[] data_sdp;
         }
+        if (data_sdp != NULL) { delete[] data_sdp; }
     }
-
     delete[] regname;
     return UA_STATUSCODE_GOOD;
 }
diff --git a/src/periph/fpga.cpp b/src/periph/fpga.cpp
index 8fe5c127..7ffec6fc 100644
--- a/src/periph/fpga.cpp
+++ b/src/periph/fpga.cpp
@@ -1580,7 +1580,7 @@ bool Periph_fpga::read_xst_integration_interval(TermOutput& termout, int format)
 
 bool Periph_fpga::write_xst_integration_interval(const char *data)
 {
-    uint32_t *_ptr = (uint32_t *)data;
+    // uint32_t *_ptr = (uint32_t *)data;
     // TODO, fill in if supported in FW
     // return Write("mm/0/REG_STAT_HDR_DAT_XST/0/??", data);
     return true;
diff --git a/src/sdptr.cpp b/src/sdptr.cpp
index 83570506..fc4f4a08 100644
--- a/src/sdptr.cpp
+++ b/src/sdptr.cpp
@@ -59,8 +59,6 @@ Serverdat SD;
 
 void monitor()
 {
-    string line;
-    string cmdname = "";
     TermOutput termout;
     struct timeval current_time;
     time_t secs;
@@ -84,11 +82,9 @@ void monitor()
         pthread_mutex_lock(&SD.newpoint_lock);
         pthread_cond_timedwait(&SD.newpoint_cond, &SD.newpoint_lock, (const struct timespec *)&SD.t0);
         pthread_mutex_unlock(&SD.newpoint_lock);
-
-        gettimeofday(&current_time, NULL);
-        SD.tod = current_time.tv_sec;
         SD.uptime++;
 
+        gettimeofday(&current_time, NULL);
         secs = current_time.tv_sec;
         now = gmtime(&secs);
         sprintf(time_str, "%02d:%02d:%02d.%06ld", now->tm_hour, now->tm_min, now->tm_sec, current_time.tv_usec);
@@ -98,17 +94,8 @@ void monitor()
         if (SD.unb != NULL) {
             // cout << "sdptr_monitor start" << endl;
             SD.unb->monitor(termout);
-
-            // Do PPS monitor here too, see: https://support.astron.nl/jira/browse/L2SDP-225
+            termout.clear();
         }
-
-        //cout << "Monitor thread : " << print_termout(termout) << endl;
-        termout.clear();
-
-        //if (retries <= 0) {
-            //cerr << "Re-initializing, Read register maps again!" << endl;
-            //raise(SIGHUP)
-        //}
     }
 }
 
@@ -140,11 +127,6 @@ void server_init(bool warm_start)
     cerr << "done, it is mine. Now (re)init all" << endl;
 
     if (warm_start) {
-        //TermOutput termout;
-        //for (uint c=0; c<c_MAX_CONTROL_SERVERS; c++) {
-        //    SD.unb->pcontrol(c, termout, 'S'); // shutdown thread
-        //}
-        //usleep(1000000);
         if (SD.unb != NULL) delete SD.unb;
         SD.unb = NULL;
     }
-- 
GitLab