This is an automated email from the ASF dual-hosted git repository.

rrm pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git

commit 2f305a59b5201f94d872c7176df65d71dfd88557
Author: Randall Meyer <r...@apple.com>
AuthorDate: Mon Jul 30 13:23:28 2018 -0700

    mgmt: General cleanup
    
    Including:
    * removing unused/unrequired includes
    * moving file description to top comment
    * pragma once conversion
    * remove unused preprocessor macros
---
 mgmt/Alarms.cc              |  2 --
 mgmt/Alarms.h               | 20 +++-----------------
 mgmt/BaseManager.cc         | 14 +-------------
 mgmt/BaseManager.h          | 21 ++-------------------
 mgmt/FileManager.cc         | 10 +---------
 mgmt/FileManager.h          | 15 +++------------
 mgmt/LocalManager.cc        |  1 +
 mgmt/LocalManager.h         | 18 +++++-------------
 mgmt/MgmtDefs.h             | 12 +-----------
 mgmt/ProcessManager.cc      |  3 ---
 mgmt/ProcessManager.h       | 16 +++-------------
 mgmt/ProxyConfig.cc         |  5 +++--
 mgmt/ProxyConfig.h          | 14 +-------------
 mgmt/RecordsConfig.h        |  2 --
 mgmt/RecordsConfigUtils.cc  |  9 ---------
 mgmt/Rollback.cc            | 16 ++++++++++++----
 mgmt/Rollback.h             | 25 ++-----------------------
 mgmt/WebMgmtUtils.cc        | 13 +------------
 mgmt/WebMgmtUtils.h         | 26 ++------------------------
 mgmt/api/CoreAPI.cc         |  2 +-
 mgmt/api/EventControlMain.h |  1 +
 21 files changed, 43 insertions(+), 202 deletions(-)

diff --git a/mgmt/Alarms.cc b/mgmt/Alarms.cc
index 0f02a1c..f2e67b9 100644
--- a/mgmt/Alarms.cc
+++ b/mgmt/Alarms.cc
@@ -25,10 +25,8 @@
 #include "ts/ink_string.h"
 #include "ts/ink_file.h"
 #include "ts/ink_time.h"
-#include "LocalManager.h"
 #include "MgmtUtils.h"
 #include "Alarms.h"
-#include "ts/Diags.h"
 
 #include "P_RecCore.h"
 
diff --git a/mgmt/Alarms.h b/mgmt/Alarms.h
index 229df0f..8eb55e0 100644
--- a/mgmt/Alarms.h
+++ b/mgmt/Alarms.h
@@ -1,6 +1,7 @@
 /** @file
 
-  A brief file description
+  Class definitions for alarms keeper, class keeps a queue of Alarm
+  objects. Can be polled on status of alarms.
 
   @section license License
 
@@ -21,22 +22,8 @@
   limitations under the License.
  */
 
-/*
- *
- * Alarms.h
- *   Class definitions for alarms keeper, class keeps a queue of Alarm
- * objects. Can be polled on status of alarms.
- *
- * $Date: 2007-10-05 16:56:44 $
- *
- *
- */
-
 #pragma once
 
-#include <cstdlib>
-#include <cstdio>
-
 #include "ts/ink_hash_table.h"
 #include "ts/ink_mutex.h"
 
@@ -45,8 +32,7 @@ class AppVersionInfo;
 /***********************************************************************
  *
  * MODULARIZATTION: if you are adding new alarms, please ensure to add
- *                 the corresponding alarms in librecords/I_RecAlarms.h
- *
+ *                 the corresponding alarms in lib/records/I_RecAlarms.h
  *
  ***********************************************************************/
 
diff --git a/mgmt/BaseManager.cc b/mgmt/BaseManager.cc
index e2209f7..9e2e4d5 100644
--- a/mgmt/BaseManager.cc
+++ b/mgmt/BaseManager.cc
@@ -1,6 +1,6 @@
 /** @file
 
-  A brief file description
+  Member function definitions for Base Manager class.
 
   @section license License
 
@@ -21,18 +21,6 @@
   limitations under the License.
  */
 
-/**************************************
- *
- * BaseManager.cc
- *   Member function definitions for Base Manager class.
- *
- * $Date: 2003-06-01 18:37:18 $
- *
- *
- */
-
-#include "ts/ink_platform.h"
-#include "ts/ink_hash_table.h"
 #include "ts/ink_memory.h"
 #include "BaseManager.h"
 
