From 3e5a1d45d91fe86b8825a575e8efa57d30bb7d04 Mon Sep 17 00:00:00 2001
From: Emily Anne Thompson <emily.anne.thompson@cern.ch>
Date: Fri, 10 Nov 2023 14:40:15 -0800
Subject: [PATCH] Remove unnecessary includes, move all default criticals to
 header files

---
 src/libCom/GPIBNICom.cpp |  8 ++++----
 src/libCom/GPIBNICom.h   |  8 ++++----
 src/libCom/LXICom.cpp    | 10 ++++------
 src/libCom/LXICom.h      |  8 ++++----
 src/libPS/SCPIPs.cpp     |  8 --------
 5 files changed, 16 insertions(+), 26 deletions(-)

diff --git a/src/libCom/GPIBNICom.cpp b/src/libCom/GPIBNICom.cpp
index ea0a5707..f84484d2 100644
--- a/src/libCom/GPIBNICom.cpp
+++ b/src/libCom/GPIBNICom.cpp
@@ -62,7 +62,7 @@ void GPIBNICom::setConfiguration(const nlohmann::json &config) {
         }
     }
 }
-void GPIBNICom::send(char *buf, size_t length, bool critical = false) {
+void GPIBNICom::send(char *buf, size_t length, bool critical) {
     checkInterlock(critical);
     if (!m_good)
         throw std::runtime_error(
@@ -77,7 +77,7 @@ void GPIBNICom::send(char *buf, size_t length, bool critical = false) {
         throw std::runtime_error("GPIBNICom::send error from ibwrt");
     }
 }
-void GPIBNICom::send(const std::string &buf, bool critical = false) {
+void GPIBNICom::send(const std::string &buf, bool critical) {
     checkInterlock(critical);
     char *mybuf = new char[buf.length()];
     strcpy(mybuf, buf.c_str());
@@ -120,14 +120,14 @@ uint32_t GPIBNICom::receive(char *buf, size_t length) {
     }
     return retval;
 }
-std::string GPIBNICom::sendreceive(const std::string &cmd, bool critical = false) {
+std::string GPIBNICom::sendreceive(const std::string &cmd, bool critical) {
     ScopeLock lock(this);
 
     send(cmd, critical);
     return receive();
 }
 void GPIBNICom::sendreceive(char *wbuf, size_t wlength, char *rbuf,
-                            size_t rlength, bool critical = false) {
+                            size_t rlength, bool critical) {
     ScopeLock lock(this);
 
     send(wbuf, wlength, critical);
diff --git a/src/libCom/GPIBNICom.h b/src/libCom/GPIBNICom.h
index 01b3be45..3466f110 100644
--- a/src/libCom/GPIBNICom.h
+++ b/src/libCom/GPIBNICom.h
@@ -60,7 +60,7 @@ class GPIBNICom : public ICom {
      * \param length Number of characters in `buf` that should be sent
      * \param critical Interlock flag, true if interlock is monitoring the command
      */
-    void send(char *buf, size_t length, bool critical);
+    void send(char *buf, size_t length, bool critical = false);
 
     /** Send data to device
      *
@@ -69,7 +69,7 @@ class GPIBNICom : public ICom {
      * \param buf Data to be sent
      * \param critical Interlock flag, true if interlock is monitoring the command
      */
-    void send(const std::string &buf, bool critical);
+    void send(const std::string &buf, bool critical = false);
 
     /** Read data from device
      *
@@ -99,7 +99,7 @@ class GPIBNICom : public ICom {
      *
      * \return Returned data
      */
-    std::string sendreceive(const std::string &cmd, bool critical);
+    std::string sendreceive(const std::string &cmd, bool critical = false);
 
     /** Send data to device and receive reply
      *
@@ -113,7 +113,7 @@ class GPIBNICom : public ICom {
      *
      * \return Number of characters received
      */
-    void sendreceive(char *wbuf, size_t wlength, char *rbuf, size_t rlength, bool critical);
+    void sendreceive(char *wbuf, size_t wlength, char *rbuf, size_t rlength, bool critical = false);
 
  protected:
     /** Request exlusive access to device.
diff --git a/src/libCom/LXICom.cpp b/src/libCom/LXICom.cpp
index 6b7caaa9..da8b8f01 100644
--- a/src/libCom/LXICom.cpp
+++ b/src/libCom/LXICom.cpp
@@ -16,8 +16,6 @@
 #include <netdb.h>        //hostent
 #include <netinet/tcp.h>  // linux extension: socket options (timeout)
 #include <sys/socket.h>
-#include <sys/file.h>
-#include <sys/ioctl.h>
 
 // Register com
 #include "ComRegistry.h"
@@ -156,13 +154,13 @@ void LXICom::init() {
     m_good = true;
 }
 
-void LXICom::send(const std::string &buf, bool critical = false) {
+void LXICom::send(const std::string &buf, bool critical) {
     checkInterlock(critical);
     logger(logDEBUG) << "LXICom::send " << buf;
     tcp_send(buf.c_str());
 }
 
-void LXICom::send(char *buf, size_t length, bool critical = false) { 
+void LXICom::send(char *buf, size_t length, bool critical) { 
     checkInterlock(critical);
     send(std::string(buf, length), critical); 
 }
@@ -186,7 +184,7 @@ uint32_t LXICom::receive(char *buf, size_t length) {
     return (received.size() < length ? received.size() : length);
 }
 
-std::string LXICom::sendreceive(const std::string &cmd, bool critical = false) {
+std::string LXICom::sendreceive(const std::string &cmd, bool critical) {
     send(cmd, critical);
     std::string ret = receive();
 
@@ -194,7 +192,7 @@ std::string LXICom::sendreceive(const std::string &cmd, bool critical = false) {
 }
 
 void LXICom::sendreceive(char *wbuf, size_t wlength, char *rbuf,
-                         size_t rlength, bool critical = false) {
+                         size_t rlength, bool critical) {
     send(wbuf, wlength, critical);
     receive(rbuf, rlength);
 }
diff --git a/src/libCom/LXICom.h b/src/libCom/LXICom.h
index a878f351..f7b9f921 100644
--- a/src/libCom/LXICom.h
+++ b/src/libCom/LXICom.h
@@ -57,7 +57,7 @@ class LXICom : public ICom {
      * \param length Number of characters in `buf` that should be sent
      * \param critical Interlock flag, true if interlock is monitoring the command
      */
-    virtual void send(char* buf, size_t length, bool critical);
+    virtual void send(char* buf, size_t length, bool critical = false);
 
     /** Send data to device
      *
@@ -66,7 +66,7 @@ class LXICom : public ICom {
      * \param buf Data to be sent
      * \param critical Interlock flag, true if interlock is monitoring the command
      */
-    virtual void send(const std::string& buf, bool critical);
+    virtual void send(const std::string& buf, bool critical = false);
 
     /** Read data from device
      *
@@ -96,7 +96,7 @@ class LXICom : public ICom {
      *
      * \return Returned data
      */
-    virtual std::string sendreceive(const std::string& cmd, bool critical);
+    virtual std::string sendreceive(const std::string& cmd, bool critical = false);
 
     /** Write data to device and receive reply
      *
@@ -111,7 +111,7 @@ class LXICom : public ICom {
      * \return Number of characters received
      */
     virtual void sendreceive(char* wbuf, size_t wlength, char* rbuf,
-                             size_t rlength, bool critical);
+                             size_t rlength, bool critical = false);
 
     /** Locking is not supported!
      *
diff --git a/src/libPS/SCPIPs.cpp b/src/libPS/SCPIPs.cpp
index 49d85345..8c5ce62a 100644
--- a/src/libPS/SCPIPs.cpp
+++ b/src/libPS/SCPIPs.cpp
@@ -7,14 +7,6 @@
 #include "ScopeLock.h"
 #include "StringUtils.h"
 
-#include <unistd.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <sys/file.h>
-#include <iostream> 
-
 // Register power supply
 #include "PowerSupplyRegistry.h"
 REGISTER_POWERSUPPLY(SCPIPs)
-- 
GitLab