From 5b0d1bd9e1a09c3a8eacfa6800081e160c702083 Mon Sep 17 00:00:00 2001
From: Sean McBride <sean@rogue-research.com>
Date: Wed, 30 Jan 2013 16:41:38 -0500
Subject: [PATCH] Fix clang -Weverything warnings

Mostly add 'static' to private functions/globals.

Change-Id: Ic7fa75bcc0f245e7b4f8d554db4f58ac0c585e2a
---
 IOStream.cxx                 |  1 +
 SystemInformation.cxx        |  5 ++++-
 SystemTools.cxx              |  4 ++--
 testCommandLineArguments.cxx | 16 ++++++++--------
 testDynamicLoader.cxx        |  2 +-
 testProcess.c                | 22 +++++++++++-----------
 testSystemTools.cxx          | 26 +++++++++++++-------------
 7 files changed, 40 insertions(+), 36 deletions(-)

diff --git a/IOStream.cxx b/IOStream.cxx
index 57b696e..a31f8c8 100644
--- a/IOStream.cxx
+++ b/IOStream.cxx
@@ -272,6 +272,7 @@ namespace KWSYS_NAMESPACE
 
 // Create one public symbol in this object file to avoid warnings from
 // archivers.
+void IOStreamSymbolToAvoidWarning();
 void IOStreamSymbolToAvoidWarning()
 {
 }
diff --git a/SystemInformation.cxx b/SystemInformation.cxx
index b20d724..f057e0f 100644
--- a/SystemInformation.cxx
+++ b/SystemInformation.cxx
@@ -2466,7 +2466,9 @@ bool SystemInformationImplementation::RetrieveCPUPowerManagement()
 #endif
 }
 
-void SystemInformationStripLeadingSpace(kwsys_stl::string& str)
+#if USE_CPUID
+// Used only in USE_CPUID implementation below.
+static void SystemInformationStripLeadingSpace(kwsys_stl::string& str)
 {
   // Because some manufacturers have leading white space - we have to post-process the name.
   kwsys_stl::string::size_type pos = str.find_first_not_of(" ");
@@ -2475,6 +2477,7 @@ void SystemInformationStripLeadingSpace(kwsys_stl::string& str)
     str = str.substr(pos);
     }
 }
+#endif
 
 /** */
 bool SystemInformationImplementation::RetrieveExtendedCPUIdentity()
diff --git a/SystemTools.cxx b/SystemTools.cxx
index b75993e..881c49a 100644
--- a/SystemTools.cxx
+++ b/SystemTools.cxx
@@ -3037,7 +3037,7 @@ void SystemTools::CheckTranslationPath(kwsys_stl::string & path)
   path.erase(path.end()-1, path.end());
 }
 