diff --git a/mgmt/BaseManager.h b/mgmt/BaseManager.h
index 238ffe5..25152a7 100644
--- a/mgmt/BaseManager.h
+++ b/mgmt/BaseManager.h
@@ -1,6 +1,6 @@
 /** @file
 
-  A brief file description
+  Base Manager Class, base class for all managers.
 
   @section license License
 
@@ -21,16 +21,6 @@
   limitations under the License.
  */
 
-/**************************************
- *
- * BaseManager.h
- *   Base Manager Class, base class for all managers.
- *
- * $Date: 2004-02-03 22:12:02 $
- *
- *
- */
-
 #pragma once
 
 #include "ts/ink_thread.h"
@@ -41,17 +31,10 @@
 #include "MgmtDefs.h"
 #include "MgmtMarshall.h"
 
-/*******************************************
- * used by LocalManager and in Proxy Main. *
- */
-#define MAX_OPTION_SIZE 2048
-#define MAX_PROXY_SERVER_PORTS 2048
-#define MAX_ATTR_LEN 5
-/*******************************************/
-
 /*
  * MgmtEvent defines.
  */
+
 // Event flows: traffic manager -> traffic server
 #define MGMT_EVENT_SYNC_KEY 10000
 #define MGMT_EVENT_SHUTDOWN 10001
diff --git a/mgmt/FileManager.cc b/mgmt/FileManager.cc
index ad2de62..35adfb9 100644
--- a/mgmt/FileManager.cc
+++ b/mgmt/FileManager.cc
@@ -21,23 +21,15 @@
   limitations under the License.
  */
 
+#include "FileManager.h"
 #include "ts/ink_platform.h"
 #include "ts/ink_file.h"
-#include "ts/I_Layout.h"
-#include "FileManager.h"
-#include "Main.h"
 #include "Rollback.h"
 #include "WebMgmtUtils.h"
-#include "MgmtUtils.h"
-#include "ExpandingArray.h"
-#include "MgmtSocket.h"
 
 #include <vector>
 #include <algorithm>
 
-#define DIR_MODE S_IRWXU
-#define FILE_MODE S_IRWXU
-
 FileManager::FileManager()
 {
   bindings = ink_hash_table_create(InkHashTableKeyType_String);
diff --git a/mgmt/FileManager.h b/mgmt/FileManager.h
index b81efc3..0f6b823 100644
--- a/mgmt/FileManager.h
+++ b/mgmt/FileManager.h
@@ -1,6 +1,6 @@
 /** @file
 
-  A brief file description
+  Interface for class to manage configuration updates
 
   @section license License
 
@@ -23,19 +23,11 @@
 
 #pragma once
 
-/****************************************************************************
- *
- *  FileManager.h - Interface for class to manage configuration updates
- *
- *
- ****************************************************************************/
-
-#include <cstdio>
-
 #include "ts/ink_hash_table.h"
+#include "ts/ink_mutex.h"
 #include "ts/List.h"
-#include "Rollback.h"
 
+class ExpandingArray;
 class Rollback;
 
 typedef void (*FileCallbackFunc)(char *, bool);
@@ -50,7 +42,6 @@ enum lockAction_t {
   ACQUIRE_LOCK,
   RELEASE_LOCK,
 };
-class ExpandingArray;
 
 //  class FileManager
 //
diff --git a/mgmt/LocalManager.cc b/mgmt/LocalManager.cc
index a48fd2e..68feb0e 100644
--- a/mgmt/LocalManager.cc
+++ b/mgmt/LocalManager.cc
@@ -25,6 +25,7 @@
 #include "ts/ink_sock.h"
 #include "ts/ink_file.h"
 #include "ts/ink_error.h"
+#include "Alarms.h"
 #include "MgmtUtils.h"
 #include "ts/I_Layout.h"
 #include "ts/runroot.h"
diff --git a/mgmt/LocalManager.h b/mgmt/LocalManager.h
index 4dc34db..2eae7a8 100644
--- a/mgmt/LocalManager.h
+++ b/mgmt/LocalManager.h
@@ -1,6 +1,6 @@
 /** @file
 
-  A brief file description
+  Definitions for the LocalManager class.
 
   @section license License
 
@@ -21,23 +21,14 @@
   limitations under the License.
  */
 
-/*
- *
- * LocalManager.h
- *   Definitions for the LocalManager class.
- *
- * $Date: 2007-10-05 16:56:44 $
- *
- *
- */
-
 #pragma once
 
 #include <string>
 
-#include "Alarms.h"
 #include "BaseManager.h"
-#include <records/I_RecHttp.h>
+#include "records/I_RecHttp.h"
+#include "ts/I_Version.h"
+
 #include <syslog.h>
 #if TS_HAS_WCCP
 #include <wccp/Wccp.h>
@@ -46,6 +37,7 @@
 #include <sys/eventfd.h>
 #endif
 
+class Alarms;
 class FileManager;
 
 enum ManagementPendingOperation {
diff --git a/mgmt/MgmtDefs.h b/mgmt/MgmtDefs.h
index 7dc3f81..c9530ce 100644
--- a/mgmt/MgmtDefs.h
+++ b/mgmt/MgmtDefs.h
@@ -1,6 +1,6 @@
 /** @file
 
-  A brief file description
+  Some mgmt definitions for relatively general use.
 
   @section license License
 
@@ -21,16 +21,6 @@
   limitations under the License.
  */
 
-/*
- *
- * MgmtDef.h
- *   Some mgmt definitions for relatively general use.
- *
- * $Date: 2006-03-08 19:40:20 $
- *
- *
- */
-
 #pragma once
 
 /*
diff --git a/mgmt/ProcessManager.cc b/mgmt/ProcessManager.cc
index f2f851e..701b344 100644
--- a/mgmt/ProcessManager.cc
+++ b/mgmt/ProcessManager.cc
@@ -21,10 +21,7 @@
   limitations under the License.
  */
 
-#include "ts/ink_platform.h"
-
 #include "InkAPIInternal.h"
-#include "MgmtUtils.h"
 #include "ProcessManager.h"
 
 #include "ts/ink_apidefs.h"
diff --git a/mgmt/ProcessManager.h b/mgmt/ProcessManager.h
index e1e0178..2e11dca 100644
--- a/mgmt/ProcessManager.h
+++ b/mgmt/ProcessManager.h
@@ -1,6 +1,8 @@
 /** @file
 
-  A brief file description
+  Process Manager Class, derived from BaseManager. Class provides callback
+  registration for management events as well as the interface to the outside
+  world.
 
   @section license License
 
@@ -21,18 +23,6 @@
   limitations under the License.
  */
 
-/*
- *
- * ProcessManager.h
- *   Process Manager Class, derived from BaseManager. Class provides callback
- * registration for management events as well as the interface to the outside
- * world.
- *
- * $Date: 2003-06-01 18:37:18 $
- *
- *
- */
-
 #pragma once
 
 #include "MgmtUtils.h"
diff --git a/mgmt/ProxyConfig.cc b/mgmt/ProxyConfig.cc
index 3b403a4..6bc38b9 100644
--- a/mgmt/ProxyConfig.cc
+++ b/mgmt/ProxyConfig.cc
@@ -21,10 +21,11 @@
   limitations under the License.
  */
 
-#include "ts/ink_platform.h"
 #include "ProxyConfig.h"
 #include "P_EventSystem.h"
+#if TS_HAS_TESTS
 #include "ts/TestBox.h"
+#endif
 
 ConfigProcessor configProcessor;
 
@@ -171,7 +172,7 @@ ConfigProcessor::get(unsigned int id)
   ink_assert(id <= MAX_CONFIGS);
 
   if (id == 0 || id > MAX_CONFIGS) {
-    // return NULL, because we of an invalid index
+    // because of an invalid index
     return nullptr;
   }
 
diff --git a/mgmt/ProxyConfig.h b/mgmt/ProxyConfig.h
index a9d3352..ffd7447 100644
--- a/mgmt/ProxyConfig.h
+++ b/mgmt/ProxyConfig.h
@@ -21,20 +21,10 @@
   limitations under the License.
  */
 
-/****************************************************************************
+#pragma once
 
-  ProxyConfig.h
-
-
-  ****************************************************************************/
-
-#ifndef _Proxy_Config_h
-#define _Proxy_Config_h
-
-#include "ts/ink_platform.h"
 #include "ts/ink_memory.h"
 #include "ProcessManager.h"
-#include "I_EventSystem.h"
 #include "I_Tasks.h"
 
 class ProxyMutex;
@@ -140,5 +130,3 @@ private:
 };
 
 extern ConfigProcessor configProcessor;
-
-#endif
diff --git a/mgmt/RecordsConfig.h b/mgmt/RecordsConfig.h
index 4a40f64..84f70fb 100644
--- a/mgmt/RecordsConfig.h
+++ b/mgmt/RecordsConfig.h
@@ -23,7 +23,6 @@
 
 #pragma once
 
-//#include "MgmtDefs.h"
 #include "P_RecCore.h"
 
 enum RecordRequiredType {
@@ -49,4 +48,3 @@ void RecordsConfigIterate(RecordElementCallback, void *);
 
 void LibRecordsConfigInit();                 // initializes RecordsConfigIndex
 void RecordsConfigOverrideFromEnvironment(); // Override records from the 
environment
-void test_librecords();
diff --git a/mgmt/RecordsConfigUtils.cc b/mgmt/RecordsConfigUtils.cc
index a7f5557..314d3d1 100644
--- a/mgmt/RecordsConfigUtils.cc
+++ b/mgmt/RecordsConfigUtils.cc
@@ -23,7 +23,6 @@
 
 #include "ts/ink_config.h"
 #include "RecordsConfig.h"
-#include "ts/ParseRules.h"
 
 //-------------------------------------------------------------------------
 // RecordsConfigOverrideFromEnvironment
@@ -151,11 +150,3 @@ LibRecordsConfigInit()
 {
   RecordsConfigIterate(initialize_record, nullptr);
 }
-
-void
-test_librecords()
-{
-  RecRegisterStatInt(RECT_PROCESS, "proxy.process.librecords.testing.int", 
(RecInt)100, RECP_NON_PERSISTENT);
-  RecRegisterStatFloat(RECT_NODE, "proxy.node.librecords.testing.float", 
(RecFloat)100.1, RECP_NON_PERSISTENT);
-  RecRegisterStatCounter(RECT_LOCAL, "proxy.local.librecords.testing.counter", 
(RecCounter)99, RECP_NON_PERSISTENT);
-}
diff --git a/mgmt/Rollback.cc b/mgmt/Rollback.cc
index 6203ea1..5c46c51 100644
--- a/mgmt/Rollback.cc
+++ b/mgmt/Rollback.cc
@@ -22,17 +22,14 @@
  */
 
 #include "ts/ink_platform.h"
-#include "ts/ink_string.h"
 #include "ts/ink_memory.h"
 #include "ts/ink_time.h"
-#include "ts/ink_file.h"
+#include "Alarms.h"
 #include "LocalManager.h"
 #include "Rollback.h"
 #include "WebMgmtUtils.h"
-#include "MgmtUtils.h"
 #include "ExpandingArray.h"
 #include "MgmtSocket.h"
-#include "ts/ink_cap.h"
 #include "ts/I_Layout.h"
 #include "FileManager.h"
 #include "ProxyConfig.h"
@@ -40,6 +37,17 @@
 #define MAX_VERSION_DIGITS 11
 #define DEFAULT_BACKUPS 2
 
+constexpr int ACTIVE_VERSION  = 0;
+constexpr int INVALID_VERSION = -1;
+
+#if HAVE_STRUCT_STAT_ST_MTIMESPEC_TV_NSEC
+#define TS_ARCHIVE_STAT_MTIME(t) ((t).st_mtime * 1000000000 + 
(t).st_mtimespec.tv_nsec)
+#elif HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC
+#define TS_ARCHIVE_STAT_MTIME(t) ((t).st_mtime * 1000000000 + 
(t).st_mtim.tv_nsec)
+#else
+#define TS_ARCHIVE_STAT_MTIME(t) ((t).st_mtime * 1000000000)
+#endif
+
 // Error Strings
 const char *RollbackStrings[] = {"Rollback Ok", "File was not found", "Version 
was out of date", "System Call Error",
                                  "Invalid Version - Version Numbers Must 
Increase"};
diff --git a/mgmt/Rollback.h b/mgmt/Rollback.h
index 5586e3c..77e56c2 100644
--- a/mgmt/Rollback.h
+++ b/mgmt/Rollback.h
@@ -1,6 +1,6 @@
 /** @file
 
-  A brief file description
+  Interface for class to allow rollback of configuration files
 
   @section license License
 
@@ -23,32 +23,11 @@
 
 #pragma once
 
-/****************************************************************************
- *
- *  Rollback.h - Interface for class to allow rollback of configuration
- *                  files
- *
- *
- ****************************************************************************/
-
-#include "ts/ink_platform.h"
 #include "ts/ink_mutex.h"
-#include "ts/ink_assert.h"
-#include "ts/TextBuffer.h"
 #include "ts/List.h"
 
 class FileManager;
-
-#define ACTIVE_VERSION 0
-#define INVALID_VERSION -1
-
-#if HAVE_STRUCT_STAT_ST_MTIMESPEC_TV_NSEC
-#define TS_ARCHIVE_STAT_MTIME(t) ((t).st_mtime * 1000000000 + 
(t).st_mtimespec.tv_nsec)
-#elif HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC
-#define TS_ARCHIVE_STAT_MTIME(t) ((t).st_mtime * 1000000000 + 
(t).st_mtim.tv_nsec)
-#else
-#define TS_ARCHIVE_STAT_MTIME(t) ((t).st_mtime * 1000000000)
-#endif
+class TextBuffer;
 
 typedef int version_t;
 