-void
+static void
 SystemToolsAppendComponents(
   kwsys_stl::vector<kwsys_stl::string>& out_components,
   kwsys_stl::vector<kwsys_stl::string>::const_iterator first,
@@ -4704,7 +4704,7 @@ bool SystemTools::ParseURL( const kwsys_stl::string& URL,
 // ----------------------------------------------------------------------
 // These must NOT be initialized.  Default initialization to zero is
 // necessary.
-unsigned int SystemToolsManagerCount;
+static unsigned int SystemToolsManagerCount;
 SystemToolsTranslationMap *SystemTools::TranslationMap;
 SystemToolsTranslationMap *SystemTools::LongPathMap;
 #ifdef __CYGWIN__
diff --git a/testCommandLineArguments.cxx b/testCommandLineArguments.cxx
index e75a87e..72e6544 100644
--- a/testCommandLineArguments.cxx
+++ b/testCommandLineArguments.cxx
@@ -24,9 +24,9 @@
 #include <stddef.h> /* size_t */
 #include <string.h> /* strcmp */
 
-void* random_ptr = reinterpret_cast<void*>(0x123);
+static void* random_ptr = reinterpret_cast<void*>(0x123);
 
-int argument(const char* arg, const char* value, void* call_data)
+static int argument(const char* arg, const char* value, void* call_data)
 {
   kwsys_ios::cout << "Got argument: \"" << arg << "\" value: \"" << (value?value:"(null)") << "\"" << kwsys_ios::endl;
   if ( call_data != random_ptr )
@@ -37,7 +37,7 @@ int argument(const char* arg, const char* value, void* call_data)
   return 1;
 }
 
-int unknown_argument(const char* argument, void* call_data)
+static int unknown_argument(const char* argument, void* call_data)
 {
   kwsys_ios::cout << "Got unknown argument: \"" << argument << "\"" << kwsys_ios::endl;
   if ( call_data != random_ptr )
@@ -48,12 +48,12 @@ int unknown_argument(const char* argument, void* call_data)
   return 1;
 }
 
-bool CompareTwoItemsOnList(bool i1, bool i2) { return i1 == i2; }
-bool CompareTwoItemsOnList(int i1, int i2) { return i1 == i2; }
-bool CompareTwoItemsOnList(double i1, double i2) { return i1 == i2; }
-bool CompareTwoItemsOnList(const char* i1,
+static bool CompareTwoItemsOnList(bool i1, bool i2) { return i1 == i2; }
+static bool CompareTwoItemsOnList(int i1, int i2) { return i1 == i2; }
+static bool CompareTwoItemsOnList(double i1, double i2) { return i1 == i2; }
+static bool CompareTwoItemsOnList(const char* i1,
   const char* i2) { return strcmp(i1, i2) == 0; }
-bool CompareTwoItemsOnList(const kwsys_stl::string& i1,
+static bool CompareTwoItemsOnList(const kwsys_stl::string& i1,
   const kwsys_stl::string& i2) { return i1 == i2; }
 
 int testCommandLineArguments(int argc, char* argv[])
diff --git a/testDynamicLoader.cxx b/testDynamicLoader.cxx
index cbfb65b..61c1572 100644
--- a/testDynamicLoader.cxx
+++ b/testDynamicLoader.cxx
@@ -35,7 +35,7 @@
 // left on disk.
 #include <testSystemTools.h>
 
-kwsys_stl::string GetLibName(const char* lname)
+static kwsys_stl::string GetLibName(const char* lname)
 {
   // Construct proper name of lib
   kwsys_stl::string slname;
diff --git a/testProcess.c b/testProcess.c
index 269b84b..6d5eb71 100644
--- a/testProcess.c
+++ b/testProcess.c
@@ -47,7 +47,7 @@ int runChild(const char* cmd[], int state, int exception, int value,
              int share, int output, int delay, double timeout, int poll,
              int repeat, int disown);
 
-int test1(int argc, const char* argv[])
+static int test1(int argc, const char* argv[])
 {
   (void)argc; (void)argv;
   fprintf(stdout, "Output on stdout from test returning 0.\n");
@@ -55,7 +55,7 @@ int test1(int argc, const char* argv[])
   return 0;
 }
 
-int test2(int argc, const char* argv[])
+static int test2(int argc, const char* argv[])
 {
   (void)argc; (void)argv;
   fprintf(stdout, "Output on stdout from test returning 123.\n");
@@ -63,7 +63,7 @@ int test2(int argc, const char* argv[])
   return 123;
 }
 
-int test3(int argc, const char* argv[])
+static int test3(int argc, const char* argv[])
 {
   (void)argc; (void)argv;
   fprintf(stdout, "Output before sleep on stdout from timeout test.\n");
@@ -80,7 +80,7 @@ int test3(int argc, const char* argv[])
   return 0;
 }
 
-int test4(int argc, const char* argv[])
+static int test4(int argc, const char* argv[])
 {
   /* Prepare a pointer to an invalid address.  Don't use null, because
   dereferencing null is undefined behaviour and compilers are free to
@@ -109,7 +109,7 @@ int test4(int argc, const char* argv[])
   return 0;
 }
 
-int test5(int argc, const char* argv[])
+static int test5(int argc, const char* argv[])
 {
   int r;
   const char* cmd[4];
@@ -132,7 +132,7 @@ int test5(int argc, const char* argv[])
 }
 
 #define TEST6_SIZE (4096*2)
-void test6(int argc, const char* argv[])
+static void test6(int argc, const char* argv[])
 {
   int i;
   char runaway[TEST6_SIZE+1];
@@ -156,7 +156,7 @@ void test6(int argc, const char* argv[])
    delaying 1/10th of a second should ever have to poll.  */
 #define MINPOLL 5
 #define MAXPOLL 20
-int test7(int argc, const char* argv[])
+static int test7(int argc, const char* argv[])
 {
   (void)argc; (void)argv;
   fprintf(stdout, "Output on stdout before sleep.\n");
@@ -176,7 +176,7 @@ int test7(int argc, const char* argv[])
   return 0;
 }
 
-int test8(int argc, const char* argv[])
+static int test8(int argc, const char* argv[])
 {
   /* Create a disowned grandchild to test handling of processes
      that exit before their children.  */
@@ -200,7 +200,7 @@ int test8(int argc, const char* argv[])
   return r;
 }
 
-int test8_grandchild(int argc, const char* argv[])
+static int test8_grandchild(int argc, const char* argv[])
 {
   (void)argc; (void)argv;
   fprintf(stdout, "Output on stdout from grandchild before sleep.\n");
@@ -221,7 +221,7 @@ int test8_grandchild(int argc, const char* argv[])
   return 0;
 }
 
-int runChild2(kwsysProcess* kp,
+static int runChild2(kwsysProcess* kp,
               const char* cmd[], int state, int exception, int value,
               int share, int output, int delay, double timeout,
               int poll, int disown)
@@ -505,7 +505,7 @@ int main(int argc, const char* argv[])
     fprintf(stderr, "Output on stderr after test %d.\n", n);
     fflush(stdout);
     fflush(stderr);
-#if _WIN32
+#if defined(_WIN32)
     if(argv0) { free(argv0); }
 #endif
     return r;
diff --git a/testSystemTools.cxx b/testSystemTools.cxx
index 3ac0cb3..1690fd5 100644
--- a/testSystemTools.cxx
+++ b/testSystemTools.cxx
@@ -32,7 +32,7 @@
 #include <string.h> /* strcmp */
 
 //----------------------------------------------------------------------------
-const char* toUnixPaths[][2] =
+static const char* toUnixPaths[][2] =
 {
     { "/usr/local/bin/passwd", "/usr/local/bin/passwd" },
     { "/usr/lo cal/bin/pa sswd", "/usr/lo cal/bin/pa sswd" },
@@ -52,8 +52,8 @@ const char* toUnixPaths[][2] =
     {0, 0}
 };
 
-bool CheckConvertToUnixSlashes(kwsys_stl::string input,
-                               kwsys_stl::string output)
+static bool CheckConvertToUnixSlashes(kwsys_stl::string input,
+                                      kwsys_stl::string output)
 {
   kwsys_stl::string result = input;
   kwsys::SystemTools::ConvertToUnixSlashes(result);
@@ -69,17 +69,17 @@ bool CheckConvertToUnixSlashes(kwsys_stl::string input,
 }
 
 //----------------------------------------------------------------------------
-const char* checkEscapeChars[][4] =
+static const char* checkEscapeChars[][4] =
 {
   { "1 foo 2 bar 2", "12", "\\", "\\1 foo \\2 bar \\2"},
   { " {} ", "{}", "#", " #{#} "},
   {0, 0, 0, 0}
 };
 
-bool CheckEscapeChars(kwsys_stl::string input,
-                      const char *chars_to_escape,
-                      char escape_char,
-                      kwsys_stl::string output)
+static bool CheckEscapeChars(kwsys_stl::string input,
+                             const char *chars_to_escape,
+                             char escape_char,
+                             kwsys_stl::string output)
 {
   kwsys_stl::string result = kwsys::SystemTools::EscapeChars(
     input.c_str(), chars_to_escape, escape_char);
@@ -95,7 +95,7 @@ bool CheckEscapeChars(kwsys_stl::string input,
 }
 
 //----------------------------------------------------------------------------
-bool CheckFileOperations()
+static bool CheckFileOperations()
 {
   bool res = true;
 
@@ -129,7 +129,7 @@ bool CheckFileOperations()
 }
 
 //----------------------------------------------------------------------------
-bool CheckStringOperations()
+static bool CheckStringOperations()
 {
   bool res = true;
 
@@ -329,7 +329,7 @@ bool CheckStringOperations()
 
 //----------------------------------------------------------------------------
 
-bool CheckPutEnv(const char* env, const char* name, const char* value)
+static bool CheckPutEnv(const char* env, const char* name, const char* value)
 {
   if(!kwsys::SystemTools::PutEnv(env))
     {
@@ -348,7 +348,7 @@ bool CheckPutEnv(const char* env, const char* name, const char* value)
   return true;
 }
 
-bool CheckUnPutEnv(const char* env, const char* name)
+static bool CheckUnPutEnv(const char* env, const char* name)
 {
   if(!kwsys::SystemTools::UnPutEnv(env))
     {
@@ -365,7 +365,7 @@ bool CheckUnPutEnv(const char* env, const char* name)
   return true;
 }
 
-bool CheckEnvironmentOperations()
+static bool CheckEnvironmentOperations()
 {
   bool res = true;
   res &= CheckPutEnv("A=B", "A", "B");
-- 
GitLab