diff --git a/mgmt/WebMgmtUtils.cc b/mgmt/WebMgmtUtils.cc
index 41bf759..5220df7 100644
--- a/mgmt/WebMgmtUtils.cc
+++ b/mgmt/WebMgmtUtils.cc
@@ -1,6 +1,6 @@
 /** @file
 
-  A brief file description
+  Functions for interfacing to management records
 
   @section license License
 
@@ -21,24 +21,13 @@
   limitations under the License.
  */
 
-#include "ts/ink_platform.h"
 #include "ts/ink_string.h"
 #include "ts/Tokenizer.h"
-#include "ts/ink_code.h"
 #include "ts/ink_file.h"
-#include "LocalManager.h"
 #include "MgmtUtils.h"
 #include "WebMgmtUtils.h"
 #include "ts/Regex.h"
 
-/****************************************************************************
- *
- *  WebMgmtUtils.cc - Functions for interfacing to management records
- *
- *
- *
- ****************************************************************************/
-
 // bool varSetFromStr(const char*, const char* )
 //
 // Sets the named local manager variable from the value string
diff --git a/mgmt/WebMgmtUtils.h b/mgmt/WebMgmtUtils.h
index 4a01ab9..00c1b94 100644
--- a/mgmt/WebMgmtUtils.h
+++ b/mgmt/WebMgmtUtils.h
@@ -1,6 +1,6 @@
 /** @file
 
-  A brief file description
+  Functions for interfacing to management records
 
   @section license License
 
@@ -21,29 +21,15 @@
   limitations under the License.
  */
 
-#ifndef _WEB_MGMT_UTILS_
-#define _WEB_MGMT_UTILS_
+#pragma once
 
 #include "MgmtDefs.h"
-
-/****************************************************************************
- *
- *  WebMgmtUtils.h - Functions for interfacing to management records
- *
- *
- *
- ****************************************************************************/
-
 #include "ts/ink_hash_table.h"
-#include "ts/TextBuffer.h"
-#include "ExpandingArray.h"
-
 #include "P_RecCore.h"
 
 // class MgmtData - stores information from local manager
 //    variables in its native type
 //
-#include "P_RecCore.h"
 class MgmtData
 {
 public:
@@ -101,16 +87,8 @@ InkHashTable *processFormSubmission_noSubstitute(char 
*submission);
 int setHostnameVar();
 void appendDefaultDomain(char *hostname, int bufLength);
 
-// Some scaling constants
-#define BYTES_TO_MB_SCALE (1 / (1024 * 1024.0))
-#define MBIT_TO_KBIT_SCALE (1000.0)
-#define SECOND_TO_MILLISECOND_SCALE (1000.0)
-#define PCT_TO_INTPCT_SCALE (100.0)
-
 bool recordValidityCheck(const char *varName, const char *value);
 bool recordRegexCheck(const char *pattern, const char *value);
 bool recordRangeCheck(const char *pattern, const char *value);
 bool recordIPCheck(const char *pattern, const char *value);
 bool recordRestartCheck(const char *varName);
-
-#endif
diff --git a/mgmt/api/CoreAPI.cc b/mgmt/api/CoreAPI.cc
index d92148c..53c6a4e 100644
--- a/mgmt/api/CoreAPI.cc
+++ b/mgmt/api/CoreAPI.cc
@@ -32,6 +32,7 @@
 #include "ts/ink_platform.h"
 #include "ts/ink_file.h"
 #include "ts/ParseRules.h"
+#include "Alarms.h"
 #include "MgmtUtils.h"
 #include "LocalManager.h"
 #include "FileManager.h"
@@ -40,7 +41,6 @@
 #include "ts/Diags.h"
 #include "ts/ink_hash_table.h"
 #include "ExpandingArray.h"
-//#include "I_AccCrypto.h"
 
 #include "CoreAPI.h"
 #include "CoreAPIShared.h"
diff --git a/mgmt/api/EventControlMain.h b/mgmt/api/EventControlMain.h
index 52de265..7e1d8e1 100644
--- a/mgmt/api/EventControlMain.h
+++ b/mgmt/api/EventControlMain.h
@@ -33,6 +33,7 @@
 
 #include "mgmtapi.h"       //add the include path b/c included in web dir
 #include "CoreAPIShared.h" // for NUM_EVENTS
+#include "Alarms.h"
 
 // use events_registered[event_id] as index to check if alarm is registered
 typedef struct {

Reply via email to